# Complete Journey E2E Coverage Implementation Plan

> **For agentic workers:** REQUIRED SUB-SKILL: Use /ship (recommended) or /executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.

**Goal:** Repair existing generated journey tests so every UJ-001–UJ-020 H/A/P branch has deterministic setup and complete exact oracles, and complete matrix authority.

**Architecture:** One shared WordPress/Playwright support module owns nonce, factory, lower-capability, response, cleanup, and runtime-failure primitives. Each journey owns its UI trigger and branch assertions. `matrix.js` owns page × actor × exact element contracts consumed by the existing matrix runner.

**Tech Stack:** CommonJS, Playwright Test, WordPress REST API, existing admin SPA, Node syntax/lint checks.

---

## Wave Plan

| Wave | Tasks | Files touched | Safe to parallelize? |
|------|-------|---------------|----------------------|
| 1 | Task 1, Task 2 | `tests/e2e/journeys/journey-support.js`, `docs/ui_matrix/matrix.js` | yes; no overlap |
| 2 | Tasks 3–7 | UJ-001–UJ-005 spec + manifest pairs | yes; disjoint journey files |
| 3 | Tasks 8–12 | UJ-006–UJ-010 spec + manifest pairs | yes; disjoint journey files |
| 4 | Tasks 13–17 | UJ-011–UJ-015 spec + manifest pairs | yes; disjoint journey files |
| 5 | Tasks 18–22 | UJ-016–UJ-020 spec + manifest pairs | yes; disjoint journey files |
| 6 | Task 23 | `docs/user_journeys/scan-problems.md`, matrix runner if required | no; depends on all findings |

## Files and contracts

- `tests/e2e/journeys/journey-support.js`: factory-only setup, scoped idempotent cleanup, exact REST helpers, lower-capability auth, and runtime failure capture.
- `docs/ui_matrix/matrix.js`: page roots, canonical redirects, actor reachability, and exact high-value element state rows.
- `tests/e2e/journeys/UJ-*.spec.js`: three executable branch tests per journey; H1 drives documented UI, A1 drives documented rejection, P1 uses exact actor boundary.
- `tests/e2e/journeys/UJ-*.spec.manifest.json`: exact journey ID, spec path, H/A/P branches, execution classes, projects, and fixtures.
- `docs/user_journeys/scan-problems.md`: append only source contradictions found during route/permission verification.

## Tasks

### Task 1: Shared deterministic support

**Wave:** 1  **Blocks:** Tasks 3–22  **Blocked by:** —

**Contract:** Preserve exported helper names used by existing specs. Enforce exact expected statuses for fixture creation and cleanup; cleanup must execute in `finally`, remain scoped to test-owned IDs, and never accept arbitrary live records. Lower-capability fixture must create an editor through WP REST, authenticate through application password or supported login fallback, expose a valid nonce, and delete only its created user. Runtime capture must fail on page errors, console errors/warnings, and journey-owned failed requests.

**Acceptance:** `node --check tests/e2e/journeys/journey-support.js` exits 0 and all journey imports resolve.

### Task 2: Matrix authority

**Wave:** 1  **Blocks:** —  **Blocked by:** —

**Contract:** Keep every page in `pages`; add exact actor rows and high-value controls for dashboard, languages, translations, history, settings, licensing, migration, onboarding, including anonymous login redirect and administrator root assertions. No selector may be an unscoped ordinal or a generic container-only assertion.

**Acceptance:** `node --check docs/ui_matrix/matrix.js && node --check tests/e2e/ui-matrix/ui-matrix.spec.js` exits 0.

### Tasks 3–22: UJ branch coverage

Each task modifies only named spec/manifest pair. Keep H1 on the documented UI trigger. For every branch assert exact request, response, visible result, authoritative durable projection, fresh read, and forbidden effect. Use the journey contract’s literal values; where source conflict makes literal impossible, use the registered route/status and retain the documented defect in Task 23.

| Task | Journey | Required fixture/oracle focus |
|------|---------|-------------------------------|
| 3 | UJ-001 | unique language; duplicate code; anonymous 401 |
| 4 | UJ-002 | owned editable language; conflicting locale; anonymous 401 |
| 5 | UJ-003 | active non-default; default deactivation rejection; anonymous 401 |
| 6 | UJ-004 | default handoff; inactive target rejection; anonymous 401 |
| 7 | UJ-005 | unused non-default deletion; default rejection; anonymous 401 |
| 8 | UJ-006 | debug save; timeout clamp; editor 403 |
| 9 | UJ-007 | reset defaults; repeat idempotency; editor 403 |
| 10 | UJ-008 | live license activation; client format rejection; editor 403 |
| 11 | UJ-009 | active license deactivation; no-license rejection; editor 403 |
| 12 | UJ-010 | real onboarding account; expired session; editor permission boundary |
| 13 | UJ-011 | UI queue; duplicate open job; manage-translation permission boundary |
| 14 | UJ-012 | exact translated draft; empty title no transport; protected content boundary |
| 15 | UJ-013 | selected pair set; all-translated no transport; protected queue boundary |
| 16 | UJ-014 | deterministic fixture scan; concurrent lock; protected scan boundary |
| 17 | UJ-015 | UI string queue; duplicate open job; protected queue boundary |
| 18 | UJ-016 | exact manual string save; missing ID; protected string boundary |
| 19 | UJ-017 | registered `mpz/v1` migration route; failed preflight; editor 403 |
| 20 | UJ-018 | populated cache clear; cancel confirmation; editor 403 |
| 21 | UJ-019 | selected string set; already translated no transport; protected queue boundary |
| 22 | UJ-020 | pending cancellation; completed rejection; protected cancellation boundary |

**Acceptance per task:** `node --check <spec>` exits 0; manifest has exactly `H1`, `A1`, `P1`; `npx playwright test <spec> --list --config=playwright.config.js` lists three tests.

### Task 23: Findings and gates

**Wave:** 6  **Blocks:** —  **Blocked by:** Tasks 1–22

Append source-conflict rows without rewriting contracts. Run validator, full list, relevant JS checks, and remote Chromium targeted tests. Fix only failures caused by changed test/support code; report remaining product/fixture defects with exact route/status evidence.

**Acceptance:** validator exits 0; list exits 0; relevant syntax/lint/type checks exit 0; remote command output is captured with exit status.

## Self-review

- Every UJ ID has one spec and one manifest.
- Every manifest expects H1/A1/P1 and matches test tags.
- No `test.skip`, `test.fixme`, broad cleanup, raw SQL mutation, conditional required trigger, or weak body/container oracle remains.
- Source conflicts are explicit; contracts are unchanged.
