Commit b4567af
test(components): cover useResponsePanelCopy — 23 tests, 0 prior
The 160-line useResponsePanelCopy hook exposes 8 return-surface members
(copied, showCopyOverride, copyOverrideReason, copyOverrideSubmitting,
showExportMenu, exportMenuRef, plus 4 handlers and 3 setters) and
invokes the Tauri command boundary (auditResponseCopyOverride,
exportDraft) plus navigator.clipboard — yet had zero tests. This was
the most-cited AGENTS.md DoD gap in the audit.
Adds useResponsePanelCopy.test.ts with 23 tests grouped by handler:
handleExport (4)
- happy path: exportDraft payload + success toast + menu closes
- empty response short-circuits before calling the command
- exception path: onShowError fires, menu still closes
- saved=false: no success toast, no error, command was called
handleCopy (8)
- happy path: writes navigator.clipboard with the raw response
- uses parsed.output when hasSections is true
- copied flag resets to false after the 2s timeout (fake timers)
- opens override modal when confidence mode is not 'answer'
- opens override modal when there are zero citations
- empty response short-circuits
- clipboard rejection routes to onShowError without flipping copied
- undefined confidenceMode defaults to 'answer' for gating
handleConfirmCopyOverride (7)
- happy path: audits, writes clipboard, success toast, modal closes,
reason cleared
- undefined confidenceMode is sent to audit as null
- empty reason: onShowError, no audit, no clipboard
- whitespace-only reason: same as empty (trim applied)
- audit failure: error toast, submitting flag resets in finally
- empty response short-circuits
- uses parsed.output when hasSections is true
cancelCopyOverride (1)
- closes modal and clears reason atomically
Export-menu click-outside useEffect (3)
- outside mousedown closes the menu via the ref contract
- inside mousedown leaves the menu open
- no mousedown listener is registered while the menu is closed
Mocks only external boundaries: the Tauri command module is mocked via
vi.mock("./draftTauriCommands", ...) with hoisted mock fns;
navigator.clipboard.writeText is installed on the jsdom navigator.
Total: 69 test files / 264 tests (was 68 / 241 on master). Typecheck
and eslint clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 04473dc commit b4567af
1 file changed
Lines changed: 478 additions & 0 deletions
0 commit comments