Skip to content

Commit 1c8daa6

Browse files
chore: migrate complete-react-case e2e to Playwright
1 parent 3c639e7 commit 1c8daa6

File tree

6 files changed

+496
-62771
lines changed

6 files changed

+496
-62771
lines changed

complete-react-case/cypress.env.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

complete-react-case/e2e/checkApplication.cy.ts

Lines changed: 0 additions & 97 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { test, expect } from '@playwright/test';
2+
import { Constants } from '../../cypress-e2e/fixtures/constants';
3+
4+
test.describe('Complete React case', () => {
5+
test.beforeEach(async ({ page }) => {
6+
await page.goto('/');
7+
});
8+
9+
test('Check App build and running', async ({ page }) => {
10+
const text = Constants.elementsText.completeReactCaseApp;
11+
await expect(page.locator('h1')).toHaveText(text.header);
12+
await expect(page.locator('strong').nth(0)).toHaveText(text.paragraphs.firstParagraph);
13+
await expect(page.locator('strong').nth(1)).toHaveText(text.paragraphs.secondParagraph);
14+
await expect(page.locator('h4').filter({ hasText: text.buttons.h4Buttons })).toBeVisible();
15+
await expect(page.locator('h4').filter({ hasText: text.h4Dialog })).toBeVisible();
16+
await expect(page.locator('h4').filter({ hasText: text.h4HoverElement })).toBeVisible();
17+
await expect(page.locator('.tool-tip')).toHaveText(text.h4HoverElement);
18+
});
19+
20+
test('Check App buttons', async ({ page }) => {
21+
const { buttons } = Constants.elementsText.completeReactCaseApp;
22+
await expect(page.getByRole('button', { name: buttons.primaryButton })).toBeVisible();
23+
await expect(page.getByRole('button', { name: buttons.warningButton })).toBeVisible();
24+
await expect(page.getByRole('button', { name: buttons.openDialogButton })).toBeVisible();
25+
await expect(page.getByRole('button', { name: buttons.primaryButton })).toHaveCSS(
26+
'background-color',
27+
Constants.color.lightWashedAzure,
28+
);
29+
await expect(page.getByRole('button', { name: buttons.warningButton })).toHaveCSS(
30+
'background-color',
31+
Constants.color.lightWashedOrange,
32+
);
33+
});
34+
35+
test('Check App Dialog popup', async ({ page }) => {
36+
const { buttons, nameMessage } = Constants.elementsText.completeReactCaseApp;
37+
await page.getByRole('button', { name: buttons.openDialogButton }).click();
38+
await expect(page.getByRole('button', { name: buttons.closeButton })).toBeVisible();
39+
await expect(page.getByText(nameMessage)).toBeVisible();
40+
await page.fill('input', Constants.commonPhrases.completeReactCaseApp.input);
41+
await page.getByRole('button', { name: buttons.closeButton }).click();
42+
});
43+
});
44+

complete-react-case/package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
"build": "pnpm --filter complete-react-case_* --parallel build",
99
"legacy:build": "pnpm --filter complete-react-case_* --parallel legacy:build",
1010
"legacy:start": "pnpm --filter complete-react-case_* --parallel legacy:start",
11-
"e2e:ci": "pnpm start & wait-on http-get://localhost:3002/ && npx cypress run --config-file ../cypress-e2e/config/cypress.config.ts --config '{\"supportFile\": \"../cypress-e2e/support/e2e.ts\"}' --spec \"./e2e/*.cy.ts\" --browser=chrome",
12-
"legacy:e2e:ci": "pnpm legacy:start & wait-on http-get://localhost:3002/ && npx cypress run --config-file ../cypress-e2e/config/cypress.config.ts --config '{\"supportFile\": \"../cypress-e2e/support/e2e.ts\"}' --spec \"./e2e/*.cy.ts\" --browser=chrome"
11+
"test:e2e": "npx playwright test",
12+
"test:e2e:ui": "npx playwright test --ui",
13+
"test:e2e:debug": "npx playwright test --debug",
14+
"e2e:ci": "pnpm build && npx playwright install --with-deps && npx playwright test --reporter=list",
15+
"legacy:e2e:ci": "pnpm legacy:build && npx playwright install --with-deps && npx playwright test --reporter=list"
1316
},
1417
"keywords": [],
1518
"author": "",
@@ -19,6 +22,7 @@
1922
},
2023
"homepage": "https://github.com/anderlaw/react-webpack-MF#readme",
2124
"devDependencies": {
22-
"wait-on": "7.2.0"
25+
"@playwright/test": "^1.54.2",
26+
"playwright": "^1.54.2"
2327
}
2428
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
export default defineConfig({
4+
testDir: './e2e',
5+
timeout: 60000,
6+
expect: {
7+
timeout: 15000,
8+
},
9+
fullyParallel: true,
10+
forbidOnly: !!process.env.CI,
11+
retries: process.env.CI ? 1 : 0,
12+
workers: process.env.CI ? 1 : undefined,
13+
reporter: [
14+
['html', { outputFolder: 'playwright-report', open: 'never' }],
15+
['list'],
16+
],
17+
use: {
18+
baseURL: 'http://localhost:3002',
19+
trace: 'on-first-retry',
20+
screenshot: 'only-on-failure',
21+
video: 'retain-on-failure',
22+
viewport: { width: 1920, height: 1080 },
23+
},
24+
25+
projects: [
26+
{
27+
name: 'chromium',
28+
use: { ...devices['Desktop Chrome'] },
29+
},
30+
],
31+
32+
webServer: [
33+
{
34+
command: 'cd lib-app && pnpm serve',
35+
port: 3000,
36+
reuseExistingServer: !process.env.CI,
37+
timeout: 120000,
38+
},
39+
{
40+
command: 'cd component-app && pnpm serve',
41+
port: 3001,
42+
reuseExistingServer: !process.env.CI,
43+
timeout: 120000,
44+
},
45+
{
46+
command: 'cd main-app && pnpm serve',
47+
port: 3002,
48+
reuseExistingServer: !process.env.CI,
49+
timeout: 120000,
50+
},
51+
],
52+
});
53+

0 commit comments

Comments
 (0)