Skip to content

Commit

Permalink
[ML] Stabilize tests that open the actions menu
Browse files Browse the repository at this point in the history
  • Loading branch information
peteharverson committed Jul 27, 2021
1 parent b0c8e46 commit bf97c80
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 26 deletions.
2 changes: 1 addition & 1 deletion x-pack/test/functional/apps/transform/cloning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export default function ({ getService }: FtrProviderContext) {
await transform.table.assertTransformRowActions(testData.originalConfig.id, false);

await transform.testExecution.logTestStep('should display the define pivot step');
await transform.table.clickTransformRowAction('Clone');
await transform.table.clickTransformRowAction(testData.originalConfig.id, 'Clone');
await transform.wizard.assertSelectedTransformFunction(testData.type);
await transform.wizard.assertDefineStepActive();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ export default function ({ getService }: FtrProviderContext) {
await transform.table.assertTransformRowActions(testData.transformId, false);

await transform.testExecution.logTestStep('should navigate to discover');
await transform.table.clickTransformRowAction('Discover');
await transform.table.clickTransformRowAction(testData.transformId, 'Discover');

if (testData.discoverAdjustSuperDatePicker) {
await transform.discover.assertNoResults(testData.destinationIndex);
Expand Down
4 changes: 2 additions & 2 deletions x-pack/test/functional/apps/transform/deleting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default function ({ getService }: FtrProviderContext) {
);

await transform.testExecution.logTestStep('should stop the transform');
await transform.table.clickTransformRowAction('Stop');
await transform.table.clickTransformRowAction(testData.originalConfig.id, 'Stop');
}

await transform.testExecution.logTestStep('should display the stopped transform');
Expand All @@ -117,7 +117,7 @@ export default function ({ getService }: FtrProviderContext) {
'Delete',
true
);
await transform.table.clickTransformRowAction('Delete');
await transform.table.clickTransformRowAction(testData.originalConfig.id, 'Delete');
await transform.table.assertTransformDeleteModalExists();

await transform.testExecution.logTestStep('should delete the transform');
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/functional/apps/transform/editing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default function ({ getService }: FtrProviderContext) {
await transform.table.assertTransformRowActions(testData.originalConfig.id, false);

await transform.testExecution.logTestStep('should show the edit flyout');
await transform.table.clickTransformRowAction('Edit');
await transform.table.clickTransformRowAction(testData.originalConfig.id, 'Edit');
await transform.editFlyout.assertTransformEditFlyoutExists();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export default function ({ getService }: FtrProviderContext) {

it('should display controls in the edit flyout correctly', async () => {
await transform.testExecution.logTestStep('should show the edit flyout');
await transform.table.clickTransformRowActionWithRetry(transformConfigWithPivot.id, 'Edit');
await transform.table.clickTransformRowAction(transformConfigWithPivot.id, 'Edit');
await transform.editFlyout.assertTransformEditFlyoutExists();

await transform.testExecution.logTestStep('should have the description input enabled');
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/functional/apps/transform/starting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default function ({ getService }: FtrProviderContext) {

await transform.testExecution.logTestStep('should start the transform');
await transform.table.assertTransformRowActionEnabled(transformId, 'Start', true);
await transform.table.clickTransformRowAction('Start');
await transform.table.clickTransformRowAction(transformId, 'Start');
await transform.table.confirmStartTransform();
await transform.table.clearSearchString(testDataList.length);

Expand Down
52 changes: 33 additions & 19 deletions x-pack/test/functional/services/transform/transform_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { FtrProviderContext } from '../../ftr_provider_context';
type TransformRowActionName = 'Clone' | 'Delete' | 'Edit' | 'Start' | 'Stop' | 'Discover';

export function TransformTableProvider({ getService }: FtrProviderContext) {
const find = getService('find');
const retry = getService('retry');
const testSubjects = getService('testSubjects');
const browser = getService('browser');
Expand Down Expand Up @@ -235,6 +236,30 @@ export function TransformTableProvider({ getService }: FtrProviderContext) {
return !subSelector ? row : `${row} > ${subSelector}`;
}

public async ensureTransformActionsMenuOpen(transformId: string) {
await retry.tryForTime(30 * 1000, async () => {
await this.ensureTransformActionsMenuClosed();

if (!(await find.existsByCssSelector('.euiContextMenuPanel', 1000))) {
await testSubjects.click(this.rowSelector(transformId, 'euiCollapsedItemActionsButton'));
expect(await find.existsByCssSelector('.euiContextMenuPanel', 1000)).to.eql(
true,
'Actions popover should exist'
);
}
});
}

public async ensureTransformActionsMenuClosed() {
await retry.tryForTime(30 * 1000, async () => {
await browser.pressKeys(browser.keys.ESCAPE);
expect(await find.existsByCssSelector('.euiContextMenuPanel', 1000)).to.eql(
false,
'Actions popover should not exist'
);
});
}

public async assertTransformRowActionsButtonEnabled(
transformId: string,
expectedValue: boolean
Expand All @@ -251,7 +276,7 @@ export function TransformTableProvider({ getService }: FtrProviderContext) {
}

public async assertTransformRowActions(transformId: string, isTransformRunning = false) {
await testSubjects.click(this.rowSelector(transformId, 'euiCollapsedItemActionsButton'));
await this.ensureTransformActionsMenuOpen(transformId);

await testSubjects.existOrFail('transformActionClone');
await testSubjects.existOrFail('transformActionDelete');
Expand All @@ -265,6 +290,8 @@ export function TransformTableProvider({ getService }: FtrProviderContext) {
await testSubjects.existOrFail('transformActionStart');
await testSubjects.missingOrFail('transformActionStop');
}

await this.ensureTransformActionsMenuClosed();
}

public async assertTransformRowActionEnabled(
Expand All @@ -276,8 +303,7 @@ export function TransformTableProvider({ getService }: FtrProviderContext) {
await retry.tryForTime(60 * 1000, async () => {
await this.refreshTransformList();

await browser.pressKeys(browser.keys.ESCAPE);
await testSubjects.click(this.rowSelector(transformId, 'euiCollapsedItemActionsButton'));
await this.ensureTransformActionsMenuOpen(transformId);

await testSubjects.existOrFail(selector, { timeout: 1000 });
const isEnabled = await testSubjects.isEnabled(selector);
Expand All @@ -288,26 +314,14 @@ export function TransformTableProvider({ getService }: FtrProviderContext) {
}')`
);

// Close the actions menu
await browser.pressKeys(browser.keys.ESCAPE);
});
}

public async clickTransformRowActionWithRetry(
transformId: string,
action: TransformRowActionName
) {
await retry.tryForTime(30 * 1000, async () => {
await browser.pressKeys(browser.keys.ESCAPE);
await testSubjects.click(this.rowSelector(transformId, 'euiCollapsedItemActionsButton'));
await testSubjects.existOrFail(`transformAction${action}`, { timeout: 1000 });
await testSubjects.click(`transformAction${action}`);
await testSubjects.missingOrFail(`transformAction${action}`, { timeout: 1000 });
await this.ensureTransformActionsMenuClosed();
});
}

public async clickTransformRowAction(action: TransformRowActionName) {
public async clickTransformRowAction(transformId: string, action: TransformRowActionName) {
await this.ensureTransformActionsMenuOpen(transformId);
await testSubjects.click(`transformAction${action}`);
await testSubjects.missingOrFail(`transformAction${action}`);
}

public async waitForTransformsExpandedRowPreviewTabToLoad() {
Expand Down

0 comments on commit bf97c80

Please sign in to comment.