@@ -5,6 +5,7 @@ import { FloatingActionButton } from "./index";
55
66import type { LLMConnectionStatus } from "~/ai/hooks" ;
77import type { Tab } from "~/store/zustand/tabs" ;
8+ import type { EditorView } from "~/store/zustand/tabs/schema" ;
89
910const hoisted = vi . hoisted ( ( ) => ( {
1011 currentTab : { type : "raw" } as
@@ -141,6 +142,16 @@ describe("FloatingActionButton", () => {
141142 slotId : "slot-1" ,
142143 state : { view : null , autoStart : null } ,
143144 } as Extract < Tab , { type : "sessions" } > ;
145+ const renderFloatingActionButton = (
146+ props : Partial < React . ComponentProps < typeof FloatingActionButton > > = { } ,
147+ ) =>
148+ render (
149+ < FloatingActionButton
150+ currentView = { hoisted . currentTab as EditorView }
151+ tab = { tab }
152+ { ...props }
153+ /> ,
154+ ) ;
144155
145156 beforeEach ( ( ) => {
146157 hoisted . currentTab = { type : "raw" } ;
@@ -169,7 +180,7 @@ describe("FloatingActionButton", () => {
169180 } ) ;
170181
171182 it ( "shows the chat FAB on raw memo view after transcript exists" , ( ) => {
172- render ( < FloatingActionButton tab = { tab } /> ) ;
183+ renderFloatingActionButton ( ) ;
173184
174185 expect (
175186 screen . queryByRole ( "button" , { name : "Ask Anarlog anything" } ) ,
@@ -179,7 +190,7 @@ describe("FloatingActionButton", () => {
179190 it ( "shows chat instead of a regenerate summary FAB on generated summaries" , ( ) => {
180191 hoisted . currentTab = { type : "enhanced" , id : "note-1" } ;
181192
182- render ( < FloatingActionButton tab = { tab } /> ) ;
193+ renderFloatingActionButton ( ) ;
183194
184195 expect (
185196 screen . queryByRole ( "button" , { name : "Ask Anarlog anything" } ) ,
@@ -198,7 +209,7 @@ describe("FloatingActionButton", () => {
198209 noteId : "note-1" ,
199210 } ) ;
200211
201- render ( < FloatingActionButton tab = { tab } /> ) ;
212+ renderFloatingActionButton ( ) ;
202213
203214 expect (
204215 screen . queryByRole ( "button" , { name : "Ask Anarlog anything" } ) ,
@@ -220,7 +231,7 @@ describe("FloatingActionButton", () => {
220231 hoisted . enhanceTaskStatus = "success" ;
221232 hoisted . enhancedContent = "" ;
222233
223- render ( < FloatingActionButton tab = { tab } /> ) ;
234+ renderFloatingActionButton ( ) ;
224235
225236 expect (
226237 screen . queryByRole ( "button" , { name : "Ask Anarlog anything" } ) ,
@@ -234,7 +245,7 @@ describe("FloatingActionButton", () => {
234245 hoisted . currentTab = { type : "enhanced" , id : "note-1" } ;
235246 hoisted . enhanceTaskStatus = "error" ;
236247
237- render ( < FloatingActionButton tab = { tab } /> ) ;
248+ renderFloatingActionButton ( ) ;
238249
239250 expect (
240251 screen . queryByRole ( "button" , { name : "Ask Anarlog anything" } ) ,
@@ -247,7 +258,7 @@ describe("FloatingActionButton", () => {
247258 hoisted . enhancedContent = "" ;
248259 hoisted . llmStatus = { status : "pending" , reason : "missing_provider" } ;
249260
250- render ( < FloatingActionButton tab = { tab } /> ) ;
261+ renderFloatingActionButton ( ) ;
251262
252263 expect (
253264 screen . queryByRole ( "button" , { name : "Ask Anarlog anything" } ) ,
@@ -260,7 +271,7 @@ describe("FloatingActionButton", () => {
260271 hoisted . enhancedContent = "" ;
261272 hoisted . llmStatus = { status : "pending" , reason : "missing_provider" } ;
262273
263- render ( < FloatingActionButton tab = { tab } /> ) ;
274+ renderFloatingActionButton ( ) ;
264275
265276 expect (
266277 screen . queryByRole ( "button" , { name : "Ask Anarlog anything" } ) ,
@@ -271,7 +282,7 @@ describe("FloatingActionButton", () => {
271282 it ( "keeps the chat FAB visible near the editor caret" , ( ) => {
272283 hoisted . isCaretNearBottom = true ;
273284
274- render ( < FloatingActionButton tab = { tab } /> ) ;
285+ renderFloatingActionButton ( ) ;
275286
276287 const wrapper = screen . getByText ( "Ask Anarlog anything" ) . parentElement ;
277288 const hoverZone = wrapper ?. parentElement ;
@@ -293,7 +304,7 @@ describe("FloatingActionButton", () => {
293304 it ( "keeps the chat FAB visible during active meetings" , ( ) => {
294305 hoisted . sessionMode = "active" ;
295306
296- render ( < FloatingActionButton tab = { tab } /> ) ;
307+ renderFloatingActionButton ( ) ;
297308
298309 const wrapper = screen . getByText ( "Ask Anarlog anything" ) . parentElement ;
299310 const hoverZone = wrapper ?. parentElement ;
@@ -317,7 +328,7 @@ describe("FloatingActionButton", () => {
317328 hoisted . sessionMode = "active" ;
318329 hoisted . hasTranscript = false ;
319330
320- render ( < FloatingActionButton tab = { tab } /> ) ;
331+ renderFloatingActionButton ( ) ;
321332
322333 const wrapper = screen . getByText ( "Ask Anarlog anything" ) . parentElement ;
323334
@@ -333,7 +344,7 @@ describe("FloatingActionButton", () => {
333344 it ( "opens chat from the active meeting FAB" , ( ) => {
334345 hoisted . sessionMode = "active" ;
335346
336- render ( < FloatingActionButton tab = { tab } /> ) ;
347+ renderFloatingActionButton ( ) ;
337348
338349 fireEvent . click (
339350 screen . getByRole ( "button" , { name : "Ask Anarlog anything" } ) ,
@@ -346,7 +357,7 @@ describe("FloatingActionButton", () => {
346357 hoisted . hasTranscript = false ;
347358 hoisted . isCaretNearBottom = true ;
348359
349- render ( < FloatingActionButton tab = { tab } /> ) ;
360+ renderFloatingActionButton ( ) ;
350361
351362 const wrapper = screen . getByText ( "Start listening" ) . parentElement ;
352363
@@ -359,7 +370,7 @@ describe("FloatingActionButton", () => {
359370 it ( "hides the listen FAB when listening is disabled" , ( ) => {
360371 hoisted . hasTranscript = false ;
361372
362- render ( < FloatingActionButton allowListening = { false } tab = { tab } /> ) ;
373+ renderFloatingActionButton ( { allowListening : false } ) ;
363374
364375 expect (
365376 screen . queryByRole ( "button" , { name : "Start listening" } ) ,
@@ -370,7 +381,7 @@ describe("FloatingActionButton", () => {
370381 hoisted . currentTab = { type : "transcript" } ;
371382 hoisted . hasTranscript = false ;
372383
373- render ( < FloatingActionButton audioExists tab = { tab } /> ) ;
384+ renderFloatingActionButton ( { audioExists : true } ) ;
374385
375386 expect (
376387 screen . queryByRole ( "button" , { name : "Ask Anarlog anything" } ) ,
@@ -387,7 +398,7 @@ describe("FloatingActionButton", () => {
387398 hoisted . currentTab = { type : "transcript" } ;
388399 hoisted . hasTranscript = true ;
389400
390- render ( < FloatingActionButton audioExists tab = { tab } /> ) ;
401+ renderFloatingActionButton ( { audioExists : true } ) ;
391402
392403 expect (
393404 screen . queryByRole ( "button" , { name : "Ask Anarlog anything" } ) ,
@@ -404,7 +415,7 @@ describe("FloatingActionButton", () => {
404415 hoisted . currentTab = { type : "transcript" } ;
405416 hoisted . sessionMode = "running_batch" ;
406417
407- render ( < FloatingActionButton audioExists tab = { tab } /> ) ;
418+ renderFloatingActionButton ( { audioExists : true } ) ;
408419
409420 fireEvent . click ( screen . getByRole ( "button" , { name : "Stop transcription" } ) ) ;
410421
@@ -415,20 +426,17 @@ describe("FloatingActionButton", () => {
415426 hoisted . currentTab = { type : "transcript" } ;
416427 hoisted . hasTranscript = false ;
417428
418- render ( < FloatingActionButton tab = { tab } /> ) ;
429+ renderFloatingActionButton ( ) ;
419430
420431 expect (
421432 screen . queryByRole ( "button" , { name : "Regenerate transcript" } ) ,
422433 ) . toBeNull ( ) ;
423434 } ) ;
424435
425436 it ( "shows a skip reason in the FAB slot instead of the chat FAB" , ( ) => {
426- render (
427- < FloatingActionButton
428- tab = { tab }
429- skipReason = "Not enough words recorded (3/5 minimum)"
430- /> ,
431- ) ;
437+ renderFloatingActionButton ( {
438+ skipReason : "Not enough words recorded (3/5 minimum)" ,
439+ } ) ;
432440
433441 const status = screen . getByRole ( "status" ) ;
434442
@@ -441,12 +449,9 @@ describe("FloatingActionButton", () => {
441449 } ) ;
442450
443451 it ( "keeps a skip reason visible without tuck behavior" , ( ) => {
444- render (
445- < FloatingActionButton
446- tab = { tab }
447- skipReason = "Not enough words recorded (3/5 minimum)"
448- /> ,
449- ) ;
452+ renderFloatingActionButton ( {
453+ skipReason : "Not enough words recorded (3/5 minimum)" ,
454+ } ) ;
450455
451456 const status = screen . getByRole ( "status" ) ;
452457
0 commit comments