From 5707690494f0836a71b5488958549f61642d9237 Mon Sep 17 00:00:00 2001 From: Dmitry Lemeshko Date: Mon, 18 Mar 2019 19:05:26 +0100 Subject: [PATCH] Dashboard embeddable rendering tests: return names of failed visualisations (#32646) --- .../apps/dashboard/embeddable_rendering.js | 15 ++++++----- .../functional/page_objects/dashboard_page.js | 12 +++++++++ .../services/dashboard/add_panel.js | 26 ++++++++++++------- .../services/dashboard/expectations.js | 6 +++++ 4 files changed, 44 insertions(+), 15 deletions(-) diff --git a/test/functional/apps/dashboard/embeddable_rendering.js b/test/functional/apps/dashboard/embeddable_rendering.js index f39d9ab4377c3..716d169c490b9 100644 --- a/test/functional/apps/dashboard/embeddable_rendering.js +++ b/test/functional/apps/dashboard/embeddable_rendering.js @@ -34,6 +34,7 @@ export default function ({ getService, getPageObjects }) { const dashboardExpect = getService('dashboardExpect'); const dashboardAddPanel = getService('dashboardAddPanel'); const PageObjects = getPageObjects(['common', 'dashboard', 'header', 'visualize', 'discover', 'timePicker']); + let visNames = []; const expectAllDataRenders = async () => { await pieChart.expectPieSliceCount(16); @@ -107,21 +108,23 @@ export default function ({ getService, getPageObjects }) { }); it('adding visualizations', async () => { - await dashboardAddPanel.addEveryVisualization('"Rendering Test"'); + visNames = await dashboardAddPanel.addEveryVisualization('"Rendering Test"'); + await dashboardExpect.visualizationsArePresent(visNames); // This one is rendered via svg which lets us do better testing of what is being rendered. - await dashboardAddPanel.addVisualization('Filter Bytes Test: vega'); - + visNames.push(await dashboardAddPanel.addVisualization('Filter Bytes Test: vega')); await PageObjects.header.waitUntilLoadingHasFinished(); - // await dashboardExpect.panelCount(27); + await dashboardExpect.visualizationsArePresent(visNames); + expect(visNames.length).to.be.equal(27); await PageObjects.dashboard.waitForRenderComplete(); }); it('adding saved searches', async () => { - await dashboardAddPanel.addEverySavedSearch('"Rendering Test"'); + const visAndSearchNames = visNames.concat(await dashboardAddPanel.addEverySavedSearch('"Rendering Test"')); await dashboardAddPanel.closeAddPanel(); await PageObjects.header.waitUntilLoadingHasFinished(); - // await dashboardExpect.panelCount(28); + await dashboardExpect.visualizationsArePresent(visAndSearchNames); + expect(visAndSearchNames.length).to.be.equal(28); await PageObjects.dashboard.waitForRenderComplete(); await PageObjects.dashboard.saveDashboard('embeddable rendering test', { storeTimeWithDashboard: true }); diff --git a/test/functional/page_objects/dashboard_page.js b/test/functional/page_objects/dashboard_page.js index 67e6ba0fe73fb..525f9f3e24b01 100644 --- a/test/functional/page_objects/dashboard_page.js +++ b/test/functional/page_objects/dashboard_page.js @@ -587,6 +587,18 @@ export function DashboardPageProvider({ getService, getPageObjects }) { return await testSubjects.click('dashboardPanelTitlesCheckbox'); } + async getNotLoadedVisualizations(vizList) { + const checkList = []; + for (const name of vizList) { + const isPresent = await testSubjects.exists( + `dashboardPanelHeading-${name.replace(/\s+/g, '')}`, + { timeout: 10000 } + ); + checkList.push({ name, isPresent }); + } + + return checkList.filter(viz => viz.isPresent === false).map(viz => viz.name); + } } return new DashboardPage(); diff --git a/test/functional/services/dashboard/add_panel.js b/test/functional/services/dashboard/add_panel.js index c8572125ac7c3..7f3cbf564ce94 100644 --- a/test/functional/services/dashboard/add_panel.js +++ b/test/functional/services/dashboard/add_panel.js @@ -52,33 +52,33 @@ export function DashboardAddPanelProvider({ getService, getPageObjects }) { log.debug('addEveryEmbeddableOnCurrentPage'); const itemList = await testSubjects.find('savedObjectFinderItemList'); const embeddableRows = await itemList.findAllByCssSelector('li'); + const embeddableList = []; for (let i = 0; i < embeddableRows.length; i++) { + embeddableList.push(await embeddableRows[i].getVisibleText()); await embeddableRows[i].click(); await PageObjects.common.closeToast(); } log.debug(`Added ${embeddableRows.length} embeddables`); + return embeddableList; } async clickPagerNextButton() { // Clear all toasts that could hide pagination controls await PageObjects.common.clearAllToasts(); - const addPanel = await testSubjects.find('dashboardAddPanel'); - const pagination = await addPanel.findAllByClassName('euiPagination'); - if (pagination.length === 0) { + const isNext = await testSubjects.exists('pagination-button-next'); + if (!isNext) { return false; } - const pagerNextButton = await pagination[0].findByCssSelector('button[aria-label="Next page"]'); - if (!pagerNextButton) { - return false; - } + const pagerNextButton = await testSubjects.find('pagination-button-next'); const isDisabled = await pagerNextButton.getAttribute('disabled'); if (isDisabled != null) { return false; } + await PageObjects.header.waitUntilLoadingHasFinished(); await pagerNextButton.click(); await PageObjects.header.waitUntilLoadingHasFinished(); return true; @@ -121,26 +121,30 @@ export function DashboardAddPanelProvider({ getService, getPageObjects }) { await this.filterEmbeddableNames(filter.replace('-', ' ')); } let morePages = true; + const vizList = []; while (morePages) { - await this.addEveryEmbeddableOnCurrentPage(); + vizList.push(await this.addEveryEmbeddableOnCurrentPage()); morePages = await this.clickPagerNextButton(); } await this.closeAddPanel(); + return vizList.reduce((acc, vizList) => [...acc, ...vizList], []); } async addEverySavedSearch(filter) { log.debug('DashboardAddPanel.addEverySavedSearch'); await this.ensureAddPanelIsShowing(); await this.toggleFilter('search'); + const searchList = []; if (filter) { await this.filterEmbeddableNames(filter.replace('-', ' ')); } let morePages = true; while (morePages) { - await this.addEveryEmbeddableOnCurrentPage(); + searchList.push(await this.addEveryEmbeddableOnCurrentPage()); morePages = await this.clickPagerNextButton(); } await this.closeAddPanel(); + return searchList.reduce((acc, searchList) => [...acc, ...searchList], []); } async addSavedSearch(searchName) { @@ -163,9 +167,12 @@ export function DashboardAddPanelProvider({ getService, getPageObjects }) { async addVisualizations(visualizations) { log.debug('DashboardAddPanel.addVisualizations'); + const vizList = []; for (const vizName of visualizations) { await this.addVisualization(vizName); + vizList.push(vizName); } + return vizList; } async addVisualization(vizName) { @@ -176,6 +183,7 @@ export function DashboardAddPanelProvider({ getService, getPageObjects }) { await testSubjects.click(`savedObjectTitle${vizName.split(' ').join('-')}`); await testSubjects.exists('addObjectToDashboardSuccess'); await this.closeAddPanel(); + return vizName; } async filterEmbeddableNames(name) { diff --git a/test/functional/services/dashboard/expectations.js b/test/functional/services/dashboard/expectations.js index 72b3bbf7e8847..e8f85251eefa9 100644 --- a/test/functional/services/dashboard/expectations.js +++ b/test/functional/services/dashboard/expectations.js @@ -37,6 +37,12 @@ export function DashboardExpectProvider({ getService, getPageObjects }) { }); } + async visualizationsArePresent(vizList) { + log.debug('Checking all visualisations are present on dashsboard'); + const notLoaded = await PageObjects.dashboard.getNotLoadedVisualizations(vizList); + expect(notLoaded).to.be.empty(); + } + async selectedLegendColorCount(color, expectedCount) { log.debug(`DashboardExpect.selectedLegendColorCount(${color}, ${expectedCount})`); await retry.try(async () => {