Skip to content

Commit

Permalink
[ML] Functional tests - stabilize typing with checks service method
Browse files Browse the repository at this point in the history
  • Loading branch information
pheyos committed Oct 21, 2020
1 parent ab8bf78 commit 4078cfa
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions x-pack/test/functional/services/ml/common_ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export function MachineLearningCommonUIProvider({ getService }: FtrProviderConte
// clicking on the testSubject
const input = await find.activeElement();

// make sure that clearing the element's value works
await retry.tryForTime(5000, async () => {
let currentValue = await input.getAttribute('value');
if (currentValue !== '') {
Expand All @@ -53,6 +54,7 @@ export function MachineLearningCommonUIProvider({ getService }: FtrProviderConte
}
});

// make sure that typing a character really adds that character to the input value
for (const chr of text) {
await retry.tryForTime(5000, async () => {
const oldValue = await input.getAttribute('value');
Expand All @@ -70,6 +72,16 @@ export function MachineLearningCommonUIProvider({ getService }: FtrProviderConte
});
});
}

// make sure that finally the complete text is entered
// this is needed because sometimes the field value is reset while typing
// and the above character checking might not catch it due to bad timing
const currentValue = await input.getAttribute('value');
if (currentValue !== text) {
throw new Error(
`Expected input '${selector}' to have the value '${text}' (got ${currentValue})`
);
}
});
},

Expand Down

0 comments on commit 4078cfa

Please sign in to comment.