Skip to content

Commit

Permalink
Another attempt to fix the test
Browse files Browse the repository at this point in the history
  • Loading branch information
kertal committed Aug 16, 2021
1 parent 20ae71e commit 612b76d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion test/functional/apps/discover/_data_grid_doc_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/discover/_doc_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)');
Expand Down
19 changes: 14 additions & 5 deletions test/functional/page_objects/discover_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit 612b76d

Please sign in to comment.