Skip to content

Commit

Permalink
[7.5] [ftr/visualize] continue to wait for save completion by… (elast…
Browse files Browse the repository at this point in the history
…ic#52113)

* [ftr/visualize] continue to wait for save completion by default

* capture the toast message when saving the visualization so that it can be inspected if desired

* fix/flaky visualize listing tests (#33)

* move waitForSaveModalToClose from dashboard_page to common_page

* call common_page.waitForSaveModalToClose()

* remove extra wait for toast

* fix trailing spaces

* improve error message of failing test
  • Loading branch information
Spencer authored Dec 3, 2019
1 parent 4bec3c0 commit 736cc12
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 33 deletions.
2 changes: 0 additions & 2 deletions test/functional/apps/visualize/_area_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export default function ({ getService, getPageObjects }) {
it('should save and load with special characters', async function () {
const vizNamewithSpecialChars = vizName1 + '/?&=%';
await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizNamewithSpecialChars);
await PageObjects.visualize.waitForVisualizationSavedToastGone();
});

it('should save and load with non-ascii characters', async function () {
Expand All @@ -69,7 +68,6 @@ export default function ({ getService, getPageObjects }) {

it('should save and load', async function () {
await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1);
await PageObjects.visualize.waitForVisualizationSavedToastGone();
await PageObjects.visualize.loadSavedVisualization(vizName1);
await PageObjects.visualize.waitForVisualization();
});
Expand Down
4 changes: 2 additions & 2 deletions test/functional/apps/visualize/_data_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default function ({ getService, getPageObjects }) {

it('should be able to save and load', async function () {
await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1);
await PageObjects.visualize.waitForVisualizationSavedToastGone();

await PageObjects.visualize.loadSavedVisualization(vizName1);
await PageObjects.visualize.waitForVisualization();
});
Expand Down Expand Up @@ -129,7 +129,7 @@ export default function ({ getService, getPageObjects }) {
// check that it works after a save and reload
const SAVE_NAME = 'viz w/ percents';
await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(SAVE_NAME);
await PageObjects.visualize.waitForVisualizationSavedToastGone();

await PageObjects.visualize.loadSavedVisualization(SAVE_NAME);
await PageObjects.visualize.waitForVisualization();

Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/visualize/_data_table_nontimeindex.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default function ({ getService, getPageObjects }) {

it('should be able to save and load', async function () {
await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1);
await PageObjects.visualize.waitForVisualizationSavedToastGone();

await PageObjects.visualize.loadSavedVisualization(vizName1);
await PageObjects.visualize.waitForVisualization();
});
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/visualize/_heatmap_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function ({ getService, getPageObjects }) {

it('should save and load', async function () {
await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1);
await PageObjects.visualize.waitForVisualizationSavedToastGone();

await PageObjects.visualize.loadSavedVisualization(vizName1);
await PageObjects.visualize.waitForVisualization();
});
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/visualize/_line_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export default function ({ getService, getPageObjects }) {

it('should be able to save and load', async function () {
await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1);
await PageObjects.visualize.waitForVisualizationSavedToastGone();

await PageObjects.visualize.loadSavedVisualization(vizName1);
await PageObjects.visualize.waitForVisualization();
});
Expand Down
4 changes: 2 additions & 2 deletions test/functional/apps/visualize/_pie_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function ({ getService, getPageObjects }) {

it('should save and load', async function () {
await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1);
await PageObjects.visualize.waitForVisualizationSavedToastGone();

await PageObjects.visualize.loadSavedVisualization(vizName1);
await PageObjects.visualize.waitForVisualization();
});
Expand Down Expand Up @@ -158,7 +158,7 @@ export default function ({ getService, getPageObjects }) {

it('should correctly save disabled agg', async () => {
await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1);
await PageObjects.visualize.waitForVisualizationSavedToastGone();

await PageObjects.visualize.loadSavedVisualization(vizName1);
await PageObjects.visualize.waitForRenderingCount();

Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/visualize/_tag_cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default function ({ getService, getPageObjects }) {

it('should save and load', async function () {
await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1);
await PageObjects.visualize.waitForVisualizationSavedToastGone();

await PageObjects.visualize.loadSavedVisualization(vizName1);
await PageObjects.visualize.waitForVisualization();
});
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/visualize/_vertical_bar_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function ({ getService, getPageObjects }) {

it('should save and load', async function () {
await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1);
await PageObjects.visualize.waitForVisualizationSavedToastGone();

await PageObjects.visualize.loadSavedVisualization(vizName1);
await PageObjects.visualize.waitForVisualization();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default function ({ getService, getPageObjects }) {

it('should save and load', async function () {
await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1);
await PageObjects.visualize.waitForVisualizationSavedToastGone();

await PageObjects.visualize.loadSavedVisualization(vizName1);
await PageObjects.visualize.waitForVisualization();
});
Expand Down
8 changes: 8 additions & 0 deletions test/functional/page_objects/common_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,14 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
});
return response.status !== 200;
}
async waitForSaveModalToClose() {
log.debug('Waiting for save modal to close');
await retry.try(async () => {
if (await testSubjects.exists('savedObjectSaveModal')) {
throw new Error('save modal still open');
}
});
}
}

return new CommonPage();
Expand Down
11 changes: 1 addition & 10 deletions test/functional/page_objects/dashboard_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,20 +326,11 @@ export function DashboardPageProvider({ getService, getPageObjects }) {
await testSubjects.existOrFail('saveDashboardSuccess');
const message = await PageObjects.common.closeToast();
await PageObjects.header.waitUntilLoadingHasFinished();
await this.waitForSaveModalToClose();
await PageObjects.common.waitForSaveModalToClose();

return message;
}

async waitForSaveModalToClose() {
log.debug('Waiting for dashboard save modal to close');
await retry.try(async () => {
if (await testSubjects.exists('savedObjectSaveModal')) {
throw new Error('dashboard save still open');
}
});
}

async deleteDashboard(dashboardName, dashboardId) {
await this.gotoDashboardLandingPage();
await this.searchForDashboardWithName(dashboardName);
Expand Down
20 changes: 12 additions & 8 deletions test/functional/page_objects/visualize_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -734,19 +734,23 @@ export function VisualizePageProvider({ getService, getPageObjects, updateBaseli
await testSubjects.click('saveAsNewCheckbox');
}
log.debug('Click Save Visualization button');

await testSubjects.click('confirmSaveSavedObjectButton');

// if we wait for this, the success toast message could be gone :-()
// wait for save to complete before completion
// await PageObjects.header.waitUntilLoadingHasFinished();
// Confirm that the Visualization has actually been saved
await testSubjects.existOrFail('saveVisualizationSuccess');
const message = await PageObjects.common.closeToast();
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.common.waitForSaveModalToClose();

return message;
}

async saveVisualizationExpectSuccess(vizName, { saveAsNew = false } = {}) {
await this.saveVisualization(vizName, { saveAsNew });
const successToast = await testSubjects.exists('saveVisualizationSuccess', {
timeout: 2 * defaultFindTimeout
});
expect(successToast).to.be(true);
const saveMessage = await this.saveVisualization(vizName, { saveAsNew });
if (!saveMessage) {
throw new Error(`Expected saveVisualization to respond with the saveMessage from the toast, got ${saveMessage}`);
}
}

async saveVisualizationExpectSuccessAndBreadcrumb(vizName, { saveAsNew = false } = {}) {
Expand Down
8 changes: 5 additions & 3 deletions x-pack/test/functional/apps/graph/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ export default function({ getService, getPageObjects }: FtrProviderContext) {
const { nodes } = await PageObjects.graph.getGraphObjects();
const circlesText = nodes.map(({ label }) => label);
expect(circlesText.length).to.equal(expectedNodes.length);
circlesText.forEach(circleText => {
expect(expectedNodes.includes(circleText)).to.be(true);
});
const unexpectedCircleTexts = circlesText.filter(t => !expectedNodes.includes(t));

if (unexpectedCircleTexts.length) {
throw new Error(`Find unexpected circle texts: ${unexpectedCircleTexts}`);
}
});

it('should show correct connections', async function() {
Expand Down

0 comments on commit 736cc12

Please sign in to comment.