-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] Functional tests - fix typing issue (#52167)
* Use char by char typing in all text fields * Add dely before first typed charakter when typing char by char * Remove delay before typing again * Use clearCharByChar option for input fields * Revert "Use clearCharByChar option for input fields" This reverts commit e412d7b. * Revert "Use char by char typing in all text fields" This reverts commit 2fbccc5. * Disable jobCreatorUpdate for tests * Revert "Disable jobCreatorUpdate for tests" This reverts commit e178fd8. * Check typing char by char for job wizard inputs * Remove .only from anomaly detection suite * Move setValueWithChecks from testSubjects to a ML service
- Loading branch information
Showing
5 changed files
with
97 additions
and
11 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
x-pack/test/functional/services/machine_learning/common.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { FtrProviderContext } from '../../ftr_provider_context'; | ||
|
||
interface SetValueOptions { | ||
clearWithKeyboard?: boolean; | ||
typeCharByChar?: boolean; | ||
} | ||
|
||
export function MachineLearningCommonProvider({ getService }: FtrProviderContext) { | ||
const log = getService('log'); | ||
const retry = getService('retry'); | ||
const testSubjects = getService('testSubjects'); | ||
const find = getService('find'); | ||
|
||
return { | ||
async setValueWithChecks( | ||
selector: string, | ||
text: string, | ||
options: SetValueOptions = {} | ||
): Promise<void> { | ||
return await retry.try(async () => { | ||
const { clearWithKeyboard = false, typeCharByChar = false } = options; | ||
log.debug(`TestSubjects.setValueWithChecks(${selector}, ${text})`); | ||
await testSubjects.click(selector); | ||
// in case the input element is actually a child of the testSubject, we | ||
// call clearValue() and type() on the element that is focused after | ||
// clicking on the testSubject | ||
const input = await find.activeElement(); | ||
|
||
await retry.tryForTime(5000, async () => { | ||
let currentValue = await input.getAttribute('value'); | ||
if (currentValue !== '') { | ||
if (clearWithKeyboard === true) { | ||
await input.clearValueWithKeyboard(); | ||
} else { | ||
await input.clearValue(); | ||
} | ||
currentValue = await input.getAttribute('value'); | ||
} | ||
|
||
if (currentValue === '') { | ||
return true; | ||
} else { | ||
throw new Error(`Expected input to be empty, but got value '${currentValue}'`); | ||
} | ||
}); | ||
|
||
for (const chr of text) { | ||
await retry.tryForTime(5000, async () => { | ||
const oldValue = await input.getAttribute('value'); | ||
await input.type(chr, { charByChar: typeCharByChar }); | ||
|
||
await retry.tryForTime(1000, async () => { | ||
const newValue = await input.getAttribute('value'); | ||
if (newValue === `${oldValue}${chr}`) { | ||
return true; | ||
} else { | ||
throw new Error( | ||
`After typing character '${chr}', the new value in the input should be '${oldValue}${chr}' (got ${newValue})` | ||
); | ||
} | ||
}); | ||
}); | ||
} | ||
}); | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters