diff --git a/src/library-authoring/create-library/CreateLibrary.test.tsx b/src/library-authoring/create-library/CreateLibrary.test.tsx index f9762e5969..06228f1aa5 100644 --- a/src/library-authoring/create-library/CreateLibrary.test.tsx +++ b/src/library-authoring/create-library/CreateLibrary.test.tsx @@ -435,7 +435,7 @@ describe('', () => { sections: 8, subsections: 12, units: 20, - createdOnServer: '2025-01-01T10:00:00Z', + createdOnServer: 'test.com', createdAt: '2025-01-01T10:00:00Z', createdBy: { username: 'testuser', @@ -478,7 +478,67 @@ describe('', () => { await waitFor(() => { expect(screen.getByText('Test Archive Library')).toBeInTheDocument(); expect(screen.getByText('TestOrg / test-archive')).toBeInTheDocument(); - expect(screen.getByText(/Contains 15 Components/i)).toBeInTheDocument(); + // Testing the archive details summary + expect(screen.getByText(/Contains 8 sections, 12 subsections, 20 units, 15 components/i)).toBeInTheDocument(); + expect(screen.getByText(/Created on instance test.com/i)).toBeInTheDocument(); + expect(screen.getByText(/by user test@example.com/i)).toBeInTheDocument(); + }); + }); + + test('shows success state without instance and user email information', async () => { + const user = userEvent.setup(); + axiosMock.onGet(getStudioHomeApiUrl()).reply(200, studioHomeMock); + + const mockResult = { + learningPackageId: 123, + title: 'Test Archive Library', + org: 'TestOrg', + slug: 'test-archive', + key: 'TestOrg/test-archive', + archiveKey: 'archive-key', + containers: 5, + components: 15, + collections: 3, + sections: 8, + subsections: 12, + units: 20, + createdOnServer: null, + createdAt: '2025-01-01T10:00:00Z', + createdBy: null, + }; + + // Pre-set the restore status to succeeded + mockRestoreStatusData = { + state: LibraryRestoreStatus.Succeeded, + result: mockResult, + error: null, + errorLog: null, + }; + + // Mock the restore mutation to return a task ID + mockRestoreMutate.mockImplementation((_file: File, { onSuccess }: any) => { + onSuccess({ taskId: 'task-123' }); + }); + + render(); + + // Switch to archive mode + const createFromArchiveBtn = await screen.findByRole('button', { name: messages.createFromArchiveButton.defaultMessage }); + await user.click(createFromArchiveBtn); + + // Upload a file to trigger the restore process + const file = new File(['test content'], 'test-archive.zip', { type: 'application/zip' }); + const dropzone = screen.getByRole('presentation', { hidden: true }); + const input = dropzone.querySelector('input[type="file"]') as HTMLInputElement; + + await user.upload(input, file); + + // Wait for the restore to complete and archive details to be shown + await waitFor(() => { + // Testing the archive details summary without instance and user email + expect(screen.getByText(/Contains 8 sections, 12 subsections, 20 units, 15 components/i)).toBeInTheDocument(); + expect(screen.queryByText(/Created on instance/i)).not.toBeInTheDocument(); + expect(screen.queryByText(/by user/i)).not.toBeInTheDocument(); }); }); diff --git a/src/library-authoring/create-library/CreateLibrary.tsx b/src/library-authoring/create-library/CreateLibrary.tsx index 34217222f0..9bae528191 100644 --- a/src/library-authoring/create-library/CreateLibrary.tsx +++ b/src/library-authoring/create-library/CreateLibrary.tsx @@ -15,6 +15,7 @@ import { import { AccessTime, Widgets, + PersonOutline, } from '@openedx/paragon/icons'; import AlertError from '@src/generic/alert-error'; import classNames from 'classnames'; @@ -203,22 +204,38 @@ export const CreateLibrary = ({
- {restoreStatus.result.title} + {restoreStatus.result.title}

{restoreStatus.result.org} / {restoreStatus.result.slug}

-
+
- + {intl.formatMessage(messages.archiveComponentsCount, { - count: restoreStatus.result.components, + countSections: restoreStatus.result.sections, + countSubsections: restoreStatus.result.subsections, + countUnits: restoreStatus.result.units, + countComponents: restoreStatus.result.components, })}
+ { + (restoreStatus.result.createdBy?.email && restoreStatus.result.createdOnServer) && ( +
+ + + {intl.formatMessage(messages.archiveRestoredCreatedBy, { + createdBy: restoreStatus.result.createdBy?.email, + server: restoreStatus.result.createdOnServer, + })} + +
+ ) + }
- + {intl.formatMessage(messages.archiveBackupDate, { date: new Date(restoreStatus.result.createdAt).toLocaleDateString(), diff --git a/src/library-authoring/create-library/messages.ts b/src/library-authoring/create-library/messages.ts index 190c9a5831..846b6bd5e2 100644 --- a/src/library-authoring/create-library/messages.ts +++ b/src/library-authoring/create-library/messages.ts @@ -120,8 +120,13 @@ const messages = defineMessages({ }, archiveComponentsCount: { id: 'course-authoring.library-authoring.create-library.form.archive.components-count', - defaultMessage: 'Contains {count} Components', - description: 'Text showing the number of components in the restored archive.', + defaultMessage: 'Contains {countSections} sections, {countSubsections} subsections, {countUnits} units, {countComponents} components', + description: 'Text showing the number of sections, subsections, units, and components in the restored archive.', + }, + archiveRestoredCreatedBy: { + id: 'course-authoring.library-authoring.create-library.form.archive.restored-created-by', + defaultMessage: 'Created on instance {server}, by user {createdBy}', + description: 'Text showing who restored the archive.', }, archiveBackupDate: { id: 'course-authoring.library-authoring.create-library.form.archive.backup-date',