From b8c8a55eb7cfc3f6c6eae93053b3be8b489f9da5 Mon Sep 17 00:00:00 2001 From: Wylie Conlon Date: Mon, 1 Mar 2021 14:51:14 -0500 Subject: [PATCH] Fix tests that weren't fully testing the navigation --- .../components/doc_viewer/doc_viewer.tsx | 2 +- .../apps/context/_discover_navigation.js | 10 +++++++--- .../apps/discover/_data_grid_context.ts | 11 ++++++++--- test/functional/page_objects/context_page.ts | 17 +++++++---------- test/functional/page_objects/discover_page.ts | 4 ++++ 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/plugins/discover/public/application/components/doc_viewer/doc_viewer.tsx b/src/plugins/discover/public/application/components/doc_viewer/doc_viewer.tsx index 0c888091bcbdfd..d0476d4c38b489 100644 --- a/src/plugins/discover/public/application/components/doc_viewer/doc_viewer.tsx +++ b/src/plugins/discover/public/application/components/doc_viewer/doc_viewer.tsx @@ -46,7 +46,7 @@ export function DocViewer(renderProps: DocViewRenderProps) { } return ( -
+
); diff --git a/test/functional/apps/context/_discover_navigation.js b/test/functional/apps/context/_discover_navigation.js index f5cc3a323c976e..03828ff775d4ff 100644 --- a/test/functional/apps/context/_discover_navigation.js +++ b/test/functional/apps/context/_discover_navigation.js @@ -29,6 +29,7 @@ export default function ({ getService, getPageObjects }) { ]); const testSubjects = getService('testSubjects'); const dashboardAddPanel = getService('dashboardAddPanel'); + const browser = getService('browser'); describe('context link in discover', () => { before(async () => { @@ -119,9 +120,12 @@ export default function ({ getService, getPageObjects }) { await docTable.clickRowToggle({ rowIndex: 0 }); const rowActions = await docTable.getRowActions({ rowIndex: 0 }); await rowActions[1].click(); - await PageObjects.header.waitUntilLoadingHasFinished(); - const contextFields = await docTable.getFields(); - expect(contextFields.length).to.be.greaterThan(0); + await PageObjects.common.sleep(250); + // accept alert if it pops up + const alert = await browser.getAlert(); + await alert?.accept(); + expect(await browser.getCurrentUrl()).to.contain('#/doc'); + expect(await PageObjects.discover.isShowingDocViewer()).to.be(true); }); }); } diff --git a/test/functional/apps/discover/_data_grid_context.ts b/test/functional/apps/discover/_data_grid_context.ts index 4896d974321ea0..6ee6eee63b05d6 100644 --- a/test/functional/apps/discover/_data_grid_context.ts +++ b/test/functional/apps/discover/_data_grid_context.ts @@ -32,6 +32,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const kibanaServer = getService('kibanaServer'); const esArchiver = getService('esArchiver'); const dashboardAddPanel = getService('dashboardAddPanel'); + const browser = getService('browser'); describe('discover data grid context tests', () => { before(async () => { @@ -100,12 +101,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await dashboardAddPanel.addSavedSearch('my search'); await PageObjects.header.waitUntilLoadingHasFinished(); - await dataGrid.clickRowToggle({ rowIndex: 0 }); + await docTable.clickRowToggle({ rowIndex: 0 }); const rowActions = await docTable.getRowActions({ rowIndex: 0 }); await rowActions[1].click(); + await PageObjects.common.sleep(250); + // accept alert if it pops up + const alert = await browser.getAlert(); + await alert?.accept(); + expect(await browser.getCurrentUrl()).to.contain('#/doc'); await PageObjects.header.waitUntilLoadingHasFinished(); - const contextFields = await docTable.getFields(); - expect(contextFields.length).to.be.greaterThan(0); + expect(await PageObjects.discover.isShowingDocViewer()).to.be(true); }); }); } diff --git a/test/functional/page_objects/context_page.ts b/test/functional/page_objects/context_page.ts index b758423d9346dd..360e022f29e2ba 100644 --- a/test/functional/page_objects/context_page.ts +++ b/test/functional/page_objects/context_page.ts @@ -7,7 +7,6 @@ */ import rison from 'rison-node'; -import { getUrl } from '@kbn/test'; import { FtrProviderContext } from '../ftr_provider_context'; const DEFAULT_INITIAL_STATE = { @@ -15,8 +14,6 @@ const DEFAULT_INITIAL_STATE = { }; export function ContextPageProvider({ getService, getPageObjects }: FtrProviderContext) { - const browser = getService('browser'); - const config = getService('config'); const retry = getService('retry'); const testSubjects = getService('testSubjects'); const PageObjects = getPageObjects(['header', 'common']); @@ -28,14 +25,14 @@ export function ContextPageProvider({ getService, getPageObjects }: FtrProviderC ...DEFAULT_INITIAL_STATE, ...overrideInitialState, }); - const appUrl = getUrl.noAuth(config.get('servers.kibana'), { - ...config.get('apps.context'), - hash: `${config.get('apps.context.hash')}/${indexPattern}/${anchorId}?_a=${initialState}`, - }); - - log.debug(`browser.get(${appUrl})`); - await browser.get(appUrl); + await PageObjects.common.navigateToUrl( + 'discover', + `#/context/${indexPattern}/${anchorId}?_a=${initialState}`, + { + useActualUrl: true, + } + ); await PageObjects.header.awaitGlobalLoadingIndicatorHidden(); await this.waitUntilContextLoadingHasFinished(); // For lack of a better way, using a sleep to ensure page is loaded before proceeding diff --git a/test/functional/page_objects/discover_page.ts b/test/functional/page_objects/discover_page.ts index b7b4535641c900..733f5cb59fbbb3 100644 --- a/test/functional/page_objects/discover_page.ts +++ b/test/functional/page_objects/discover_page.ts @@ -222,6 +222,10 @@ export function DiscoverPageProvider({ getService, getPageObjects }: FtrProvider await find.clickByCssSelector('.fa-sort-up'); } + public async isShowingDocViewer() { + return await testSubjects.exists('kbnDocViewer'); + } + public async getMarks() { const table = await docTable.getTable(); const $ = await table.parseDomContent();