-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add e2e tests for the Use as Draft feature #9845
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(), | ||
]); | ||
Comment on lines
+72
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: The URL wait and button click should be sequential - waiting for URL after clicking the button. Current implementation may lead to flaky tests. |
||
|
||
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(), | ||
]); | ||
Comment on lines
+158
to
+162
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Same issue with URL wait and button click ordering as above. The URL wait should come after the button 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(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: consider using a common prefix for these related button names to make maintenance easier and prevent typos