Skip to content

Commit

Permalink
Dashboard embeddable rendering tests: return names of failed visualis…
Browse files Browse the repository at this point in the history
…ations (#32646)
  • Loading branch information
dmlemeshko authored Mar 18, 2019
1 parent 71b1123 commit 5707690
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 15 deletions.
15 changes: 9 additions & 6 deletions test/functional/apps/dashboard/embeddable_rendering.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 });
Expand Down
12 changes: 12 additions & 0 deletions test/functional/page_objects/dashboard_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
26 changes: 17 additions & 9 deletions test/functional/services/dashboard/add_panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions test/functional/services/dashboard/expectations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit 5707690

Please sign in to comment.