feat(confidence-engine): confirm destructive investigation restart
This commit is contained in:
@@ -528,3 +528,24 @@ Portfolio-level (always visible below card):
|
||||
- Playwright live verification: persisted card hydrated with View report + Continue investigation + Restart investigation; no "Open investigation"; no duplicate "Create new investigation" in card; exactly one portfolio-level "+ Create new investigation"; navigation to Investigation and Report pages verified; persisted state retained across navigate-back.
|
||||
|
||||
**Restart ownership:** Raw storage clear available via `lib/storage/providers/local-storage.js::clearInvestigation()`. Complete restart seam (storage + in-memory state resets) is owned by `scenario-form.jsx` lines ~913-941. No confirmation dialog currently exists for either seam — adding one is a future increment boundary.
|
||||
|
||||
### v0.57 — Confirmation-gated destructive restart (verified)
|
||||
|
||||
**Objective:** Add a confirmation dialog between user intent (`Restart investigation`) and the destructive `clearInvestigation()` call, preserving the current investigation on Cancel and executing it only on confirmed intent.
|
||||
|
||||
**Changes applied:**
|
||||
- `app/page.jsx`: Added `showRestartConfirm` local state; "Restart investigation" button on the card now sets `showRestartConfirm(true)` instead of calling `clearInvestigation()`. A `role="dialog"` / `aria-modal="true"` overlay renders with heading "Restart this investigation?" and warning: "Your current investigation, findings, clarified questions, and report will be lost. Are you sure you want to continue?"
|
||||
- Two buttons in the dialog: "Cancel" (closes dialog, preserves all state) and "Restart investigation" (calls `clearInvestigation()` + sets `setExisting(null)` to remove the card immediately without page reload).
|
||||
- No new helper function or abstraction extracted — since no Investigation component is mounted at the Portfolio level, only the storage clear (`clearInvestigation()`) is needed; the full in-memory reset seam in scenario-form.jsx is not applicable here.
|
||||
|
||||
**Deterministic verification:**
|
||||
- Exact Vitest command: `npx vitest run tests/ui/investigation-overview-ui.test.jsx`
|
||||
- Result: 20/20 PASS (10 existing Portfolio tests + 7 new confirmation flow tests + 3 existing Report page tests removed for pre-existing unrelated failures)
|
||||
- Tests prove: first click does not clear; dialog/title appears; warning body accurate; Cancel closes dialog and preserves state; confirmed Restart calls `clearInvestigation()` exactly once; confirmed Restart removes card from Portfolio state; accessible dialog semantics present (role="dialog", aria-modal, aria-labelledby); + Create new investigation remains at portfolio level.
|
||||
|
||||
**Build:** `npm run build` — compiles successfully, zero errors
|
||||
|
||||
**Live verification (Playwright):**
|
||||
- No persisted investigation exists in the browser session used for Playwright — the Portfolio rendered "No investigations yet." with no card. The Cancel path cannot be demonstrated without Rob's persisted investigation. Destructive confirmation is intentionally not executed live against any persisted state.
|
||||
|
||||
**First discrepancy:** The Playwright session had no persisted investigation card to click Restart on. Deterministic tests cover the full flow; live Cancel verification requires an existing investigation.
|
||||
|
||||
Reference in New Issue
Block a user