Fix e2e tests (#10289)

- Remove the demo test as I don't think it provides much value
- Re-run a test that was discarded because it failed due to a bug;
modified the test so the bug doesn't make the test fail
- Fixed all workflow tests
This commit is contained in:
Baptiste Devessier
2025-02-18 14:30:40 +01:00
committed by GitHub
parent fb42046033
commit ade13826c2
4 changed files with 98 additions and 102 deletions

View File

@ -17,7 +17,7 @@ export class WorkflowVisualizerPage {
readonly deactivateWorkflowButton: Locator;
readonly addTriggerButton: Locator;
readonly commandMenu: Locator;
readonly workflowNameButton: Locator;
readonly workflowNameLabel: Locator;
readonly triggerNode: Locator;
readonly background: Locator;
readonly useAsDraftButton: Locator;
@ -68,9 +68,9 @@ export class WorkflowVisualizerPage {
});
this.addTriggerButton = page.getByText('Add a Trigger');
this.commandMenu = page.getByTestId('command-menu');
this.workflowNameButton = page.getByRole('button', {
name: this.workflowName,
});
this.workflowNameLabel = page
.getByTestId('top-bar-title')
.getByText(this.workflowName);
this.triggerNode = this.#page.getByTestId('rf__node-trigger');
this.background = page.locator('.react-flow__pane');
this.useAsDraftButton = page.getByRole('button', { name: 'Use as draft' });
@ -100,7 +100,7 @@ export class WorkflowVisualizerPage {
}
async waitForWorkflowVisualizerLoad() {
await expect(this.workflowNameButton).toBeVisible();
await expect(this.workflowNameLabel).toBeVisible();
}
async goToWorkflowVisualizerPage() {
@ -132,8 +132,10 @@ export class WorkflowVisualizerPage {
const actionToCreateOption = this.commandMenu.getByText(actionName);
const [createWorkflowStepResponse] = await Promise.all([
this.#page.waitForResponse((response) => {
await actionToCreateOption.click();
const createWorkflowStepResponse = await this.#page.waitForResponse(
(response) => {
if (!response.url().endsWith('/graphql')) {
return false;
}
@ -141,19 +143,14 @@ export class WorkflowVisualizerPage {
const requestBody = response.request().postDataJSON();
return requestBody.operationName === 'CreateWorkflowVersionStep';
}),
},
);
actionToCreateOption.click(),
]);
const createWorkflowStepResponseBody =
await createWorkflowStepResponse.json();
const createdStepId =
createWorkflowStepResponseBody.data.createWorkflowVersionStep.id;
await expect(
this.#page.getByTestId('command-menu').getByRole('textbox').first(),
).toHaveValue(createdActionName);
const createdActionNode = this.#page
.locator('.react-flow__node.selected')
.getByText(createdActionName);
@ -231,6 +228,14 @@ export class WorkflowVisualizerPage {
this.getDeleteNodeButton(this.triggerNode).click(),
]);
}
async closeSidePanel() {
const closeButton = this.#page.getByTestId(
'page-header-close-command-menu-button',
);
await closeButton.click();
}
}
export const test = base.extend<{ workflowVisualizer: WorkflowVisualizerPage }>(

View File

@ -1,16 +0,0 @@
import { expect, test } from '@playwright/test';
test.fixme(
'Check if demo account is working properly @demo-only',
async ({ page }) => {
await page.goto('https://app.twenty-next.com/');
await page.getByRole('button', { name: 'Continue with Email' }).click();
await page.getByRole('button', { name: 'Continue', exact: true }).click();
await page.getByRole('button', { name: 'Sign in' }).click();
await expect(page.getByText('Welcome to Twenty')).not.toBeVisible();
await page.waitForTimeout(5000);
await expect(page.getByText('Servers on a coffee break')).not.toBeVisible({
timeout: 5000,
});
},
);

View File

@ -23,10 +23,13 @@ test('Create workflow', async ({ page }) => {
return requestBody.operationName === 'CreateOneWorkflow';
}),
await createWorkflowButton.click(),
createWorkflowButton.click(),
]);
const nameInput = page.getByRole('textbox');
const recordName = page.getByTestId('top-bar-title').getByTestId('tooltip');
await recordName.click();
const nameInput = page.getByTestId('top-bar-title').getByRole('textbox');
await nameInput.fill(NEW_WORKFLOW_NAME);
const workflowDiagramContainer = page.locator('.react-flow__renderer');
@ -36,7 +39,9 @@ test('Create workflow', async ({ page }) => {
const newWorkflowId = body.data.createWorkflow.id;
try {
const workflowName = page.getByRole('button', { name: NEW_WORKFLOW_NAME });
const workflowName = page
.getByTestId('top-bar-title')
.getByText(NEW_WORKFLOW_NAME);
await expect(workflowName).toBeVisible();

View File

@ -86,9 +86,10 @@ test('Use an old version as draft', async ({ workflowVisualizer, page }) => {
await expect(workflowVisualizer.getAllStepNodes()).toHaveCount(1);
});
test.fixme(
'Use an old version as draft while having a pending draft version',
async ({ workflowVisualizer, page }) => {
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');
@ -117,6 +118,8 @@ test.fixme(
await expect(workflowVisualizer.getAllStepNodes()).toHaveCount(2);
await expect(workflowVisualizer.useAsDraftButton).not.toBeVisible();
await workflowVisualizer.closeSidePanel();
const workflowsLink = page.getByRole('link', { name: 'Workflows' });
await workflowsLink.click();
@ -171,5 +174,4 @@ test.fixme(
await expect(workflowVisualizer.getAllStepNodes()).toHaveCount(1);
await expect(workflowVisualizer.activateWorkflowButton).toBeVisible();
await expect(workflowVisualizer.discardDraftButton).toBeVisible();
},
);
});