Skip to content

Commit

Permalink
[ML] Functional tests - stabilize typing with checks service method (e…
Browse files Browse the repository at this point in the history
…lastic#81338)

This PR stabilizes the ML specific setValueWithChecks service method by adding another check for the complete value.
  • Loading branch information
pheyos committed Oct 22, 2020
1 parent b03d6c7 commit f5064ba
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 f5064ba

Please sign in to comment.