Skip to content

Commit

Permalink
[pageObjects/visualize] combine common assertions into helper (#28945)
Browse files Browse the repository at this point in the history
While working on #28503 an update needs to be made to an assertion that is copy/pasted all over the place. To make the process simpler I've added a new helper that does the work in one place and allows updating once.
  • Loading branch information
Spencer authored Jan 18, 2019
1 parent 3d24d19 commit a861980
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 58 deletions.
15 changes: 3 additions & 12 deletions test/functional/apps/visualize/_area_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,17 @@ export default function ({ getService, getPageObjects }) {

it('should save and load with special characters', async function () {
const vizNamewithSpecialChars = vizName1 + '/?&=%';
await PageObjects.visualize.saveVisualizationExpectSuccess(vizNamewithSpecialChars);
const pageTitle = await PageObjects.common.getBreadcrumbPageTitle();
log.debug(`Save viz page title is ${pageTitle}`);
expect(pageTitle).to.contain(vizNamewithSpecialChars);
await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizNamewithSpecialChars);
await PageObjects.visualize.waitForVisualizationSavedToastGone();
});

it('should save and load with non-ascii characters', async function () {
const vizNamewithSpecialChars = `${vizName1} with Umlaut ä`;
await PageObjects.visualize.saveVisualizationExpectSuccess(vizNamewithSpecialChars);
const pageTitle = await PageObjects.common.getBreadcrumbPageTitle();
log.debug(`Saved viz page title with umlaut is ${pageTitle}`);
expect(pageTitle).to.contain(vizNamewithSpecialChars);
await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizNamewithSpecialChars);
});

it('should save and load', async function () {
await PageObjects.visualize.saveVisualizationExpectSuccess(vizName1);
const pageTitle = await PageObjects.common.getBreadcrumbPageTitle();
log.debug(`Saved viz page title is ${pageTitle}`);
expect(pageTitle).to.contain(vizName1);
await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1);
await PageObjects.visualize.waitForVisualizationSavedToastGone();
await PageObjects.visualize.loadSavedVisualization(vizName1);
await PageObjects.visualize.waitForVisualization();
Expand Down
5 changes: 1 addition & 4 deletions test/functional/apps/visualize/_data_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ export default function ({ getService, getPageObjects }) {
});

it('should be able to save and load', async function () {
await PageObjects.visualize.saveVisualizationExpectSuccess(vizName1);
const pageTitle = await PageObjects.common.getBreadcrumbPageTitle();
log.debug(`Save viz page title is ${pageTitle}`);
expect(pageTitle).to.contain(vizName1);
await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1);
await PageObjects.visualize.waitForVisualizationSavedToastGone();
await PageObjects.visualize.loadSavedVisualization(vizName1);
await PageObjects.visualize.waitForVisualization();
Expand Down
5 changes: 1 addition & 4 deletions test/functional/apps/visualize/_data_table_nontimeindex.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ export default function ({ getService, getPageObjects }) {
});

it('should be able to save and load', async function () {
await PageObjects.visualize.saveVisualizationExpectSuccess(vizName1);
const pageTitle = await PageObjects.common.getBreadcrumbPageTitle();
log.debug(`Save viz page title is ${pageTitle}`);
expect(pageTitle).to.contain(vizName1);
await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1);
await PageObjects.visualize.waitForVisualizationSavedToastGone();
await PageObjects.visualize.loadSavedVisualization(vizName1);
await PageObjects.visualize.waitForVisualization();
Expand Down
15 changes: 1 addition & 14 deletions test/functional/apps/visualize/_heatmap_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,7 @@ export default function ({ getService, getPageObjects }) {
});

it('should save and load', async function () {
await PageObjects.visualize.saveVisualizationExpectSuccess(vizName1);
const pageTitle = await PageObjects.common.getBreadcrumbPageTitle();
log.debug(`Save viz page title is ${pageTitle}`);
expect(pageTitle).to.contain(vizName1);
await PageObjects.visualize.waitForVisualizationSavedToastGone();
await PageObjects.visualize.loadSavedVisualization(vizName1);
await PageObjects.visualize.waitForVisualization();
});

it('should save and load', async function () {
await PageObjects.visualize.saveVisualizationExpectSuccess(vizName1);
const pageTitle = await PageObjects.common.getBreadcrumbPageTitle();
log.debug(`Save viz page title is ${pageTitle}`);
expect(pageTitle).to.contain(vizName1);
await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1);
await PageObjects.visualize.waitForVisualizationSavedToastGone();
await PageObjects.visualize.loadSavedVisualization(vizName1);
await PageObjects.header.waitUntilLoadingHasFinished();
Expand Down
5 changes: 1 addition & 4 deletions test/functional/apps/visualize/_line_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,7 @@ export default function ({ getService, getPageObjects }) {
});

