From b328bd0e3d0696406dc753ac9272817bd8bba0d4 Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Thu, 26 Jul 2018 19:07:42 -0700 Subject: [PATCH] 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. --- .../settings/__snapshots__/advanced_settings.test.js.snap | 8 ++++++-- .../management/sections/settings/advanced_settings.js | 2 +- test/functional/page_objects/settings_page.js | 3 ++- test/functional/services/test_subjects.js | 8 ++++++++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/core_plugins/kibana/public/management/sections/settings/__snapshots__/advanced_settings.test.js.snap b/src/core_plugins/kibana/public/management/sections/settings/__snapshots__/advanced_settings.test.js.snap index 08e105b50d295..bfde665a6e5dc 100644 --- a/src/core_plugins/kibana/public/management/sections/settings/__snapshots__/advanced_settings.test.js.snap +++ b/src/core_plugins/kibana/public/management/sections/settings/__snapshots__/advanced_settings.test.js.snap @@ -20,7 +20,9 @@ exports[`AdvancedSettings should render normally 1`] = ` -

+

Settings

@@ -253,7 +255,9 @@ exports[`AdvancedSettings should render specific setting if given setting key 1` -

+

Settings

diff --git a/src/core_plugins/kibana/public/management/sections/settings/advanced_settings.js b/src/core_plugins/kibana/public/management/sections/settings/advanced_settings.js index 2ecc931906841..7899bbd2b0681 100644 --- a/src/core_plugins/kibana/public/management/sections/settings/advanced_settings.js +++ b/src/core_plugins/kibana/public/management/sections/settings/advanced_settings.js @@ -137,7 +137,7 @@ export class AdvancedSettings extends Component { -

Settings

+

Settings

diff --git a/test/functional/page_objects/settings_page.js b/test/functional/page_objects/settings_page.js index 5e509c913445d..766a97fbc2b1b 100644 --- a/test/functional/page_objects/settings_page.js +++ b/test/functional/page_objects/settings_page.js @@ -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() { diff --git a/test/functional/services/test_subjects.js b/test/functional/services/test_subjects.js index 9a614a1acbdc2..06de796fba72f 100644 --- a/test/functional/services/test_subjects.js +++ b/test/functional/services/test_subjects.js @@ -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);