Skip to content

Commit f5064ba

Browse files
committed
[ML] Functional tests - stabilize typing with checks service method (#81338)
This PR stabilizes the ML specific setValueWithChecks service method by adding another check for the complete value.
1 parent b03d6c7 commit f5064ba

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

x-pack/test/functional/services/ml/common_ui.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export function MachineLearningCommonUIProvider({ getService }: FtrProviderConte
3535
// clicking on the testSubject
3636
const input = await find.activeElement();
3737

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

57+
// make sure that typing a character really adds that character to the input value
5658
for (const chr of text) {
5759
await retry.tryForTime(5000, async () => {
5860
const oldValue = await input.getAttribute('value');
@@ -70,6 +72,16 @@ export function MachineLearningCommonUIProvider({ getService }: FtrProviderConte
7072
});
7173
});
7274
}
75+
76+
// make sure that finally the complete text is entered
77+
// this is needed because sometimes the field value is reset while typing
78+
// and the above character checking might not catch it due to bad timing
79+
const currentValue = await input.getAttribute('value');
80+
if (currentValue !== text) {
81+
throw new Error(
82+
`Expected input '${selector}' to have the value '${text}' (got ${currentValue})`
83+
);
84+
}
7385
});
7486
},
7587

0 commit comments

Comments
 (0)