QA Test Lab • Runbook 05
← Back to Runbooks Sprint Plan

Runbook 05 — Test data + state reset (idempotent runs)

Quick links

Objective

Auth contract
  • API seeding uses an authenticated request context (JWT attached per request).
  • UI runs use storage state generated by global setup (.auth/storageState.json).
  • No test performs ad-hoc UI login as a prerequisite.

Classification: API 401/403 = environment/credentials/endpoint contract. Do not treat as flaky.

Rule

Each test must pass when run alone. Each test must not require another test to run first.

System contract

INPUT Authenticated user (API + UI)
Clean or irrelevant prior state
Unique test data generator
OUTPUT Deterministic records created via API
UI reflects created state immediately
DETERMINISM Unique identifiers per run
No shared state between tests
No ordering dependency
FAILURE SIGNAL UI cannot find seeded data → state propagation or API issue
API 401/403 → auth/environment contract failure
Duplicate/collision → test data generator failure

Definition of done

Invariants

Unique data All created entities use a unique suffix (timestamp + random).
No ordering No “A then B” dependencies. Any test can run first.
API seeds Setup performed via API unless the UI flow is the subject under test.
Auth centralized Auth created once (global setup) and reused (storage state + API context).
Config explicit WEB_BASE_URL and API_BASE_URL are required (no implicit defaults).
Local file references

Unique data generator: helpers/testData.js (timestamp + random suffix).

Mechanics

Targeting

Auth lifecycle

State creation + UI validation

Do
  • Use API to create preconditions.
  • Use UI to validate user-visible reads and navigation.
  • Use unique identifiers per created record.
Don’t
  • Do not rely on “existing” feed content.
  • Do not chain tests via shared runtime state.
  • Do not add fixed sleeps to paper over state issues.

Commands

Set environment (example)

export WEB_BASE_URL="http://sut.testlab:3000"
export API_BASE_URL="http://sut.testlab:3001/api"
export RW_USER_EMAIL="YOUR_USER_EMAIL"
export RW_USER_PASSWORD="YOUR_USER_PASSWORD"
npx playwright test specs/sprint5   --project=auth-chromium   --workers=1   --reporter=line
npx playwright test specs/sprint5   --project=auth-chromium   -g "S5.003"   --workers=1   --reporter=line
Reset behavior

Re-run is expected to create new records. If the app enforces uniqueness constraints, update test data generator to avoid collisions.

Expected outputs

Evidence locations
  • test-results/ (per-test artifacts)
  • playwright-report/ (HTML report)

Failure modes

Triage commands
echo "WEB_BASE_URL=$WEB_BASE_URL"
echo "API_BASE_URL=$API_BASE_URL"
echo "RW_USER_EMAIL=$RW_USER_EMAIL"

# Optional reachability
curl -sS -I "$WEB_BASE_URL/" | head -n 3
curl -sS -I "$API_BASE_URL/tags" | head -n 3

Operational value

System flow

UPSTREAM Sprint 4 — Flake control and environment discipline
DOWNSTREAM Sprint 6 — Time-to-signal (fast failure visibility)
Sprint 14 — Structured failure artifacts
Sprint 15 — Failure triage classification
Sprint 17 — Release gate decision
Why this matters

If state is not deterministic here, all downstream signals become unreliable. This runbook ensures failures are attributable to the system under test—not test design.