From 612b76dc2ae633823c7bdfeb73d53bf2b90a8944 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 16 Aug 2021 11:41:51 +0200 Subject: [PATCH] Another attempt to fix the test --- .../apps/discover/_data_grid_doc_table.ts | 2 +- test/functional/apps/discover/_doc_table.ts | 2 +- test/functional/page_objects/discover_page.ts | 19 ++++++++++++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/test/functional/apps/discover/_data_grid_doc_table.ts b/test/functional/apps/discover/_data_grid_doc_table.ts index 00e6a5025e2af..2efb1ba51811f 100644 --- a/test/functional/apps/discover/_data_grid_doc_table.ts +++ b/test/functional/apps/discover/_data_grid_doc_table.ts @@ -161,7 +161,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.header.waitUntilLoadingHasFinished(); } // remove the second column - await PageObjects.discover.clickFieldListItemAdd(extraColumns[1]); + await PageObjects.discover.clickFieldListItemRemove(extraColumns[1]); await PageObjects.header.waitUntilLoadingHasFinished(); // test that the second column is no longer there const header = await dataGrid.getHeaderFields(); diff --git a/test/functional/apps/discover/_doc_table.ts b/test/functional/apps/discover/_doc_table.ts index 09a162e051bf6..f01d6b18fbf01 100644 --- a/test/functional/apps/discover/_doc_table.ts +++ b/test/functional/apps/discover/_doc_table.ts @@ -218,7 +218,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.header.waitUntilLoadingHasFinished(); } // remove the second column - await PageObjects.discover.clickFieldListItemAdd(extraColumns[1]); + await PageObjects.discover.clickFieldListItemRemove(extraColumns[1]); await PageObjects.header.waitUntilLoadingHasFinished(); // test that the second column is no longer there const docHeader = await find.byCssSelector('thead > tr:nth-child(1)'); diff --git a/test/functional/page_objects/discover_page.ts b/test/functional/page_objects/discover_page.ts index c6a87bb99deac..9ce54c86ee229 100644 --- a/test/functional/page_objects/discover_page.ts +++ b/test/functional/page_objects/discover_page.ts @@ -353,6 +353,9 @@ export class DiscoverPageObject extends FtrService { public async clickFieldListItemAdd(field: string) { // a filter check may make sense here, but it should be properly handled to make // it work with the _score and _source fields as well + if (await this.isFieldSelected(field)) { + return; + } await this.clickFieldListItemToggle(field); const isLegacyDefault = await this.useLegacyTable(); if (isLegacyDefault) { @@ -366,14 +369,20 @@ export class DiscoverPageObject extends FtrService { } } + public async isFieldSelected(field: string) { + const selectedList = await this.testSubjects.find('fieldList-selected'); + return await this.testSubjects.descendantExists(`field-${field}`, selectedList); + } + public async clickFieldListItemRemove(field: string) { - if (!(await this.testSubjects.exists('fieldList-selected'))) { + if ( + !(await this.testSubjects.exists('fieldList-selected')) || + !(await this.isFieldSelected(field)) + ) { return; } - const selectedList = await this.testSubjects.find('fieldList-selected'); - if (await this.testSubjects.descendantExists(`field-${field}`, selectedList)) { - await this.clickFieldListItemToggle(field); - } + + await this.clickFieldListItemToggle(field); } public async clickFieldListItemVisualize(fieldName: string) {