-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ML] Functional tests - fix typing issue #52167
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2fbccc5
Use char by char typing in all text fields
pheyos d27ad1d
Add dely before first typed charakter when typing char by char
pheyos a9ad526
Remove delay before typing again
pheyos e412d7b
Use clearCharByChar option for input fields
pheyos d746a35
Merge branch 'master' into fix_typing
pheyos 43e9956
Revert "Use clearCharByChar option for input fields"
pheyos 5db2092
Merge branch 'master' into fix_typing
pheyos d72f81e
Revert "Use char by char typing in all text fields"
pheyos e178fd8
Disable jobCreatorUpdate for tests
pheyos 49471bd
Revert "Disable jobCreatorUpdate for tests"
pheyos eb90bff
Check typing char by char for job wizard inputs
pheyos 0c759a9
Merge branch 'master' into fix_typing
pheyos a2806d1
Remove .only from anomaly detection suite
pheyos a11a340
Move setValueWithChecks from testSubjects to a ML service
pheyos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future, I usually like to export this type from the module containing the provider so I can just import the
MlCommon
type without having to use these long types everywhere.in common.ts
in here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! I've created a PR for this: #52612