Skip to content

Commit

Permalink
Use clearCharByChar option for input fields
Browse files Browse the repository at this point in the history
  • Loading branch information
pheyos committed Dec 5, 2019
1 parent a9ad526 commit e412d7b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 2 deletions.
9 changes: 7 additions & 2 deletions test/functional/services/test_subjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ interface ExistsOptions {

interface SetValueOptions {
clearWithKeyboard?: boolean;
clearCharByChar?: boolean;
typeCharByChar?: boolean;
}

Expand Down Expand Up @@ -183,15 +184,19 @@ export function TestSubjectsProvider({ getService }: FtrProviderContext) {
options: SetValueOptions = {}
): Promise<void> {
return await retry.try(async () => {
const { clearWithKeyboard = false, typeCharByChar = false } = options;
const {
clearWithKeyboard = false,
clearCharByChar = false,
typeCharByChar = false,
} = options;
log.debug(`TestSubjects.setValue(${selector}, ${text})`);
await this.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();
if (clearWithKeyboard === true) {
await input.clearValueWithKeyboard();
await input.clearValueWithKeyboard({ charByChar: clearCharByChar });
} else {
await input.clearValue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export function MachineLearningJobSourceSelectionProvider({ getService }: FtrPro
async filterSourceSelection(sourceName: string) {
await testSubjects.setValue('savedObjectFinderSearchInput', sourceName, {
clearWithKeyboard: true,
clearCharByChar: true,
typeCharByChar: true,
});
await this.assertSourceListContainsEntry(sourceName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export function MachineLearningJobWizardAdvancedProvider({
async setQueryDelay(queryDelay: string) {
await testSubjects.setValue('mlJobWizardInputQueryDelay', queryDelay, {
clearWithKeyboard: true,
clearCharByChar: true,
typeCharByChar: true,
});
await this.assertQueryDelayValue(queryDelay);
Expand All @@ -66,6 +67,7 @@ export function MachineLearningJobWizardAdvancedProvider({
async setFrequency(frequency: string) {
await testSubjects.setValue('mlJobWizardInputFrequency', frequency, {
clearWithKeyboard: true,
clearCharByChar: true,
typeCharByChar: true,
});
await this.assertFrequencyValue(frequency);
Expand All @@ -83,6 +85,7 @@ export function MachineLearningJobWizardAdvancedProvider({
async setScrollSize(scrollSize: string) {
await testSubjects.setValue('mlJobWizardInputScrollSize', scrollSize, {
clearWithKeyboard: true,
clearCharByChar: true,
typeCharByChar: true,
});
await this.assertScrollSizeValue(scrollSize);
Expand Down Expand Up @@ -262,6 +265,7 @@ export function MachineLearningJobWizardAdvancedProvider({
async setDetectorDescription(description: string) {
await testSubjects.setValue('mlAdvancedDetectorDescriptionInput', description, {
clearWithKeyboard: true,
clearCharByChar: true,
typeCharByChar: true,
});
await this.assertDetectorDescriptionValue(description);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export function MachineLearningJobWizardCommonProvider({ getService }: FtrProvid
async setBucketSpan(bucketSpan: string) {
await testSubjects.setValue('mlJobWizardInputBucketSpan', bucketSpan, {
clearWithKeyboard: true,
clearCharByChar: true,
typeCharByChar: true,
});
await this.assertBucketSpanValue(bucketSpan);
Expand All @@ -127,6 +128,7 @@ export function MachineLearningJobWizardCommonProvider({ getService }: FtrProvid
async setJobId(jobId: string) {
await testSubjects.setValue('mlJobWizardInputJobId', jobId, {
clearWithKeyboard: true,
clearCharByChar: true,
typeCharByChar: true,
});
await this.assertJobIdValue(jobId);
Expand All @@ -146,6 +148,7 @@ export function MachineLearningJobWizardCommonProvider({ getService }: FtrProvid
async setJobDescription(jobDescription: string) {
await testSubjects.setValue('mlJobWizardInputJobDescription', jobDescription, {
clearWithKeyboard: true,
clearCharByChar: true,
typeCharByChar: true,
});
await this.assertJobDescriptionValue(jobDescription);
Expand Down Expand Up @@ -291,6 +294,7 @@ export function MachineLearningJobWizardCommonProvider({ getService }: FtrProvid
}
await testSubjects.setValue(subj, modelMemoryLimit, {
clearWithKeyboard: true,
clearCharByChar: true,
typeCharByChar: true,
});
await this.assertModelMemoryLimitValue(modelMemoryLimit, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function TransformSourceSelectionProvider({ getService }: FtrProviderCont
async filterSourceSelection(sourceName: string) {
await testSubjects.setValue('savedObjectFinderSearchInput', sourceName, {
clearWithKeyboard: true,
clearCharByChar: true,
typeCharByChar: true,
});
await this.assertSourceListContainsEntry(sourceName);
Expand Down
3 changes: 3 additions & 0 deletions x-pack/test/functional/services/transform_ui/wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ export function TransformWizardProvider({ getService }: FtrProviderContext) {
async setTransformId(transformId: string) {
await testSubjects.setValue('transformIdInput', transformId, {
clearWithKeyboard: true,
clearCharByChar: true,
typeCharByChar: true,
});
await this.assertTransformIdValue(transformId);
Expand All @@ -325,6 +326,7 @@ export function TransformWizardProvider({ getService }: FtrProviderContext) {
async setTransformDescription(transformDescription: string) {
await testSubjects.setValue('transformDescriptionInput', transformDescription, {
clearWithKeyboard: true,
clearCharByChar: true,
typeCharByChar: true,
});
await this.assertTransformDescriptionValue(transformDescription);
Expand All @@ -348,6 +350,7 @@ export function TransformWizardProvider({ getService }: FtrProviderContext) {
async setDestinationIndex(destinationIndex: string) {
await testSubjects.setValue('transformDestinationIndexInput', destinationIndex, {
clearWithKeyboard: true,
clearCharByChar: true,
typeCharByChar: true,
});
await this.assertDestinationIndexValue(destinationIndex);
Expand Down

0 comments on commit e412d7b

Please sign in to comment.