@@ -371,6 +371,65 @@ describe('App', () => {
371371 unmount ( ) ;
372372 } ) ;
373373
374+ it ( 'shows export buttons when a design is active' , async ( ) => {
375+ const { getStoredToken, api : mockApi } = await getApi ( ) ;
376+ vi . mocked ( getStoredToken ) . mockReturnValue ( 'valid-token' ) ;
377+
378+ const newDesign = {
379+ id : 'new-id' ,
380+ name : 'Export Test' ,
381+ widthFeet : 10 ,
382+ widthInches : 0 ,
383+ depthFeet : 12 ,
384+ depthInches : 0 ,
385+ heightFeet : 8 ,
386+ heightInches : 0 ,
387+ roofPitch : 4 ,
388+ roofType : 'Gable' as const ,
389+ openings : [ ] ,
390+ createdAt : '2024-01-01T00:00:00Z' ,
391+ updatedAt : '2024-01-01T00:00:00Z' ,
392+ } ;
393+ vi . mocked ( mockApi . createDesign ) . mockResolvedValue ( newDesign ) ;
394+ vi . mocked ( mockApi . listDesigns )
395+ . mockResolvedValueOnce ( { items : [ ] , totalCount : 0 } )
396+ . mockResolvedValue ( { items : [ newDesign ] , totalCount : 1 } ) ;
397+
398+ const { unmount } = render ( < App /> ) ;
399+
400+ await waitFor ( ( ) => {
401+ expect ( screen . getByText ( 'Select or create a design to begin' ) ) . toBeInTheDocument ( ) ;
402+ } ) ;
403+
404+ // Create a design to make export buttons appear
405+ await userEvent . click ( screen . getByLabelText ( 'Create new design' ) ) ;
406+ await userEvent . type ( screen . getByLabelText ( 'Design Name' ) , 'Export Test' ) ;
407+ await userEvent . click ( screen . getByRole ( 'button' , { name : 'Create' } ) ) ;
408+
409+ await waitFor ( ( ) => {
410+ expect ( screen . getByLabelText ( 'Download PDF' ) ) . toBeInTheDocument ( ) ;
411+ } ) ;
412+ expect ( screen . getByLabelText ( 'Download STL' ) ) . toBeInTheDocument ( ) ;
413+
414+ unmount ( ) ;
415+ } ) ;
416+
417+ it ( 'does not show export buttons when no design is selected' , async ( ) => {
418+ const { getStoredToken } = await getApi ( ) ;
419+ vi . mocked ( getStoredToken ) . mockReturnValue ( 'valid-token' ) ;
420+
421+ const { unmount } = render ( < App /> ) ;
422+
423+ await waitFor ( ( ) => {
424+ expect ( screen . getByText ( 'Select or create a design to begin' ) ) . toBeInTheDocument ( ) ;
425+ } ) ;
426+
427+ expect ( screen . queryByLabelText ( 'Download PDF' ) ) . not . toBeInTheDocument ( ) ;
428+ expect ( screen . queryByLabelText ( 'Download STL' ) ) . not . toBeInTheDocument ( ) ;
429+
430+ unmount ( ) ;
431+ } ) ;
432+
374433 it ( 'shows tabs when a design is selected' , async ( ) => {
375434 const { getStoredToken, api : mockApi } = await getApi ( ) ;
376435 vi . mocked ( getStoredToken ) . mockReturnValue ( 'valid-token' ) ;
0 commit comments