Add e2e tests for the Use as Draft feature (#9845)
Test with and without a draft version as the last version of the workflow
This commit is contained in:
committed by
GitHub
parent
aacbf11435
commit
a4011676f0
@ -20,6 +20,9 @@ export class WorkflowVisualizerPage {
|
|||||||
readonly workflowNameButton: Locator;
|
readonly workflowNameButton: Locator;
|
||||||
readonly triggerNode: Locator;
|
readonly triggerNode: Locator;
|
||||||
readonly background: Locator;
|
readonly background: Locator;
|
||||||
|
readonly useAsDraftButton: Locator;
|
||||||
|
readonly overrideDraftButton: Locator;
|
||||||
|
readonly discardDraftButton: Locator;
|
||||||
|
|
||||||
#actionNames: Record<WorkflowActionType, string> = {
|
#actionNames: Record<WorkflowActionType, string> = {
|
||||||
'create-record': 'Create Record',
|
'create-record': 'Create Record',
|
||||||
@ -70,6 +73,13 @@ export class WorkflowVisualizerPage {
|
|||||||
});
|
});
|
||||||
this.triggerNode = this.#page.getByTestId('rf__node-trigger');
|
this.triggerNode = this.#page.getByTestId('rf__node-trigger');
|
||||||
this.background = page.locator('.react-flow__pane');
|
this.background = page.locator('.react-flow__pane');
|
||||||
|
this.useAsDraftButton = page.getByRole('button', { name: 'Use as draft' });
|
||||||
|
this.overrideDraftButton = page.getByRole('button', {
|
||||||
|
name: 'Override Draft',
|
||||||
|
});
|
||||||
|
this.discardDraftButton = page.getByRole('button', {
|
||||||
|
name: 'Discard Draft',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async createOneWorkflow() {
|
async createOneWorkflow() {
|
||||||
|
|||||||
175
packages/twenty-e2e-testing/tests/workflow-use-as-draft.spec.ts
Normal file
175
packages/twenty-e2e-testing/tests/workflow-use-as-draft.spec.ts
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
import { expect } from '@playwright/test';
|
||||||
|
import { test } from '../lib/fixtures/blank-workflow';
|
||||||
|
|
||||||
|
test('Use an old version as draft', async ({ workflowVisualizer, page }) => {
|
||||||
|
await workflowVisualizer.createInitialTrigger('record-created');
|
||||||
|
|
||||||
|
await workflowVisualizer.createStep('create-record');
|
||||||
|
|
||||||
|
await workflowVisualizer.background.click();
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
expect(workflowVisualizer.workflowStatus).toHaveText('Active'),
|
||||||
|
|
||||||
|
workflowVisualizer.activateWorkflowButton.click(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
expect(workflowVisualizer.workflowStatus).toHaveText('Draft'),
|
||||||
|
|
||||||
|
workflowVisualizer.createStep('delete-record'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
await workflowVisualizer.background.click();
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
expect(workflowVisualizer.workflowStatus).toHaveText('Active'),
|
||||||
|
|
||||||
|
workflowVisualizer.activateWorkflowButton.click(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
await expect(workflowVisualizer.triggerNode).toContainText(
|
||||||
|
'Record is Created',
|
||||||
|
);
|
||||||
|
await expect(workflowVisualizer.getAllStepNodes()).toContainText([
|
||||||
|
'Create Record',
|
||||||
|
'Delete Record',
|
||||||
|
]);
|
||||||
|
await expect(workflowVisualizer.getAllStepNodes()).toHaveCount(2);
|
||||||
|
await expect(workflowVisualizer.useAsDraftButton).not.toBeVisible();
|
||||||
|
|
||||||
|
const workflowsLink = page.getByRole('link', { name: 'Workflows' });
|
||||||
|
await workflowsLink.click();
|
||||||
|
|
||||||
|
const recordTableRowForWorkflow = page.getByRole('row', {
|
||||||
|
name: workflowVisualizer.workflowName,
|
||||||
|
});
|
||||||
|
|
||||||
|
const linkToWorkflow = recordTableRowForWorkflow.getByRole('link', {
|
||||||
|
name: workflowVisualizer.workflowName,
|
||||||
|
});
|
||||||
|
expect(linkToWorkflow).toBeVisible();
|
||||||
|
|
||||||
|
const linkToFirstWorkflowVersion = recordTableRowForWorkflow.getByRole(
|
||||||
|
'link',
|
||||||
|
{
|
||||||
|
name: 'v1',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
await linkToFirstWorkflowVersion.click();
|
||||||
|
|
||||||
|
await expect(workflowVisualizer.workflowStatus).toHaveText('Archived');
|
||||||
|
await expect(workflowVisualizer.useAsDraftButton).toBeVisible();
|
||||||
|
await expect(workflowVisualizer.triggerNode).toContainText(
|
||||||
|
'Record is Created',
|
||||||
|
);
|
||||||
|
await expect(workflowVisualizer.getAllStepNodes()).toContainText([
|
||||||
|
'Create Record',
|
||||||
|
]);
|
||||||
|
await expect(workflowVisualizer.getAllStepNodes()).toHaveCount(1);
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
page.waitForURL(`/object/workflow/${workflowVisualizer.workflowId}`),
|
||||||
|
|
||||||
|
workflowVisualizer.useAsDraftButton.click(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
await expect(workflowVisualizer.workflowStatus).toHaveText('Draft');
|
||||||
|
await expect(workflowVisualizer.useAsDraftButton).not.toBeVisible();
|
||||||
|
await expect(workflowVisualizer.triggerNode).toContainText(
|
||||||
|
'Record is Created',
|
||||||
|
);
|
||||||
|
await expect(workflowVisualizer.getAllStepNodes()).toContainText([
|
||||||
|
'Create Record',
|
||||||
|
]);
|
||||||
|
await expect(workflowVisualizer.getAllStepNodes()).toHaveCount(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Use an old version as draft while having a pending draft version', async ({
|
||||||
|
workflowVisualizer,
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
await workflowVisualizer.createInitialTrigger('record-created');
|
||||||
|
|
||||||
|
await workflowVisualizer.createStep('create-record');
|
||||||
|
|
||||||
|
await workflowVisualizer.background.click();
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
expect(workflowVisualizer.workflowStatus).toHaveText('Active'),
|
||||||
|
|
||||||
|
workflowVisualizer.activateWorkflowButton.click(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
expect(workflowVisualizer.workflowStatus).toHaveText('Draft'),
|
||||||
|
|
||||||
|
workflowVisualizer.createStep('delete-record'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
await expect(workflowVisualizer.triggerNode).toContainText(
|
||||||
|
'Record is Created',
|
||||||
|
);
|
||||||
|
await expect(workflowVisualizer.getAllStepNodes()).toContainText([
|
||||||
|
'Create Record',
|
||||||
|
'Delete Record',
|
||||||
|
]);
|
||||||
|
await expect(workflowVisualizer.getAllStepNodes()).toHaveCount(2);
|
||||||
|
await expect(workflowVisualizer.useAsDraftButton).not.toBeVisible();
|
||||||
|
|
||||||
|
const workflowsLink = page.getByRole('link', { name: 'Workflows' });
|
||||||
|
await workflowsLink.click();
|
||||||
|
|
||||||
|
const recordTableRowForWorkflow = page.getByRole('row', {
|
||||||
|
name: workflowVisualizer.workflowName,
|
||||||
|
});
|
||||||
|
|
||||||
|
const linkToWorkflow = recordTableRowForWorkflow.getByRole('link', {
|
||||||
|
name: workflowVisualizer.workflowName,
|
||||||
|
});
|
||||||
|
expect(linkToWorkflow).toBeVisible();
|
||||||
|
|
||||||
|
const linkToFirstWorkflowVersion = recordTableRowForWorkflow.getByRole(
|
||||||
|
'link',
|
||||||
|
{
|
||||||
|
name: 'v1',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
await linkToFirstWorkflowVersion.click();
|
||||||
|
|
||||||
|
await expect(workflowVisualizer.workflowStatus).toHaveText('Active');
|
||||||
|
await expect(workflowVisualizer.useAsDraftButton).toBeVisible();
|
||||||
|
await expect(workflowVisualizer.triggerNode).toContainText(
|
||||||
|
'Record is Created',
|
||||||
|
);
|
||||||
|
await expect(workflowVisualizer.getAllStepNodes()).toContainText([
|
||||||
|
'Create Record',
|
||||||
|
]);
|
||||||
|
await expect(workflowVisualizer.getAllStepNodes()).toHaveCount(1);
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
expect(workflowVisualizer.overrideDraftButton).toBeVisible(),
|
||||||
|
|
||||||
|
workflowVisualizer.useAsDraftButton.click(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
page.waitForURL(`/object/workflow/${workflowVisualizer.workflowId}`),
|
||||||
|
|
||||||
|
workflowVisualizer.overrideDraftButton.click(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
await expect(workflowVisualizer.workflowStatus).toHaveText('Draft');
|
||||||
|
await expect(workflowVisualizer.useAsDraftButton).not.toBeVisible();
|
||||||
|
await expect(workflowVisualizer.triggerNode).toContainText(
|
||||||
|
'Record is Created',
|
||||||
|
);
|
||||||
|
await expect(workflowVisualizer.getAllStepNodes()).toContainText([
|
||||||
|
'Create Record',
|
||||||
|
]);
|
||||||
|
await expect(workflowVisualizer.getAllStepNodes()).toHaveCount(1);
|
||||||
|
await expect(workflowVisualizer.activateWorkflowButton).toBeVisible();
|
||||||
|
await expect(workflowVisualizer.discardDraftButton).toBeVisible();
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user