@@ -485,6 +485,68 @@ describe('<CreateLibrary />', () => {
485485 } ) ;
486486 } ) ;
487487
488+ test ( 'shows success state without instance and user email information' , async ( ) => {
489+ const user = userEvent . setup ( ) ;
490+ axiosMock . onGet ( getStudioHomeApiUrl ( ) ) . reply ( 200 , studioHomeMock ) ;
491+
492+ const mockResult = {
493+ learningPackageId : 123 ,
494+ title : 'Test Archive Library' ,
495+ org : 'TestOrg' ,
496+ slug : 'test-archive' ,
497+ key : 'TestOrg/test-archive' ,
498+ archiveKey : 'archive-key' ,
499+ containers : 5 ,
500+ components : 15 ,
501+ collections : 3 ,
502+ sections : 8 ,
503+ subsections : 12 ,
504+ units : 20 ,
505+ createdOnServer : null ,
506+ createdAt : '2025-01-01T10:00:00Z' ,
507+ createdBy : null ,
508+ } ;
509+
510+ // Pre-set the restore status to succeeded
511+ mockRestoreStatusData = {
512+ state : LibraryRestoreStatus . Succeeded ,
513+ result : mockResult ,
514+ error : null ,
515+ errorLog : null ,
516+ } ;
517+
518+ // Mock the restore mutation to return a task ID
519+ mockRestoreMutate . mockImplementation ( ( _file : File , { onSuccess } : any ) => {
520+ onSuccess ( { taskId : 'task-123' } ) ;
521+ } ) ;
522+
523+ render ( < CreateLibrary /> ) ;
524+
525+ // Switch to archive mode
526+ const createFromArchiveBtn = await screen . findByRole ( 'button' , { name : messages . createFromArchiveButton . defaultMessage } ) ;
527+ await user . click ( createFromArchiveBtn ) ;
528+
529+ // Upload a file to trigger the restore process
530+ const file = new File ( [ 'test content' ] , 'test-archive.zip' , { type : 'application/zip' } ) ;
531+ const dropzone = screen . getByTestId ( 'library-archive-dropzone' ) ;
532+ const input = dropzone . querySelector ( 'input[type="file"]' ) as HTMLInputElement ;
533+
534+ Object . defineProperty ( input , 'files' , {
535+ value : [ file ] ,
536+ writable : false ,
537+ } ) ;
538+
539+ fireEvent . change ( input ) ;
540+
541+ // Wait for the restore to complete and archive details to be shown
542+ await waitFor ( ( ) => {
543+ // Testing the archive details summary without instance and user email
544+ expect ( screen . getByText ( / C o n t a i n s 8 s e c t i o n s , 1 2 s u b s e c t i o n s , 2 0 u n i t s , 1 5 c o m p o n e n t s / i) ) . toBeInTheDocument ( ) ;
545+ expect ( screen . queryByText ( / C r e a t e d o n i n s t a n c e / i) ) . not . toBeInTheDocument ( ) ;
546+ expect ( screen . queryByText ( / b y u s e r / i) ) . not . toBeInTheDocument ( ) ;
547+ } ) ;
548+ } ) ;
549+
488550 test ( 'shows error state with error message and link after failed upload' , async ( ) => {
489551 const user = userEvent . setup ( ) ;
490552 axiosMock . onGet ( getStudioHomeApiUrl ( ) ) . reply ( 200 , studioHomeMock ) ;
0 commit comments