Skip to content

Commit 752c333

Browse files
author
spalger
committed
[console] add functional tests to ensure that settings work
1 parent 086a40c commit 752c333

4 files changed

Lines changed: 54 additions & 4 deletions

File tree

src/core_plugins/console/public/src/directives/settings.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ <h4>Editor &amp; Output pane settings</h4>
1414
type="number"
1515
required
1616
class="form-control"
17+
data-test-subj="setting-font-size-input"
1718
>
1819
</div>
1920
</div>
@@ -62,7 +63,8 @@ <h4>Autocomplete</h4>
6263
<button
6364
type="submit"
6465
ng-disabled="settingsForm.$invalid"
65-
class="btn btn-primary">
66+
class="btn btn-primary"
67+
data-test-subj="settings-save-button">
6668
Save
6769
</button>
6870
</div>

src/ui/public/kbn_top_nav/kbn_top_nav.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<navbar ng-show="kbnTopNav.isVisible()" class="kibana-nav-options">
1+
<navbar ng-show="kbnTopNav.isVisible()" class="kibana-nav-options" data-test-subj="top-nav">
22
<div ng-transclude></div>
33
<div class="button-group kibana-nav-actions" role="toolbar">
44
<button
@@ -13,6 +13,7 @@
1313
tooltip-placement="bottom"
1414
tooltip-popup-delay="400"
1515
tooltip-append-to-body="1"
16+
data-test-subj="menu-item-{{menuItem.key}}"
1617
>
1718
</button>
1819
</div>

test/functional/apps/console/_console.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,18 @@ bdd.describe('console app', function describeIndexTests() {
5454
});
5555
});
5656
});
57+
58+
bdd.it('settings should allow changing the text size', async function () {
59+
await PageObjects.console.setFontSizeSetting(20);
60+
await PageObjects.common.try(async () => {
61+
// the settings are not applied synchronously, so we retry for a time
62+
expect(await PageObjects.console.getRequestFontSize()).to.be('20px');
63+
});
64+
65+
await PageObjects.console.setFontSizeSetting(24);
66+
await PageObjects.common.try(async () => {
67+
// the settings are not applied synchronously, so we retry for a time
68+
expect(await PageObjects.console.getRequestFontSize()).to.be('24px');
69+
});
70+
});
5771
});

test/support/page_objects/console_page.js

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ async function getVisibleTextFromAceEditor(editor) {
1212
}
1313

1414
export default class ConsolePage {
15-
init() {
15+
init(remote) {
16+
this.remote = remote;
17+
}
1618

19+
async getRequestEditor() {
20+
return await PageObjects.common.findTestSubject('console request-editor');
1721
}
1822

1923
async getRequest() {
20-
const requestEditor = await PageObjects.common.findTestSubject('console request-editor');
24+
const requestEditor = await this.getRequestEditor();
2125
return await getVisibleTextFromAceEditor(requestEditor);
2226
}
2327

@@ -35,4 +39,33 @@ export default class ConsolePage {
3539
const closeButton = await PageObjects.common.findTestSubject('console help-close-button');
3640
await closeButton.click();
3741
}
42+
43+
async openSettings() {
44+
const settingsButton = await PageObjects.common.findTestSubject('console top-nav menu-item-settings');
45+
await settingsButton.click();
46+
}
47+
48+
async setFontSizeSetting(newSize) {
49+
await this.openSettings();
50+
51+
// while the settings form opens/loads this may fail, so retry for a while
52+
await PageObjects.common.try(async () => {
53+
const fontSizeInput = await PageObjects.common.findTestSubject('console setting-font-size-input');
54+
await fontSizeInput.clearValue();
55+
await fontSizeInput.click();
56+
await fontSizeInput.type(String(newSize));
57+
});
58+
59+
const saveButton = await PageObjects.common.findTestSubject('console settings-save-button');
60+
await saveButton.click();
61+
}
62+
63+
async getFontSize(editor) {
64+
const aceLine = await editor.findByClassName('ace_line');
65+
return await aceLine.getComputedStyle('font-size');
66+
}
67+
68+
async getRequestFontSize() {
69+
return await this.getFontSize(await this.getRequestEditor());
70+
}
3871
}

0 commit comments

Comments
 (0)