Repository navigation
Playwright Developer Guide
Setup, project layout, authentication, reporting, and CI wiring for the nr-waste-plus-e2e package. All commands below run from e2e/ unless stated otherwise.
e2e/
├── features/ # Gherkin .feature files
├── playwright/
│ ├── auth/ # CSS SSO setup, session state, TOTP
│ ├── fixtures/ # Playwright fixtures and quality recorders
│ ├── reporters/quality/ # Zod schemas, QualityReporter, renderers
│ ├── steps/ # Step definitions shared by all features
│ ├── support/ # Locators, axe, Lighthouse, token helpers
│ └── env.ts # Base URL and credential resolution
├── playwright.config.ts # Projects, reporters, timeouts, workers
└── package.json # Scripts and dependencies
bddgen reads features/ plus the step and fixture globs and generates specs under .features-gen/. Each project owns its own generated directory so a run cannot overwrite another project's specs.
Node 22.19 or newer is required. From the repository root:
cd e2e
npm ci
npx playwright install chromiumThe package reads its own git-ignored .env. Never commit credential values or .auth state.
| Variable | Purpose |
|---|---|
idir_username, idir_password
|
IDIR login through Entra |
idir_totp_secret |
One-time code generator for the Entra MFA prompt |
bceid_username, bceid_password
|
Business BCeID login |
CYPRESS_baseUrl |
Deployed frontend URL, retained for compatibility |
E2E_BASE_URL |
Alternative URL variable |
PW_FEATURES |
Comma-separated feature paths for a focused run |
URL precedence is CYPRESS_baseUrl → E2E_BASE_URL → http://localhost:3000. Credential names with CYPRESS_, IDIR_, and local *2 prefixes are accepted for compatibility with the deployed-test environment. CI supplies the real values as repository secrets.
npx bddgen && npx playwright test # full suite, equivalent to npm run pw:test
PW_FEATURES=features/screen-load.feature npx bddgen && npx playwright test
npm run pw:ui # interactive UI mode
npm run pw:report # last HTML report
npm run pw:typecheck
npm run lint
npm run test:reporters # quality reporter golden testsPW_FEATURES narrows source features before generation. When it is unset, DEFAULT_FEATURES in playwright.config.ts supplies the list. features/logouts.feature runs in the logouts teardown project; lighthouse.feature and ux-quality.feature run in the lighthouse project. To run only the logout journey, keep logouts.feature in PW_FEATURES and pass --project=logouts without --no-deps, so setup still refreshes the BCeID session.
Keep workers: 1. The Silver OpenShift route rate-limits new TCP connections and HTTP requests per client IP; parallel workers open fresh contexts back to back and fail with net::ERR_EMPTY_RESPONSE.
| Project | Role |
|---|---|
setup |
Real CSS SSO login for IDIR and Business BCeID; writes session state; teardown performs a real logout |
journeys |
Generated BDD specs for ordinary user journeys |
logouts |
Logout journey, run as teardown after every project that depends on setup
|
lighthouse |
Authenticated audits on port 9333, one worker, longer timeouts |
The setup project signs in through the actual identity provider: IDIR uses Entra with a fresh TOTP code, and Business BCeID uses its UAT flow. Journey scenarios select the saved session with @loginAsIDIR or @loginAsBCeID. There is no separate SSO hand-off project or file; the setup projects sign in directly.
Authenticated scenarios start on /search. openAppIfBlank handles steps that assert before an explicit I visit.
Lighthouse runs in-process through the lighthouse package on port 9333. runLighthouse hands the authenticated Playwright page to Lighthouse as its fourth argument. That page carries the SSO session, so no cookie injection over CDP is needed. The desktop form factor loads Lighthouse's desktop config.
Thresholds remain performance 75, accessibility 90, best practices 90, SEO 80; TTFB 95, CLS 0.1, LCP 2500. Each audit records its category and metric results as quality events. The LHR finalDisplayedUrl and the page title are stored as finalUrl and documentTitle; tokens and query values are not retained.
Steps record a11y, uiux, and lighthouse events with testInfo.attach. Fixtures validate each event against Zod schemas before attaching it. QualityReporter collects the attachments and writes e2e/reports/quality/{a11y,uiux,lighthouse}.json and e2e/reports/quality/summary.md.
summary.md has one # Quality summary heading. The verdict comes first, as **VERDICT: FAIL|WARN|PASS|NOT RUN** followed by the reason. Six renderers run in the locked order from SECTION_ORDER: summary, failures, accessibility violations, UI/UX violations, Lighthouse checks, and gate status. Status cells use plain tokens without emoji or absolute paths. Empty categories produce no section. Lighthouse groups are deduplicated by path, scenario, and profile, keeping the latest attempt. Skipped tests are a verdict cause, so they move the verdict to WARN.
The reporter does not write to $GITHUB_STEP_SUMMARY. A workflow step appends summary.md once to that file, under if: always(), after the run. Reporter unit tests and golden tests in playwright/reporters/quality/*.test.ts pin the format: section order, verdict tokens, escaping, and Lighthouse dedupe. Native reporters add HTML, JSON, JUnit, GitHub, and timeline output. CI also writes a blob report; sharding is intentionally off because the suite is short.
Trace and video are off in the shared config because traces can capture tokens in a public repository. Screenshots are kept on failure only. Playwright's copy prompt is disabled in CI since failed-test snapshots can include the identity-provider form text.
pull_request in pr-open.yml calls .github/workflows/.automated-tests.yml from the Tests job. The reusable workflow exposes the check as User flow test. It installs dependencies and Chromium, runs lint, typecheck, and reporter tests, waits for the frontend deployment, verifies credentials, then runs npx bddgen && npx playwright test.
After the run, a secret-leak scan checks playwright-report, test-results, and reports for credential values and JWT-shaped strings before artifacts are uploaded. The QualityReporter summary appears in the workflow run summary. The suite holds 57 tests and takes about 2–3 minutes.
Role mapping reads client_roles, resource_access, and cognito:groups. WASTE_PLUS_*_FOREST_CLIENT-<number> values are normalized to the numeric client used by the application. The Legacy-data tag appears when grade.code is null, even when isLegacy is false. The dev-only OpenShift route limits were raised for PR and dev environments to 300 TCP connections and 600 HTTP requests; test and production are unchanged.
- User Journeys — suite overview and Lighthouse outcome note.
- Writing Playwright BDD Scenarios — scenario conventions.
- Playwright BDD Step Reference — registered steps.
This wiki documents NR Waste Plus for users and developers. Verify security and deployment guidance against the current application configuration before applying it elsewhere.
- Report an issue or ask a question in the GitHub repository.
- Follow the Contributing Guidelines to propose an update.
- Read the Code of Conduct.
Collection indexes support human browsing and machine retrieval. Keep both current when adding or moving wiki pages.
NR Waste Plus Wiki | GitHub Repository