Skip to content

Add Playwright e2e tests for the demo UI#30

Open
arv wants to merge 4 commits intomainfrom
claude/add-playwright-tests-3WmLD
Open

Add Playwright e2e tests for the demo UI#30
arv wants to merge 4 commits intomainfrom
claude/add-playwright-tests-3WmLD

Conversation

@arv
Copy link
Copy Markdown
Contributor

@arv arv commented Mar 29, 2026

  • Install @playwright/test in demo package
  • playwright.config.ts: loads .env, starts Vite via webServer, wires
    globalSetup/globalTeardown
  • e2e/global-setup.ts: starts Postgres (docker compose -d), waits for
    readiness, seeds deterministic test data, clears the zero-cache
    replica, then spawns zero-cache-dev and waits for port 4848
  • e2e/global-teardown.ts: kills the zero-cache process on exit
  • e2e/seed-test.ts: 10 fixed items (Alpha–Kappa) with inverted
    created/modified timestamps so all four sort orderings are distinct
  • e2e/tests/app.spec.ts: heading, item count, row rendering, default sort
  • e2e/tests/sort.spec.ts: sort field and direction toggle assertions
  • e2e/tests/item-detail.spec.ts: panel open/close, URL hash permalink,
    aria-selected, description and ID display

Run with: cd demo && pnpm test:e2e

https://claude.ai/code/session_01H3p3JUgo2y2389e3qKBo7N

claude added 4 commits March 28, 2026 13:37
- Install @playwright/test in demo package
- playwright.config.ts: loads .env, starts Vite via webServer, wires
  globalSetup/globalTeardown
- e2e/global-setup.ts: starts Postgres (docker compose -d), waits for
  readiness, seeds deterministic test data, clears the zero-cache
  replica, then spawns zero-cache-dev and waits for port 4848
- e2e/global-teardown.ts: kills the zero-cache process on exit
- e2e/seed-test.ts: 10 fixed items (Alpha–Kappa) with inverted
  created/modified timestamps so all four sort orderings are distinct
- e2e/tests/app.spec.ts: heading, item count, row rendering, default sort
- e2e/tests/sort.spec.ts: sort field and direction toggle assertions
- e2e/tests/item-detail.spec.ts: panel open/close, URL hash permalink,
  aria-selected, description and ID display

Run with: cd demo && pnpm test:e2e

https://claude.ai/code/session_01H3p3JUgo2y2389e3qKBo7N
- Use node: protocol prefix for all Node.js built-in module imports
- Expand seed data from 10 to 200 items so the virtualizer exercises
  paging (min page size is 100); extra items have inverted created/
  modified so all four sort orderings still produce distinct first rows:
    modified DESC → Alpha Item, modified ASC → Test Item 200,
    created  DESC → Kappa Item, created  ASC → Test Item 011
- Remove manual loadDotEnv() helper from playwright.config.ts; env vars
  are now loaded exclusively via `node --env-file=.env` in test:e2e
- Update sort.spec.ts assertions to match the new 200-item dataset
- Add scroll.spec.ts: scrolls the virtualizer to the bottom and verifies
  the last row (index 199) becomes visible (tests paging)
- Add .github/workflows/e2e.yml CI workflow that installs Playwright,
  runs `pnpm test:e2e` (globalSetup handles postgres + zero-cache), and
  uploads the playwright-report artifact on failure

https://claude.ai/code/session_01H3p3JUgo2y2389e3qKBo7N
`node --env-file=.env ./node_modules/.bin/playwright` fails because pnpm
generates a bash wrapper in .bin/, not a JS file.  Node.js can't execute
bash and throws a SyntaxError before playwright even starts.

The package.json bin field for @playwright/test points to cli.js, so
use that path directly:

  node --env-file=.env ./node_modules/@playwright/test/cli.js test

https://claude.ai/code/session_01H3p3JUgo2y2389e3qKBo7N
tsconfig.app.json's "./*.ts" glob picked up playwright.config.ts and
tsgo failed with TS2614 because @playwright/test is a CJS package whose
named exports conflict with the project's verbatimModuleSyntax + NodeNext
settings.

Fix:
- Exclude ./playwright.config.ts from demo/tsconfig.app.json
- Add demo/e2e/tsconfig.json that extends tsconfig-shared.json and
  explicitly adds "types": ["@playwright/test"], covering both
  playwright.config.ts and all e2e/**/*.ts files
- Add demo/e2e/tsconfig.json to the root check-types script so the
  playwright files are still type-checked

https://claude.ai/code/session_01H3p3JUgo2y2389e3qKBo7N
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.

2 participants