Skip to content

Commit

Permalink
fix functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
walterra committed Nov 24, 2023
1 parent ee56458 commit 7b17044
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await transform.wizard.assertTransformDescriptionValue('');
await transform.wizard.setTransformDescription(testData.transformDescription);

await transform.testExecution.logTestStep('inputs the destination index');
await transform.testExecution.logTestStep(
'should default the set destination index to job id switch to true'
);
await transform.wizard.assertDestIndexSameAsIdSwitchExists();
await transform.wizard.assertDestIndexSameAsIdCheckState(true);

await transform.testExecution.logTestStep('should input the destination index');
await transform.wizard.setDestIndexSameAsIdCheckState(false);
await transform.wizard.assertDestinationIndexInputExists();
await transform.wizard.assertDestinationIndexValue('');
await transform.wizard.assertDestinationIndexValue(testData.transformId);
await transform.wizard.setDestinationIndex(testData.destinationIndex);

await transform.testExecution.logTestStep('displays the create data view switch');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -727,9 +727,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await transform.wizard.assertTransformDescriptionValue('');
await transform.wizard.setTransformDescription(testData.transformDescription);

await transform.testExecution.logTestStep('inputs the destination index');
await transform.testExecution.logTestStep(
'should default the set destination index to job id switch to true'
);
await transform.wizard.assertDestIndexSameAsIdSwitchExists();
await transform.wizard.assertDestIndexSameAsIdCheckState(true);

await transform.testExecution.logTestStep('should input the destination index');
await transform.wizard.setDestIndexSameAsIdCheckState(false);
await transform.wizard.assertDestinationIndexInputExists();
await transform.wizard.assertDestinationIndexValue('');
await transform.wizard.assertDestinationIndexValue(testData.transformId);
await transform.wizard.setDestinationIndex(testData.destinationIndex);

await transform.testExecution.logTestStep('displays the create data view switch');
Expand Down
9 changes: 8 additions & 1 deletion x-pack/test/functional/apps/transform/edit_clone/cloning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -517,9 +517,16 @@ export default function ({ getService }: FtrProviderContext) {
);
await transform.wizard.setTransformDescription(testData.transformDescription);

await transform.testExecution.logTestStep(
'should default the set destination index to job id switch to true'
);
await transform.wizard.assertDestIndexSameAsIdSwitchExists();
await transform.wizard.assertDestIndexSameAsIdCheckState(true);

await transform.testExecution.logTestStep('should input the destination index');
await transform.wizard.setDestIndexSameAsIdCheckState(false);
await transform.wizard.assertDestinationIndexInputExists();
await transform.wizard.assertDestinationIndexValue('');
await transform.wizard.assertDestinationIndexValue(testData.transformId);
await transform.wizard.setDestinationIndex(testData.destinationIndex);

