Skip to content

Commit

Permalink
Add: playwright sharding for parallel test execution (#2504)
Browse files Browse the repository at this point in the history
* Add: product edit nonce to for direct navigation

* Add: playwright sharding for parallel job

* Update packages

* Fix: flaky tests
  • Loading branch information
shashwatahalder01 authored Jan 8, 2025
1 parent 466f28a commit 8217a61
Show file tree
Hide file tree
Showing 19 changed files with 1,281 additions and 508 deletions.
310 changes: 266 additions & 44 deletions .github/workflows/e2e_api_tests.yml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/pw/e2e.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ export default defineConfig({
reporter: CI
? [
// ['github'],
['html', { open: 'never', outputFolder: 'playwright-report/e2e/html-report' }],
// ['junit', { outputFile: 'playwright-report/e2e/junit-report/e2e-results.xml' }],
// ['html', { open: 'never', outputFolder: 'playwright-report/e2e/html-report' }],
['blob', { open: 'outputDir', outputDir: 'playwright-report/e2e/blob-report' }],
['list', { printSteps: true }],
['./utils/summaryReporter.ts', { outputFile: 'playwright-report/e2e/summary-report/results.json' }],
]
: [
// ['blob', { open: 'outputDir', outputDir: 'playwright-report/e2e/blob-report' }],
['html', { open: 'never', outputFolder: 'playwright-report/e2e/html-report' }],
// ['junit', { outputFile: 'playwright-report/e2e/junit-report/e2e-results.xml' }],
['list', { printSteps: true }],
['./utils/summaryReporter.ts', { outputFile: 'playwright-report/e2e/summary-report/results.json' }],
],
Expand Down
829 changes: 554 additions & 275 deletions tests/pw/package-lock.json

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions tests/pw/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
"nid": "npm install --include=dev",
"nip": "npm install --omit=dev",
"pw:chrome-only": "playwright install chromium",
"pw:browser-with-deps": "playwright install --with-deps chromium",
"pw:deps-only": "playwright install-deps chromium",
"pw:chrome-with-deps": "playwright install --with-deps chromium",
"pw:chrome-deps-only": "playwright install-deps chromium",
"pw:browsers": "playwright install",
"pw:browsers-with-deps": "playwright install --with-deps",
"pw:browsers-deps-only": "playwright install-deps",
"test": "npx playwright test",
"site:reset": "NO_SETUP=false npm run site:setup && npm run env:setup",
"site:setup": "SKIP_DOKAN=true npx playwright test --project=local_site_setup --config=e2e.config.ts",
Expand All @@ -25,6 +28,7 @@
"test:codegen": "playwright codegen",
"test:report": "npx playwright show-report",
"test:trace": "npx playwright show-trace trace.zip",
"merge:report": "npx playwright merge-reports --reporter html",
"allure:generate": "allure generate playwright-report/allure-report -o allure-report --clean",
"allure:open": "allure open allure-report",
"start:env": "wp-env start",
Expand All @@ -50,9 +54,9 @@
"license": "ISC",
"devDependencies": {
"@types/js-yaml": "^4.0.9",
"@types/node": "^22.10.2",
"@typescript-eslint/eslint-plugin": "^8.19.0",
"@typescript-eslint/parser": "^8.19.0",
"@types/node": "^22.10.5",
"@typescript-eslint/eslint-plugin": "^8.19.1",
"@typescript-eslint/parser": "^8.19.1",
"eslint": "9.17",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-playwright": "^2.1.0",
Expand All @@ -66,7 +70,7 @@
"dependencies": {
"@faker-js/faker": "^9.3.0",
"@playwright/test": "1.49",
"@wordpress/env": "^10.14.0",
"@wordpress/env": "^10.15.0",
"dotenv": "^16.4.7",
"mysql2": "^3.12.0",
"php-serialize": "^5.0.1",
Expand Down
6 changes: 3 additions & 3 deletions tests/pw/pages/menuManagerPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ export class MenuManagerPage extends BasePage {

// update menu status
async updateMenuStatus(menu: string, action: string, menuLink: string) {
await this.goto(data.subUrls.backend.dokan.settings);
await this.gotoUntilNetworkidle(data.subUrls.backend.dokan.settings, { waitUntil: 'networkidle' }, true);
await this.click(settingsAdmin.menus.menuManager);

switch (action) {
case 'activate':
await this.enableSwitcher(settingsAdmin.menuManager.menuSwitcher(menu));
await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, settingsAdmin.saveChanges);
await this.clickAndWaitForResponseAndLoadStateUntilNetworkIdle(data.subUrls.ajax, settingsAdmin.saveChanges);
await this.toHaveBackgroundColor(settingsAdmin.menuManager.menuSwitcher(menu) + '//span', 'rgb(0, 144, 255)');
//assertion
await this.goto(data.subUrls.frontend.vDashboard.dashboard);
Expand All @@ -42,7 +42,7 @@ export class MenuManagerPage extends BasePage {

case 'deactivate':
await this.disableSwitcher(settingsAdmin.menuManager.menuSwitcher(menu));
await this.clickAndWaitForResponseAndLoadState(data.subUrls.ajax, settingsAdmin.saveChanges);
await this.clickAndWaitForResponseAndLoadStateUntilNetworkIdle(data.subUrls.ajax, settingsAdmin.saveChanges);
await this.toHaveBackgroundColor(settingsAdmin.menuManager.menuSwitcher(menu) + '//span', 'rgb(215, 218, 221)');
//assertion
await this.goto(data.subUrls.frontend.vDashboard.dashboard);
Expand Down
Loading

0 comments on commit 8217a61

Please sign in to comment.