✨ feat: add playwright-testing skill documentation and enhance AGENTS.md with testing references
This commit is contained in:
+23
-4
@@ -2,6 +2,8 @@
|
||||
|
||||
Playwright tests for E2E, API, mobile, and visual regression. Config in `playwright.config.ts`.
|
||||
|
||||
For the full current workflow, prefer the `playwright-testing` skill.
|
||||
|
||||
## Running tests
|
||||
|
||||
- All tests: `yarn test`
|
||||
@@ -11,19 +13,36 @@ Playwright tests for E2E, API, mobile, and visual regression. Config in `playwri
|
||||
- Single file: `npx playwright test tests/e2e/filename.spec.ts`
|
||||
- Single test: `npx playwright test -g "test name"`
|
||||
- After code changes, run only affected spec files — not the full suite.
|
||||
- Prefer the configured `CODING_URL` from `.env` whenever it serves both `/` and `/api/...`.
|
||||
- The current test baseline is deterministic and seed-driven, not demo-content-driven.
|
||||
|
||||
## BrowserSync workaround
|
||||
|
||||
BrowserSync keeps a WebSocket open permanently, preventing `networkidle` and `load` from resolving. All fixture files override `page.goto()` and `page.reload()` to use `waitUntil: "domcontentloaded"` by default. Always use `domcontentloaded` for navigation waits.
|
||||
|
||||
## Console watcher
|
||||
|
||||
- Browser-based fixtures attach `tests/fixtures/console-monitor.ts` automatically.
|
||||
- Unexpected `pageerror`, `console.error`, and failed network requests fail the test.
|
||||
- Treat ignored patterns as infrastructure-only noise, not as a place to hide app bugs.
|
||||
|
||||
## Seeded setup
|
||||
|
||||
- `tests/global-setup.ts` verifies the configured base URL, probes `/api/content`, and seeds deterministic content pages.
|
||||
- `tests/global-teardown.ts` removes seeded content again and disposes shared API contexts.
|
||||
- Seed data lives in `tests/api/helpers/seed-data.ts`.
|
||||
- Seeded route constants live in `tests/fixtures/test-constants.ts`.
|
||||
- If tests write to a collection through `ADMIN_TOKEN`, that collection must define explicit permissions like `"token:${ADMIN_TOKEN}":`.
|
||||
|
||||
## Fixtures & helpers
|
||||
|
||||
- `e2e/fixtures.ts` — Shared fixtures (`authedPage`, `testUser`) and helpers (`waitForSpaReady`, `navigateToRoute`, `clickSpaLink`).
|
||||
- `e2e/fixtures.ts` — Shared desktop helpers (`waitForSpaReady`, `navigateToRoute`, `clickSpaLink`) with BrowserSync-safe navigation defaults.
|
||||
- `e2e-visual/fixtures.ts` — Visual test helpers (`waitForVisualReady`, `hideDynamicContent`, `prepareForScreenshot`, `expectScreenshot`, `getDynamicMasks`).
|
||||
- `e2e-mobile/fixtures.ts` — Mobile helpers (`openHamburgerMenu`, `isMobileViewport`, `isTabletViewport`, `isBelowLg`).
|
||||
- `api/fixtures.ts` — API fixtures (`api`, `authedApi`, `accessToken`).
|
||||
- `api/helpers/` — API test utilities (`test-user.ts`, `admin-api.ts`, `maildev.ts`).
|
||||
- `fixtures/test-constants.ts` — Central constants (`TEST_USER`, `ADMIN_TOKEN`, `API_BASE`).
|
||||
- `api/fixtures.ts` — API fixtures (`api`, `adminApi`).
|
||||
- `api/helpers/` — API test utilities (`admin-api.ts`, `seed-data.ts`, `maildev.ts`).
|
||||
- `fixtures/test-constants.ts` — Central constants (`ADMIN_TOKEN`, `API_BASE`, `TEST_BASE_URL`, `SEEDED_TEST_CONTENT`).
|
||||
- `api/helpers/test-user.ts` is legacy starter scaffolding and should only be reused if the project really needs JWT-user coverage again.
|
||||
|
||||
## Visual regression
|
||||
|
||||
|
||||
Vendored
+4
-4
@@ -4,10 +4,10 @@ import path from "node:path"
|
||||
/**
|
||||
* Zentrale Test-Konstanten für alle Tests.
|
||||
*
|
||||
* Passe diese Werte an dein Projekt an:
|
||||
* - TEST_USER: E-Mail/Passwort für den E2E-Test-User
|
||||
* - ADMIN_TOKEN: Token aus api/config.yml.env
|
||||
* - API_BASE: API-Pfad (Standard: /api)
|
||||
* Aktuell relevant fuer das deterministische Playwright-Setup:
|
||||
* - ADMIN_TOKEN: statischer Token aus api/config.yml.env fuer Seed/Cleanup
|
||||
* - TEST_BASE_URL: bevorzugt CODING_URL aus env/.env
|
||||
* - SEEDED_TEST_CONTENT: feste Routen fuer API- und E2E-Tests
|
||||
*/
|
||||
|
||||
export const TEST_USER = {
|
||||
|
||||
Reference in New Issue
Block a user