Skip to content

Commit

Permalink
Verify that we've navigated to Settings by checking the title. (elast…
Browse files Browse the repository at this point in the history
…ic#21245)

* Fail the consuming test if navigation to settings is unsuccessful.
* Add testSubjects.existOrFail helper.
  • Loading branch information
cjcenizal committed Jul 27, 2018
1 parent f3e0ef6 commit 215339f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ exports[`AdvancedSettings should render normally 1`] = `
<EuiText
grow={true}
>
<h1>
<h1
data-test-subj="managementSettingsTitle"
>
Settings
</h1>
</EuiText>
Expand Down Expand Up @@ -253,7 +255,9 @@ exports[`AdvancedSettings should render specific setting if given setting key 1`
<EuiText
grow={true}
>
<h1>
<h1
data-test-subj="managementSettingsTitle"
>
Settings
</h1>
</EuiText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class AdvancedSettings extends Component {
<EuiFlexGroup gutterSize="none">
<EuiFlexItem>
<EuiText>
<h1>Settings</h1>
<h1 data-test-subj="managementSettingsTitle">Settings</h1>
</EuiText>
</EuiFlexItem>
<EuiFlexItem>
Expand Down
3 changes: 2 additions & 1 deletion test/functional/page_objects/settings_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export function SettingsPageProvider({ getService, getPageObjects }) {

async clickKibanaSettings() {
await this.clickLinkText('Advanced Settings');
await PageObjects.header.waitUntilLoadingHasFinished();
// Verify navigation is successful.
await testSubjects.existOrFail('managementSettingsTitle');
}

async clickKibanaSavedObjects() {
Expand Down
8 changes: 8 additions & 0 deletions test/functional/services/test_subjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/

import expect from 'expect.js';
import testSubjSelector from '@kbn/test-subj-selector';
import {
filter as filterAsync,
Expand All @@ -37,6 +38,13 @@ export function TestSubjectsProvider({ getService }) {
return await find.existsByDisplayedByCssSelector(testSubjSelector(selector), timeout);
}

async existOrFail(selector, timeout = 1000) {
log.debug(`TestSubjects.existOrFail(${selector})`);
const doesExist = await this.exists(selector, timeout);
// Verify element exists, or else fail the test consuming this.
expect(doesExist).to.be(true);
}

async append(selector, text) {
return await retry.try(async () => {
const input = await this.find(selector);
Expand Down

0 comments on commit 215339f

Please sign in to comment.