Skip to content

Commit

Permalink
[Dataset quality] Fix flaky test (elastic#181047)
Browse files Browse the repository at this point in the history
Fixes elastic#180994

## Summary

Fixes the flaky test by using better timeouts.
  • Loading branch information
awahab07 authored Apr 18, 2024
1 parent ae997d9 commit 584f1f7
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions test/functional/services/selectable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class SelectableService extends FtrService {
`selectableBodyTestSubjectId: ${selectableBodyTestSubjectId}, textsToSelect: ${textsToSelect}`
);

await this.openIfClosed(buttonTestSubjectId, selectableBodyTestSubjectId);
await this.ensureOpened(buttonTestSubjectId, selectableBodyTestSubjectId);

const selectableBodyContainer = await this.testSubjects.find(selectableBodyTestSubjectId);
const listContainer = await selectableBodyContainer.findByClassName('euiSelectableList');
Expand Down Expand Up @@ -92,7 +92,7 @@ export class SelectableService extends FtrService {
searchText: string,
optionText: string
) {
await this.openIfClosed(buttonTestSubjectId, selectableBodyTestSubjectId);
await this.ensureOpened(buttonTestSubjectId, selectableBodyTestSubjectId);

// Clear and set search text
await this.testSubjects.setValue(searchInputTestSubjectId, searchText, {
Expand All @@ -107,16 +107,15 @@ export class SelectableService extends FtrService {
]);
}

private async openIfClosed(buttonTestSubjectId: string, selectableBodyTestSubjectId: string) {
private async ensureOpened(buttonTestSubjectId: string, selectableBodyTestSubjectId: string) {
// Open the selectable if `selectableBodyTestSubjectId` doesn't exist
const isSelectableOpen = await this.testSubjects.exists(selectableBodyTestSubjectId, {
timeout: 500,
});
const isSelectableOpen = await this.testSubjects.exists(selectableBodyTestSubjectId);

if (!isSelectableOpen) {
await this.testSubjects.click(buttonTestSubjectId);
await this.common.sleep(500);
}

await this.testSubjects.existOrFail(selectableBodyTestSubjectId);
}
}

Expand Down

0 comments on commit 584f1f7

Please sign in to comment.