Skip to content

Commit

Permalink
Clean up duplicate func and fullTimeRange
Browse files Browse the repository at this point in the history
  • Loading branch information
qn895 committed Apr 28, 2023
1 parent 19f0096 commit 2f64036
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
discoverAdjustSuperDatePicker: true,
expected: {
continuousModeDateField: 'order_date',
fullTimeRange: {
start: 'Jun 12, 2019 @ 00:04:19.000',
end: 'Jul 12, 2019 @ 23:45:36.000',
},
pivotAdvancedEditorValueArr: ['{', ' "group_by": {', ' "category": {'],
pivotAdvancedEditorValue: {
group_by: {
Expand Down Expand Up @@ -216,10 +212,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
numFailureRetries: '101',
discoverAdjustSuperDatePicker: false,
expected: {
fullTimeRange: {
start: 'Jun 12, 2019 @ 00:04:19.000',
end: 'Jul 12, 2019 @ 23:45:36.000',
},
latestPreview: {
column: 0,
values: [],
Expand Down Expand Up @@ -478,17 +470,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('stops transform', async () => {
await transform.testExecution.logTestStep('should show the actions popover');
await transform.table.assertTransformRowActions(testData.transformId, true);
await transform.table.assertTransformRowActionEnabledState(
await transform.table.assertTransformRowActionEnabled(
testData.transformId,
'Reset',
false
);
await transform.table.assertTransformRowActionEnabledState(
await transform.table.assertTransformRowActionEnabled(
testData.transformId,
'Delete',
false
);

await transform.testExecution.logTestStep('should stop transform');
await transform.table.stopTransform(testData.transformId);
});

Expand All @@ -505,24 +498,30 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

it('resets and starts previously stopped transform', async () => {
await transform.testExecution.logTestStep(
'navigates back to transform management list page'
'should navigate to transform management list page'
);
await transform.navigation.navigateTo();
await transform.management.assertTransformListPageExists();

await transform.testExecution.logTestStep('should show the actions popover');
await transform.testExecution.logTestStep(
'should show the actions popover for continuous transform'
);
await transform.table.assertTransformRowActions(testData.transformId, false);
await transform.table.assertTransformRowActionEnabledState(
await transform.table.assertTransformRowActionEnabled(
testData.transformId,
'Reset',
true
);
await transform.table.assertTransformRowActionEnabledState(
await transform.table.assertTransformRowActionEnabled(
testData.transformId,
'Start',
true
);

await transform.testExecution.logTestStep('should reset transform');
await transform.table.resetTransform(testData.transformId);

await transform.testExecution.logTestStep('should start previously stopped transform');
await transform.table.startTransform(testData.transformId);
});
});
Expand Down
28 changes: 4 additions & 24 deletions x-pack/test/functional/services/transform/transform_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,36 +354,18 @@ export function TransformTableProvider({ getService }: FtrProviderContext) {
await this.ensureTransformActionsMenuClosed();
}

public async assertTransformRowActionEnabledState(
transformId: string,
action: 'Clone' | 'Delete' | 'Discover' | 'Edit' | 'Reset' | 'Start' | 'Stop',
expectedEnabledState: boolean
) {
const actionDataTestSubj = 'transformAction' + action;
await this.ensureTransformActionsMenuOpen(transformId);

const isEnabled = await testSubjects.isEnabled(actionDataTestSubj);
expect(isEnabled).to.eql(
expectedEnabledState,
`Expected ${action} to be ${expectedEnabledState ? 'enabled' : 'disabled'} (got ${
isEnabled ? 'enabled' : 'disabled'
}`
);
}

public async resetTransform(transformId: string) {
await this.assertTransformRowFields(transformId, { status: 'stopped' });
await retry.tryForTime(5 * 1000, async () => {
await this.clickTransformRowAction(transformId, 'Reset');
await testSubjects.existOrFail('transformResetModal');
await testSubjects.clickWhenNotDisabled('confirmModalConfirmButton');
await this.confirmResetTransform();
await this.assertTransformRowFields(transformId, { status: 'stopped' });
});
}

public async stopTransform(transformId: string) {
await this.assertTransformRowFields(transformId, { status: 'started' });
await this.assertTransformRowActionEnabledState(transformId, 'Stop', true);
await this.assertTransformRowActionEnabled(transformId, 'Stop', true);
await retry.tryForTime(5 * 1000, async () => {
await this.clickTransformRowAction(transformId, 'Stop');
await this.assertTransformRowFields(transformId, { status: 'stopped' });
Expand All @@ -392,13 +374,11 @@ export function TransformTableProvider({ getService }: FtrProviderContext) {

public async startTransform(transformId: string) {
await this.assertTransformRowFields(transformId, { status: 'stopped' });
await this.assertTransformRowActionEnabledState(transformId, 'Start', true);
await this.assertTransformRowActionEnabled(transformId, 'Start', true);

await retry.tryForTime(5 * 1000, async () => {
await this.clickTransformRowAction(transformId, 'Start');
await testSubjects.existOrFail('transformStartModal');
await testSubjects.clickWhenNotDisabled('confirmModalConfirmButton');

await this.confirmStartTransform();
await this.assertTransformRowFields(transformId, { status: 'started' });
});
}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/functional/services/transform/wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ export function TransformWizardProvider({ getService, getPageObjects }: FtrProvi
},

// For continuous transform, no need to assert progress bar exists
async startTransform({ expectProgressbarExists = true }) {
async startTransform({ expectProgressbarExists } = { expectProgressbarExists: true }) {
await testSubjects.click('transformWizardStartButton');
await retry.tryForTime(5000, async () => {
await this.assertDiscoverCardExists();
Expand Down

0 comments on commit 2f64036

Please sign in to comment.