Workflow e2e tests – 1st batch (#9713)
- Clean Playwright's configuration:
- Remove artificial 500ms delay between each step
- Group all tests under a `chrome` project relying on a `setup` project
to get an authentication state which all tests can reuse
- Changes on the `Sign up with invite link via email` test:
- Generate a new email for each test trial, as previously it was failing
when run many times
- Make deleting the account part of the test; if we write other tests
for account sign-up, we'll prefer to delete the accounts with an HTTP
call to speed up things
- Added some assertions to ensure we reached steps when expected, as we
removed the 500ms delay between each step, and it made some assertions
fail
- Wrote new tests for workflows:
- Created `Create workflow`, a test asserting we can create a workflow
from the record table
- Created `Create simple workflow`, a test asserting we can create a
simple flow; I will add more assertions to this test and write other
tests once this first PR is approved
- I make HTTP calls to delete and destroy workflows after they run to
keep the database clean
- Added a data-testid to ensure we focus elements from the Cmd+K; our
selectors are not strong – see `getByRole('textbox')` – and I preferred
to scope them to a root element
- Added an `aria-label` to a button
---------
Co-authored-by: prastoin <paul@twenty.com>
This commit is contained in:
committed by
GitHub
parent
d50294d39a
commit
7ed2c12e7a
67
packages/twenty-e2e-testing/tests/workflow-creation.spec.ts
Normal file
67
packages/twenty-e2e-testing/tests/workflow-creation.spec.ts
Normal file
@ -0,0 +1,67 @@
|
||||
import { expect, test } from '@playwright/test';
|
||||
import { deleteWorkflow } from '../lib/requests/delete-workflow';
|
||||
import { destroyWorkflow } from '../lib/requests/destroy-workflow';
|
||||
|
||||
test('Create workflow', async ({ page }) => {
|
||||
const NEW_WORKFLOW_NAME = 'Test Workflow';
|
||||
|
||||
await page.goto('/');
|
||||
|
||||
const workflowsLink = page.getByRole('link', { name: 'Workflows' });
|
||||
await workflowsLink.click();
|
||||
|
||||
const createWorkflowButton = page.getByRole('button', { name: 'New record' });
|
||||
|
||||
const [createWorkflowResponse] = await Promise.all([
|
||||
page.waitForResponse(async (response) => {
|
||||
if (!response.url().endsWith('/graphql')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const requestBody = response.request().postDataJSON();
|
||||
|
||||
return requestBody.operationName === 'CreateOneWorkflow';
|
||||
}),
|
||||
|
||||
await createWorkflowButton.click(),
|
||||
]);
|
||||
|
||||
const nameInputClosedState = page.getByText('Name').first();
|
||||
await nameInputClosedState.click();
|
||||
|
||||
const nameInput = page.getByRole('textbox');
|
||||
await nameInput.fill(NEW_WORKFLOW_NAME);
|
||||
await nameInput.press('Enter');
|
||||
|
||||
const body = await createWorkflowResponse.json();
|
||||
const newWorkflowId = body.data.createWorkflow.id;
|
||||
|
||||
try {
|
||||
const newWorkflowRowEntryName = page
|
||||
.getByTestId(`row-id-${newWorkflowId}`)
|
||||
.locator('div')
|
||||
.filter({ hasText: NEW_WORKFLOW_NAME })
|
||||
.nth(2);
|
||||
|
||||
await Promise.all([
|
||||
page.waitForURL(
|
||||
(url) => url.pathname === `/object/workflow/${newWorkflowId}`,
|
||||
),
|
||||
|
||||
newWorkflowRowEntryName.click(),
|
||||
]);
|
||||
|
||||
const workflowName = page.getByRole('button', { name: NEW_WORKFLOW_NAME });
|
||||
|
||||
await expect(workflowName).toBeVisible();
|
||||
} finally {
|
||||
await deleteWorkflow({
|
||||
page,
|
||||
workflowId: newWorkflowId,
|
||||
});
|
||||
await destroyWorkflow({
|
||||
page,
|
||||
workflowId: newWorkflowId,
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user