await transform.testExecution.logTestStep('should display the create data view switch');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,13 @@ export function MachineLearningDataFrameAnalyticsCreationProvider(

async assertDestIndexInputExists() {
await retry.tryForTime(4000, async () => {
await testSubjects.existOrFail('mlAnalyticsCreateJobFlyoutDestinationIndexInput');
await testSubjects.existOrFail('mlCreationWizardUtilsDestinationIndexInput');
});
},

async assertDestIndexValue(expectedValue: string) {
const actualDestIndex = await testSubjects.getAttribute(
'mlAnalyticsCreateJobFlyoutDestinationIndexInput',
'mlCreationWizardUtilsDestinationIndexInput',
'value'
);
expect(actualDestIndex).to.eql(
Expand All @@ -275,13 +275,9 @@ export function MachineLearningDataFrameAnalyticsCreationProvider(
},

async setDestIndex(destIndex: string) {
await mlCommonUI.setValueWithChecks(
'mlAnalyticsCreateJobFlyoutDestinationIndexInput',
destIndex,
{
clearWithKeyboard: true,
}
);
await mlCommonUI.setValueWithChecks('mlCreationWizardUtilsDestinationIndexInput', destIndex, {
clearWithKeyboard: true,
});
await this.assertDestIndexValue(destIndex);
},

Expand Down Expand Up @@ -656,7 +652,7 @@ export function MachineLearningDataFrameAnalyticsCreationProvider(

async getDestIndexSameAsIdSwitchCheckState(): Promise<boolean> {
const state = await testSubjects.getAttribute(
'mlAnalyticsCreateJobWizardDestIndexSameAsIdSwitch',
'mlCreationWizardUtilsJobIdAsDestIndexNameSwitch',
'aria-checked'
);
return state === 'true';
Expand All @@ -671,14 +667,14 @@ export function MachineLearningDataFrameAnalyticsCreationProvider(
},

async assertDestIndexSameAsIdSwitchExists() {
await testSubjects.existOrFail(`mlAnalyticsCreateJobWizardDestIndexSameAsIdSwitch`, {
await testSubjects.existOrFail(`mlCreationWizardUtilsJobIdAsDestIndexNameSwitch`, {
allowHidden: true,
});
},

async setDestIndexSameAsIdCheckState(checkState: boolean) {
if ((await this.getDestIndexSameAsIdSwitchCheckState()) !== checkState) {
await testSubjects.click('mlAnalyticsCreateJobWizardDestIndexSameAsIdSwitch');
await testSubjects.click('mlCreationWizardUtilsJobIdAsDestIndexNameSwitch');
}
await this.assertDestIndexSameAsIdCheckState(checkState);
},
Expand Down
43 changes: 38 additions & 5 deletions x-pack/test/functional/services/transform/wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -700,13 +700,42 @@ export function TransformWizardProvider({ getService, getPageObjects }: FtrProvi
await this.assertTransformDescriptionValue(transformDescription);
},

async getDestIndexSameAsIdSwitchCheckState(): Promise<boolean> {
const state = await testSubjects.getAttribute(
'mlCreationWizardUtilsJobIdAsDestIndexNameSwitch',
'aria-checked'
);
return state === 'true';
},

async assertDestIndexSameAsIdCheckState(expectedCheckState: boolean) {
const actualCheckState = await this.getDestIndexSameAsIdSwitchCheckState();
expect(actualCheckState).to.eql(
expectedCheckState,
`Destination index same as job id check state should be '${expectedCheckState}' (got '${actualCheckState}')`
);
},

async assertDestIndexSameAsIdSwitchExists() {
await testSubjects.existOrFail(`mlCreationWizardUtilsJobIdAsDestIndexNameSwitch`, {
allowHidden: true,
});
},

async setDestIndexSameAsIdCheckState(checkState: boolean) {
if ((await this.getDestIndexSameAsIdSwitchCheckState()) !== checkState) {
await testSubjects.click('mlCreationWizardUtilsJobIdAsDestIndexNameSwitch');
}
await this.assertDestIndexSameAsIdCheckState(checkState);
},

async assertDestinationIndexInputExists() {
await testSubjects.existOrFail('transformDestinationIndexInput');
await testSubjects.existOrFail('mlCreationWizardUtilsDestinationIndexInput');
},

async assertDestinationIndexValue(expectedValue: string) {
const actualDestinationIndex = await testSubjects.getAttribute(
'transformDestinationIndexInput',
'mlCreationWizardUtilsDestinationIndexInput',
'value'
);
expect(actualDestinationIndex).to.eql(
Expand All @@ -716,9 +745,13 @@ export function TransformWizardProvider({ getService, getPageObjects }: FtrProvi
},

async setDestinationIndex(destinationIndex: string) {
await ml.commonUI.setValueWithChecks('transformDestinationIndexInput', destinationIndex, {
clearWithKeyboard: true,
});
await ml.commonUI.setValueWithChecks(
'mlCreationWizardUtilsDestinationIndexInput',
destinationIndex,
{
clearWithKeyboard: true,
}
);
await this.assertDestinationIndexValue(destinationIndex);
},

Expand Down

0 comments on commit 7b17044

Please sign in to comment.