Skip to content

Commit 912f540

Browse files
hartra344Eric-B-Wu
andauthored
test(e2e): Clean up and fix up some mock e2e test using newer playwright apis (#4723)
* test(e2e): Fix up E2E tests a bit * test(e2e): fix up e2e tests * fix some tests * fix(Designer): Copy Paste Fixes (#4725) * fixScopePaste * remove logs * fix test * fix tests * i forgot to update the original one * readd tests * readd tests --------- Co-authored-by: Eric Wu <[email protected]>
1 parent f8624c7 commit 912f540

13 files changed

+293
-355
lines changed

.github/workflows/real-e2e.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
id-token: write
1414
strategy:
1515
matrix:
16-
browser: [chromium, firefox, webkit]
16+
browser: [chromium, firefox]
1717
steps:
1818
- uses: actions/checkout@v4
1919

@@ -101,7 +101,6 @@ jobs:
101101
run: |
102102
az group delete -n lauxtest2chromium --yes --no-wait
103103
az group delete -n lauxtest2firefox --yes --no-wait
104-
az group delete -n lauxtest2webkit --yes --no-wait
105104
106105
- name: "Upload Playwright Report to Azure Blob Storage for static site access"
107106
shell: bash

e2e/designer/app.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { expect, test } from '@playwright/test';
2+
import { GoToMockWorkflow } from './utils/GoToWorkflow';
23

34
test(
45
'Sanity Check',
@@ -8,9 +9,8 @@ test(
89
async ({ page }) => {
910
await page.goto('/');
1011

11-
await page.getByText('Select an option').click();
12-
await page.getByRole('option', { name: 'Simple Big Workflow' }).click();
13-
await page.getByRole('button', { name: 'Toolbox' }).click();
12+
await GoToMockWorkflow(page, 'Simple Big Workflow');
13+
1414
await page.getByTestId('card-Increment variable').getByRole('button').click();
1515
await page.getByLabel('Value').getByRole('paragraph').click();
1616
await page.getByLabel('Value').press('Escape');

e2e/designer/dragAndDrop.spec.ts

+6-17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { test } from '@playwright/test';
1+
import { test, expect } from '@playwright/test';
2+
import { GoToMockWorkflow } from './utils/GoToWorkflow';
23

34
test(
45
'Should be able to drag and drop operations',
@@ -8,21 +9,9 @@ test(
89
async ({ page }) => {
910
await page.goto('/');
1011

11-
await page.locator('text=Select an option').click();
12-
await page.locator('button[role="option"]:has-text("Simple Big Workflow")').click();
13-
await page.locator('div[role="button"]:has-text("🧰")').click();
14-
15-
const originElement = await page.waitForSelector('div[role="button"]:has-text("Increment variable55")');
16-
const destinationElement = await page.waitForSelector(
17-
'g:nth-child(51) > .edgebutton-foreignobject > div > div > .msla-drop-zone-viewmanager2'
18-
);
19-
20-
await originElement.hover();
21-
await page.mouse.down();
22-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
23-
const box = (await destinationElement.boundingBox())!;
24-
await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
25-
await destinationElement.hover();
26-
await page.mouse.up();
12+
await GoToMockWorkflow(page, 'Panel');
13+
await page
14+
.getByLabel('HTTP operation, HTTP connector')
15+
.dragTo(page.getByTestId('rf__edge-manual-Initialize_ArrayVariable').getByLabel('Insert a new step between'));
2716
}
2817
);

e2e/designer/ensureInitializeVariable.spec.ts

+5-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { test, expect } from '@playwright/test';
2+
import { GoToMockWorkflow } from './utils/GoToWorkflow';
3+
import { getSerializedWorkflowFromState } from './utils/designerFunctions';
24

35
test(
46
'Should be able to switch between Initialize Variable types',
@@ -7,9 +9,7 @@ test(
79
},
810
async ({ page }) => {
911
await page.goto('/');
10-
await page.getByText('Select an option').click();
11-
await page.getByRole('option', { name: 'Recurrence' }).click();
12-
await page.getByRole('button', { name: 'Toolbox' }).click();
12+
await GoToMockWorkflow(page, 'Recurrence');
1313
await page.getByLabel('Insert a new step after').click();
1414
await page.getByText('Add an action').click();
1515
await page.getByPlaceholder('Search').click();
@@ -37,29 +37,15 @@ test(
3737
.first()
3838
.click();
3939

40-
const serialized: any = await page.evaluate(() => {
41-
return new Promise((resolve) => {
42-
setTimeout(() => {
43-
const state = (window as any).DesignerStore.getState();
44-
resolve((window as any).DesignerModule.serializeBJSWorkflow(state));
45-
}, 5000);
46-
});
47-
});
40+
const serialized: any = await getSerializedWorkflowFromState(page);
4841
expect(serialized.definition.actions.Initialize_variable.inputs.variables[0].type).toBe('integer');
4942
expect(serialized.definition.actions.Initialize_variable.inputs.variables[0].value).toEqual(12);
5043

5144
await page.getByText('Integer').click();
5245
await page.getByRole('option', { name: 'Boolean' }).click();
5346
await page.getByPlaceholder('Enter initial value').click();
5447
await page.getByRole('option', { name: 'true' }).click();
55-
const serialized2: any = await page.evaluate(() => {
56-
return new Promise((resolve) => {
57-
setTimeout(() => {
58-
const state = (window as any).DesignerStore.getState();
59-
resolve((window as any).DesignerModule.serializeBJSWorkflow(state));
60-
}, 5000);
61-
});
62-
});
48+
const serialized2: any = await getSerializedWorkflowFromState(page);
6349
expect(serialized2.definition.actions.Initialize_variable.inputs.variables[0].type).toBe('boolean');
6450
expect(serialized2.definition.actions.Initialize_variable.inputs.variables[0].value).toEqual(true);
6551
}

e2e/designer/mock-copypastescope.spec.ts

+3-13
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import { test, expect } from '@playwright/test';
2+
import { getSerializedWorkflowFromState } from './utils/designerFunctions';
23

34
test(
45
'Mock: Expect Copy and Paste of Scopes to work on single workflow',
56
{
67
tag: '@mock',
78
},
8-
async ({ page, browserName, context }) => {
9-
test.skip(browserName === 'webkit');
10-
if (browserName === 'webkit') {
11-
context.grantPermissions(['clipboard-read'], { origin: 'http://localhost:4200' });
12-
}
9+
async ({ page }) => {
1310
await page.goto('/');
1411
await page.getByText('Select an option').click();
1512
await page.getByRole('option', { name: 'Conditionals', exact: true }).click();
@@ -20,14 +17,7 @@ test(
2017
await page.getByTestId('rf__edge-Initialize_variable-Condition').getByLabel('Insert a new step between').focus();
2118
await page.keyboard.press('Control+V');
2219
await page.waitForTimeout(1000);
23-
const serialized: any = await page.evaluate(() => {
24-
return new Promise((resolve) => {
25-
setTimeout(() => {
26-
const state = (window as any).DesignerStore.getState();
27-
resolve((window as any).DesignerModule.serializeBJSWorkflow(state));
28-
}, 5000);
29-
});
30-
});
20+
const serialized: any = await getSerializedWorkflowFromState(page);
3121
expect(serialized.definition).toEqual(verificationWorkflow);
3222
}
3323
);

0 commit comments

Comments
 (0)