Verify that we've navigated to Settings by checking the title. (#21245)

* Fail the consuming test if navigation to settings is unsuccessful.
* Add testSubjects.existOrFail helper.
This commit is contained in:
CJ Cenizal 2018-07-26 19:07:42 -07:00 committed by GitHub
parent 5fcd10ef71
commit b328bd0e3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 4 deletions

View file

@ -20,7 +20,9 @@ exports[`AdvancedSettings should render normally 1`] = `
<EuiText
grow={true}
>
<h1>
<h1
data-test-subj="managementSettingsTitle"
>
Settings
</h1>
</EuiText>
@ -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>

View file

@ -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>

View file

@ -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() {

View file

@ -17,6 +17,7 @@
* under the License.
*/
import expect from 'expect.js';
import testSubjSelector from '@kbn/test-subj-selector';
import {
filter as filterAsync,
@ -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);