From 8315d8c3fb0b88d3d7196f3e3e4c56894257e3a4 Mon Sep 17 00:00:00 2001 From: Gerard Soldevila Date: Thu, 2 Nov 2023 10:04:51 +0100 Subject: [PATCH] [application_deep_links] Unify / improve navigation between apps (#170228) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Attempt at fixing https://github.com/elastic/kibana/issues/166893 PR [#168741](https://github.com/elastic/kibana/pull/168741) forgot to update one of the tests to **exclusively** use `navigateToAppLinks`. Thus, the impacted test had a duplicated navigation logic. This PR: * removes that unintended call (this should hopefully fix flakiness). * simplifies and unifies test logic, improving readability. Flaky test runner pipeline - 100x 🟢 https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3840 --- .../core_plugins/application_deep_links.ts | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/test/plugin_functional/test_suites/core_plugins/application_deep_links.ts b/test/plugin_functional/test_suites/core_plugins/application_deep_links.ts index 5b7b561ea1ef2..e4973b05bd955 100644 --- a/test/plugin_functional/test_suites/core_plugins/application_deep_links.ts +++ b/test/plugin_functional/test_suites/core_plugins/application_deep_links.ts @@ -8,11 +8,10 @@ import url from 'url'; import expect from '@kbn/expect'; -import { PluginFunctionalProviderContext } from '../../services'; +import type { PluginFunctionalProviderContext } from '../../services'; export default function ({ getService, getPageObjects }: PluginFunctionalProviderContext) { const PageObjects = getPageObjects(['common']); - const browser = getService('browser'); const appsMenu = getService('appsMenu'); const testSubjects = getService('testSubjects'); @@ -20,8 +19,13 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide const esArchiver = getService('esArchiver'); const log = getService('log'); - const loadingScreenNotShown = async () => - expect(await testSubjects.exists('kbnLoadingMessage')).to.be(false); + const clickAppLink = async (app: string) => { + const appLink = `dlNav${app}`; + if (!(await testSubjects.exists(appLink))) { + log.debug(`App ${app} not found on side nav`); + } + await testSubjects.click(appLink); + }; const getKibanaUrl = (pathname?: string, search?: string) => url.format({ @@ -42,65 +46,64 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide }); }; - const navigateToAppLinks = async (subject: string) => { - if (!(await testSubjects.exists(subject))) { - log.debug(`side nav in app not in DOM`); - } - await testSubjects.click(subject); + const loadingScreenNotShown = async () => + expect(await testSubjects.exists('kbnLoadingMessage')).to.be(false); + + const checkAppVisible = async (app: string) => { + const appContainer = `dlApp${app}`; + await testSubjects.existOrFail(appContainer); }; - // FLAKY: https://github.com/elastic/kibana/issues/166893 - describe.skip('application deep links navigation', function describeDeepLinksTests() { + describe('application deep links navigation', function describeDeepLinksTests() { before(async () => { await esArchiver.emptyKibanaIndex(); await PageObjects.common.navigateToApp('dl'); }); it('should start on home page', async () => { - await testSubjects.existOrFail('dlAppHome'); + await checkAppVisible('Home'); }); it('should navigate to page A when navlink is clicked', async () => { - await navigateToAppLinks('dlNavPageA'); + await clickAppLink('PageA'); await waitForUrlToBe('/app/dl/page-a'); await loadingScreenNotShown(); - await testSubjects.existOrFail('dlNavPageA'); + await checkAppVisible('PageA'); }); it('should be able to use the back button to navigate back to previous deep link', async () => { await browser.goBack(); await waitForUrlToBe('/app/dl/home'); await loadingScreenNotShown(); - await testSubjects.existOrFail('dlNavHome'); + await checkAppVisible('Home'); }); it('should navigate to nested page B when navlink is clicked', async () => { - await navigateToAppLinks('dlNavDeepPageB'); + await clickAppLink('DeepPageB'); await waitForUrlToBe('/app/dl/page-b'); await loadingScreenNotShown(); - await testSubjects.existOrFail('dlNavDeepPageB'); + await checkAppVisible('PageB'); }); it('should navigate to Home when navlink is clicked inside the defined category group', async () => { - await appsMenu.clickLink('DL Home', { category: 'securitySolution' }); - await navigateToAppLinks('dlAppHome'); + await clickAppLink('Home'); await waitForUrlToBe('/app/dl/home'); await loadingScreenNotShown(); - await testSubjects.existOrFail('dlAppHome'); + await checkAppVisible('Home'); }); it('should navigate to nested page B using navigateToApp path', async () => { - await testSubjects.click('dlNavDeepPageB'); + await clickAppLink('DeepPageB'); await waitForUrlToBe('/app/dl/page-b'); await loadingScreenNotShown(); - await testSubjects.existOrFail('dlNavDeepPageB'); + await checkAppVisible('PageB'); }); it('should navigate to nested page A using navigateToApp deepLinkId', async () => { - await testSubjects.click('dlNavDeepPageAById'); + await clickAppLink('DeepPageAById'); await waitForUrlToBe('/app/dl/page-a'); await loadingScreenNotShown(); - await testSubjects.existOrFail('dlNavPageA'); + await checkAppVisible('PageA'); }); it('should not display hidden deep links', async () => {