[ML] Fix flaky setValue for some elements (#46693) (#46806)

Use setValue with clearing via keyboard
This commit is contained in:
Robert Oskamp 2019-09-27 21:41:45 +02:00 committed by GitHub
parent 804fb86fef
commit ceaa6d9102
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 8 deletions

View file

@ -27,6 +27,10 @@ interface ExistsOptions {
allowHidden?: boolean;
}
interface ClearOptions {
withKeyboard: boolean;
}
export function TestSubjectsProvider({ getService }: FtrProviderContext) {
const log = getService('log');
const retry = getService('retry');
@ -151,7 +155,11 @@ export function TestSubjectsProvider({ getService }: FtrProviderContext) {
});
}
public async setValue(selector: string, text: string): Promise<void> {
public async setValue(
selector: string,
text: string,
options: ClearOptions = { withKeyboard: false }
): Promise<void> {
return await retry.try(async () => {
log.debug(`TestSubjects.setValue(${selector}, ${text})`);
await this.click(selector);
@ -159,7 +167,11 @@ export function TestSubjectsProvider({ getService }: FtrProviderContext) {
// call clearValue() and type() on the element that is focused after
// clicking on the testSubject
const input = await find.activeElement();
await input.clearValue();
if (options.withKeyboard === true) {
await input.clearValueWithKeyboard();
} else {
await input.clearValue();
}
await input.type(text);
});
}

View file

@ -6,8 +6,7 @@
import { FtrProviderContext } from '../../ftr_provider_context';
export default function({ loadTestFile }: FtrProviderContext) {
// FLAKY: https://github.com/elastic/kibana/issues/46674
describe.skip('machine learning', function() {
describe('machine learning', function() {
this.tags('ciGroup3');
loadTestFile(require.resolve('./feature_controls'));

View file

@ -181,15 +181,17 @@ export function MachineLearningJobWizardCommonProvider({ getService }: FtrProvid
},
async setBucketSpan(bucketSpan: string) {
await testSubjects.setValue('mlJobWizardInputBucketSpan', bucketSpan);
await testSubjects.setValue('mlJobWizardInputBucketSpan', bucketSpan, { withKeyboard: true });
},
async setJobId(jobId: string) {
await testSubjects.setValue('mlJobWizardInputJobId', jobId);
await testSubjects.setValue('mlJobWizardInputJobId', jobId, { withKeyboard: true });
},
async setJobDescription(jobDescription: string) {
await testSubjects.setValue('mlJobWizardInputJobDescription', jobDescription);
await testSubjects.setValue('mlJobWizardInputJobDescription', jobDescription, {
withKeyboard: true,
});
},
async addJobGroup(jobGroup: string) {
@ -216,7 +218,9 @@ export function MachineLearningJobWizardCommonProvider({ getService }: FtrProvid
},
async setModelMemoryLimit(modelMemoryLimit: string) {
await testSubjects.setValue('mlJobWizardInputModelMemoryLimit', modelMemoryLimit);
await testSubjects.setValue('mlJobWizardInputModelMemoryLimit', modelMemoryLimit, {
withKeyboard: true,
});
},
async createJobAndWaitForCompletion() {