Skip to content

Add Playwright e2e hello-world test with CI job#1164

Open
PatelUtkarsh wants to merge 1 commit intocloudinary:developfrom
PatelUtkarsh:chore/e2e-hello-world
Open

Add Playwright e2e hello-world test with CI job#1164
PatelUtkarsh wants to merge 1 commit intocloudinary:developfrom
PatelUtkarsh:chore/e2e-hello-world

Conversation

@PatelUtkarsh
Copy link
Copy Markdown

@PatelUtkarsh PatelUtkarsh commented Apr 24, 2026

No linked issue. Scaffolds the foundation for e2e testing so future PRs can build on it.

Approach

  • Adopt @wordpress/e2e-test-utils-playwright (same utility Gutenberg uses) to keep the testing surface familiar and well-supported.
  • Add a minimal tests/e2e/ suite:
    • playwright.config.js: chromium project, baseURL=http://localhost:8889 (wp-env tests site), retries/traces on CI, artifacts written under artifacts/.
    • global-setup.js: uses RequestUtils to authenticate the default admin / password wp-env user once and persist the auth cookies as Playwright storageState, so every test starts logged in.
    • hello-world.spec.js: two sanity checks. The front page responds with a non-empty <title>, and admin.visitAdminPage('index.php') shows the admin bar (confirms the login/storage-state path actually works).
  • package.json: add @playwright/test and @wordpress/e2e-test-utils-playwright devDeps, plus test:e2e / test:e2e:debug scripts.
  • .github/workflows/ci.yml: new dedicated e2e job (does not touch the existing build matrix). It runs checkout, Node 22, npm ci, npx playwright install --with-deps chromium, npm run build, npm run env:start (reuses the repo's existing .wp-env.json), npm run test:e2e, always stops wp-env, and uploads artifacts/ on failure.
  • .gitignore: ignore local artifacts/, playwright-report/, test-results/.

QA notes

Local:

  1. npm ci
  2. npx playwright install chromium
  3. npm run build
  4. npm run env:start
  5. npm run test:e2e, expect 2 passed.
  6. npm run env:stop

Verify login actually happens (not just page-load): artifacts/storage-states/admin.json should exist and contain a wordpress_logged_in_* cookie after the run.

CI:

  • Watch the new E2E (Playwright) job on this PR. It runs the same steps against wp-env on ubuntu-latest. On failure, Playwright traces/screenshots/videos are available under the playwright-artifacts workflow artifact.

Introduces @wordpress/e2e-test-utils-playwright (the same utilities
Gutenberg uses) so future e2e coverage can build on a familiar,
battle-tested foundation.

- tests/e2e: playwright config, global auth setup via RequestUtils,
  hello-world spec covering the front page and authenticated wp-admin
- package.json: test:e2e / test:e2e:debug scripts and devDeps
- ci.yml: dedicated e2e job that boots wp-env (using .wp-env.json)
  and uploads Playwright artifacts on failure
- .gitignore: ignore local Playwright output directories
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant