Skip to content

User Journeys

Paulo Gomes da Cruz Junior edited this page Nov 30, 2026 · 1 revision

User Journeys

BDD end-to-end tests for Waste Plus. Playwright runs the scenarios. playwright-bdd turns Gherkin into Playwright tests. Feature files live in e2e/features/. Step definitions, fixtures, and support code live in e2e/playwright/.

Anyone on the team can describe a journey in plain English. Developers wire the steps to the application, and the whole set runs on every pull request.

How it works

A scenario is a .feature file written in Gherkin. You describe what should happen. The step definitions decide how to drive the browser.

Feature: Screen loading

  Scenario: Screen loads
    Given I visit "/"
    Then I can read "Waste Plus"

Authentication is a setup project, not a step in your feature. Tag a scenario @loginAsIDIR or @loginAsBCeID and the suite reuses a session created by a real CSS SSO login. IDIR uses Entra TOTP. Business BCeID uses its own UAT account. There is no Cypress-to-Playwright state hand-off.

Quick start

From the repository root:

cd e2e
npm ci
npx playwright install chromium
npx bddgen && npx playwright test

The package is nr-waste-plus-e2e and needs Node 22.19 or newer.

To run one feature:

PW_FEATURES=features/screen-load.feature npx bddgen && npx playwright test

PW_FEATURES takes a comma-separated list of feature paths relative to e2e. When it is unset, playwright.config.ts uses DEFAULT_FEATURES.

CI gate

The blocking pull-request check is pull_request → pr-open.yml job Tests → .github/workflows/.automated-tests.yml job User flow test. The suite holds 57 tests and finishes in about 2–3 minutes.

Setting Value
Workers 1 (the Silver route rate-limits per client IP)
Retries 2 in CI, 0 locally
Trace / video Off; screenshots on failure only
Sharding Off; blob report retained for future use
Credentials Repository secrets, injected into the setup project
Artifact check Secret-leak scan over report directories before upload

The quality reporter writes e2e/reports/quality/summary.md. The file opens with one # Quality summary heading. The next line is the verdict, **VERDICT: FAIL**, **VERDICT: WARN**, **VERDICT: PASS**, or **VERDICT: NOT RUN**, followed by the reason. Sections follow in a locked order: summary, failed tests, accessibility violations, UI/UX violations, Lighthouse checks, and gate status. Status cells use plain tokens with no emoji. Empty categories produce no section.

Skipped tests count as a verdict cause. They turn the verdict to WARN and appear in its reason. Lighthouse groups are deduplicated by path, scenario, and profile, and the latest attempt wins.

A workflow step appends summary.md once to $GITHUB_STEP_SUMMARY, guarded by if: always(). Reporter unit and golden tests pin the format.

Guides

Guide Audience Description
Writing Playwright BDD Scenarios Everyone Feature structure, Gherkin conventions, authentication tags, and submitting a test through GitHub Issues
Playwright BDD Step Reference Everyone The step vocabulary accepted by the runner
Playwright Developer Guide Developers Package layout, environment variables, projects, reporting, and CI wiring
UI/UX Quality Checks Designers What the design-token and accessibility checks report
UI/UX Quality Checks for Developers Developers Quality events, fixtures, renderers, and golden tests
Test Rationales Everyone Why each check category exists

Coverage

The runner currently lists 15 features: accessibility, announcements, block_details, keyboard-navigation, lighthouse, login-button, logouts, my-profile, reporting_unit_details, screen-load, search, sso-smoke, theme-toggle, unauthorized-access, and ux-quality. Client creation and editing, waste submissions, reporting-unit creation, grade management, and role management still have no user-journey coverage.

Lighthouse investigation outcome (2026-11-28)

The team reached Exit A: Lighthouse now audits the already-authenticated Playwright page instead of opening a second browser session. runLighthouse passes that page as Lighthouse's fourth argument, so the audit keeps the SSO session. You do not need to inject cookies or tokens over CDP.

The dedicated lighthouse project runs on port 9333 with one worker. Thresholds stay at performance 75, accessibility 90, best practices 90, and SEO 80. Metrics stay at TTFB 95, CLS 0.1, and LCP 2500. Three authenticated audits scored about 100/100/96/91.

Each event records the audited URL and title. The URL comes from LHR finalDisplayedUrl. The event stores it as finalUrl next to documentTitle.

Known residual issues

IDIR setup can still be flaky. CI run 46177745046 finished with 56 passed and 1 flaky. Fast-fail diagnostics for the Entra MFA stages are now in place. The Playwright setup projects handle IDIR and Business BCeID login directly; no separate SSO hand-off remains.

Clone this wiki locally