11// @vitest -environment jsdom
22import { act , renderHook } from "@testing-library/react" ;
33import { beforeEach , describe , expect , it , vi } from "vitest" ;
4-
5- const invokeMock = vi . fn ( ) ;
6- vi . mock ( "@tauri-apps/api/core" , ( ) => ( {
7- invoke : ( command : string , payload ?: Record < string , unknown > ) =>
8- invokeMock ( command , payload ) ,
9- } ) ) ;
10-
114import { useResponseActions } from "./useResponseActions" ;
125
136type HookOptions = Parameters < typeof useResponseActions > [ 0 ] ;
@@ -16,8 +9,6 @@ const writeText = vi.fn().mockResolvedValue(undefined);
169
1710beforeEach ( ( ) => {
1811 writeText . mockClear ( ) ;
19- invokeMock . mockReset ( ) ;
20- invokeMock . mockResolvedValue ( true ) ;
2112 Object . defineProperty ( navigator , "clipboard" , {
2213 value : { writeText } ,
2314 configurable : true ,
@@ -38,6 +29,8 @@ function makeOptions(overrides: Partial<HookOptions> = {}): HookOptions {
3829
3930 cancelGeneration : vi . fn ( ) ,
4031 saveAsTemplate : vi . fn ( ) . mockResolvedValue ( "tpl-1" ) ,
32+ auditResponseCopyOverride : vi . fn ( ) . mockResolvedValue ( undefined ) ,
33+ exportDraft : vi . fn ( ) . mockResolvedValue ( true ) ,
4134 logEvent : vi . fn ( ) ,
4235
4336 setResponse : vi . fn ( ) ,
@@ -62,10 +55,7 @@ describe("useResponseActions", () => {
6255 } ) ;
6356
6457 expect ( writeText ) . toHaveBeenCalledWith ( "generated text" ) ;
65- expect ( invokeMock ) . not . toHaveBeenCalledWith (
66- "audit_response_copy_override" ,
67- expect . anything ( ) ,
68- ) ;
58+ expect ( options . auditResponseCopyOverride ) . not . toHaveBeenCalled ( ) ;
6959 expect ( options . setHandoffTouched ) . toHaveBeenCalledWith ( true ) ;
7060 expect ( options . onShowSuccess ) . toHaveBeenCalledWith (
7161 "Response copied to clipboard" ,
@@ -84,7 +74,7 @@ describe("useResponseActions", () => {
8474 } ) ;
8575
8676 expect ( promptSpy ) . toHaveBeenCalled ( ) ;
87- expect ( invokeMock ) . toHaveBeenCalledWith ( "audit_response_copy_override" , {
77+ expect ( options . auditResponseCopyOverride ) . toHaveBeenCalledWith ( {
8878 reason : "ops needs this now" ,
8979 confidenceMode : "answer" ,
9080 sourcesCount : 0 ,
@@ -115,7 +105,7 @@ describe("useResponseActions", () => {
115105 await result . current . handleExportResponse ( ) ;
116106 } ) ;
117107
118- expect ( invokeMock ) . toHaveBeenCalledWith ( "export_draft" , {
108+ expect ( options . exportDraft ) . toHaveBeenCalledWith ( {
119109 responseText : "generated text" ,
120110 format : "Markdown" ,
121111 } ) ;
0 commit comments