it('should be able to save and load', async function () {
await PageObjects.visualize.saveVisualizationExpectSuccess(vizName1);
const pageTitle = await PageObjects.common.getBreadcrumbPageTitle();
log.debug(`Save viz page title is ${pageTitle}`);
expect(pageTitle).to.contain(vizName1);
await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1);
await PageObjects.visualize.waitForVisualizationSavedToastGone();
await PageObjects.visualize.loadSavedVisualization(vizName1);
await PageObjects.visualize.waitForVisualization();
Expand Down
10 changes: 2 additions & 8 deletions test/functional/apps/visualize/_pie_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ export default function ({ getService, getPageObjects }) {
});

it('should save and load', async function () {
await PageObjects.visualize.saveVisualizationExpectSuccess(vizName1);
const pageTitle = await PageObjects.common.getBreadcrumbPageTitle();
log.debug(`Save viz page title is ${pageTitle}`);
expect(pageTitle).to.contain(vizName1);
await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1);
await PageObjects.visualize.waitForVisualizationSavedToastGone();
await PageObjects.visualize.loadSavedVisualization(vizName1);
await PageObjects.visualize.waitForVisualization();
Expand Down Expand Up @@ -168,10 +165,7 @@ export default function ({ getService, getPageObjects }) {
});

it('should correctly save disabled agg', async () => {
await PageObjects.visualize.saveVisualizationExpectSuccess(vizName1);
const pageTitle = await PageObjects.common.getBreadcrumbPageTitle();
log.debug(`Save viz page title is ${pageTitle}`);
expect(pageTitle).to.contain(vizName1);
await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1);
await PageObjects.visualize.waitForVisualizationSavedToastGone();
await PageObjects.visualize.loadSavedVisualization(vizName1);
await PageObjects.visualize.waitForVisualization();
Expand Down
5 changes: 1 addition & 4 deletions test/functional/apps/visualize/_tag_cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,7 @@ export default function ({ getService, getPageObjects }) {
});

it('should save and load', async function () {
await PageObjects.visualize.saveVisualizationExpectSuccess(vizName1);
const pageTitle = await PageObjects.common.getBreadcrumbPageTitle();
log.debug(`Save viz page title is ${pageTitle}`);
expect(pageTitle).to.contain(vizName1);
await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1);
await PageObjects.visualize.waitForVisualizationSavedToastGone();
await PageObjects.visualize.loadSavedVisualization(vizName1);
await PageObjects.visualize.waitForVisualization();
Expand Down
5 changes: 1 addition & 4 deletions test/functional/apps/visualize/_vertical_bar_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ export default function ({ getService, getPageObjects }) {
before(initBarChart);

it('should save and load', async function () {
await PageObjects.visualize.saveVisualizationExpectSuccess(vizName1);
const pageTitle = await PageObjects.common.getBreadcrumbPageTitle();
log.debug(`Save viz page title is ${pageTitle}`);
expect(pageTitle).to.contain(vizName1);
await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1);
await PageObjects.visualize.waitForVisualizationSavedToastGone();
await PageObjects.visualize.loadSavedVisualization(vizName1);
await PageObjects.header.waitUntilLoadingHasFinished();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ export default function ({ getService, getPageObjects }) {
before(initBarChart);

it('should save and load', async function () {
await PageObjects.visualize.saveVisualizationExpectSuccess(vizName1);
const pageTitle = await PageObjects.common.getBreadcrumbPageTitle();
log.debug(`Save viz page title is ${pageTitle}`);
expect(pageTitle).to.contain(vizName1);
await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1);
await PageObjects.visualize.waitForVisualizationSavedToastGone();
await PageObjects.visualize.loadSavedVisualization(vizName1);
await PageObjects.header.waitUntilLoadingHasFinished();
Expand Down
7 changes: 7 additions & 0 deletions test/functional/page_objects/visualize_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,13 @@ export function VisualizePageProvider({ getService, getPageObjects }) {
expect(successToast).to.be(true);
}

async saveVisualizationExpectSuccessAndBreadcrumb(vizName, options) {
await this.saveVisualizationExpectSuccess(vizName, options);
const pageTitle = await PageObjects.common.getBreadcrumbPageTitle();
log.debug(`Save viz page title is ${pageTitle}`);
expect(pageTitle).to.contain(vizName);
}

async saveVisualizationExpectFail(vizName, { saveAsNew = false } = {}) {
await this.saveVisualization(vizName, { saveAsNew });
const errorToast = await testSubjects.exists('saveVisualizationError', {
Expand Down

0 comments on commit a861980

Please sign in to comment.