# WP1 — Request client-types scenarios (R1/R2/R3)

## Goal
One spec `e2e/specs/lis-request-client-types.spec.ts` with 3 scenarios covering the three request client types, tagged `@lis @request @client`.

## 📖 DOCUMENTATION STANDARD (owner mandate — every test case is a GUIDE)
Each `test(...)` MUST have:
1. A 2nd-arg `{ annotation: { type: "description", description: "..." } }` — a clear one-line Arabic-or-English description of WHAT this scenario proves and WHY.
2. Rich, human-readable `test.step("...")` for EVERY meaningful step — named so a non-dev reads the drill-down and understands the flow (e.g. `test.step("create an insurance request via API (contract + approval no.)")`, `test.step("assert the patient share and insurance share split correctly on the invoice")`). NOT `step 1`, `step 2`.
3. A JSDoc block above the test summarising the scenario in plain words (like the existing lis-result-review-flow.spec.ts header).
These steps + description are what render in the System Tests drill-down, so they ARE the living guide. Reuse helpers from e2e/helpers (auth: loginByApi/authHeaders/API_BASE/APP_BASE; lisSetup; uiSearch: fillSearchUntilVisible for flake). Write-isolated to company 8. Unique ids per run (testData helpers). API-setup + UI-assert where the value is.

## Scenarios
- **R1 — normal patient** `@lis @request @client @smoke`: API create patient + request with one investigation → UI assert it appears in /lab/requests. (Can reuse the pattern of the existing request-flow spec; keep that one as-is or move here — your call, but don't duplicate coverage; if you move it, retag.)
- **R2 — insurance request**: API create patient + request with `insurance_contract_id` (from WP0 seed, env `E2E_INSURANCE_CONTRACT_ID`) + `insurance_approval_number`. Assert (UI + API source-of-truth): the request shows an insurance status, and the invoice splits **patient share vs insurance share** per the contract's `patient_share_percentage` (WP0 seeded 30%). The step names must spell this out.
- **R3 — external-lab B2B**: API create request with `external_lab_id` (env `E2E_EXTERNAL_LAB_ID`), NO patient. Assert (UI): it appears under the B2B/external tab of /lab/requests and the billing targets the external lab.

## Ids from WP0 (documented at top of seed file / reported)
`E2E_INSURANCE_CONTRACT_ID`, `E2E_EXTERNAL_LAB_ID`, plus the base investigation E2E-CBC (3941). Read via env with sensible fallbacks.

## Acceptance
- [ ] 3 scenarios, each with a description annotation + named test.steps + JSDoc.
- [ ] R2 asserts the patient/insurance share split (the point of insurance).
- [ ] R3 asserts B2B routing (external lab, no patient).
- [ ] `npx playwright test --grep "@client"` runs the 3 green (retries absorb flake). Live runner trigger optional.
- [ ] `ng build` unaffected (e2e/ outside the build).

## Out of scope
Payment (WP2), tests/packages (WP3), lifecycle (WP4). No BE changes.

## Flags
No [FIN] (asserting splits, not moving money). No migration.
