@@ -7,14 +7,19 @@ import {
77} from '@src/testUtils' ;
88import { mockGetMigrationStatus } from '@src/data/api.mocks' ;
99import { bulkModulestoreMigrateUrl } from '@src/data/api' ;
10+ import { useGetContentHits } from '@src/search-manager' ;
1011import { ImportDetailsPage } from './ImportDetailsPage' ;
1112import { LibraryProvider } from '../common/context/LibraryContext' ;
1213import { mockContentLibrary } from '../data/api.mocks' ;
14+ import { getModulestoreMigratedBlocksInfoUrl } from '../data/api' ;
15+ import { libraryComponentsMock } from '../__mocks__' ;
1316
1417mockContentLibrary . applyMock ( ) ;
1518mockGetMigrationStatus . applyMock ( ) ;
1619const { libraryId } = mockContentLibrary ;
1720const mockNavigate = jest . fn ( ) ;
21+ const mockUseSearchContext = jest . fn ( ) ;
22+ const mockFetchNextPage = jest . fn ( ) ;
1823let axiosMock ;
1924
2025// Mock the useCourseDetails hook
@@ -27,6 +32,12 @@ jest.mock('react-router-dom', () => ({
2732 useNavigate : ( ) => mockNavigate ,
2833} ) ) ;
2934
35+ jest . mock ( '@src/search-manager' , ( ) => ( {
36+ ...jest . requireActual ( '@src/search-manager' ) ,
37+ useSearchContext : ( ) => mockUseSearchContext ( ) ,
38+ useGetContentHits : jest . fn ( ) . mockReturnValue ( { isPending : true , data : null } ) ,
39+ } ) ) ;
40+
3041const render = ( migrationTaskId : string ) => (
3142 testRender (
3243 < ImportDetailsPage /> ,
@@ -96,22 +107,58 @@ describe('', () => {
96107 } ) ;
97108
98109 it ( 'should render Partial Succeeded state' , async ( ) => {
110+ axiosMock . onGet ( getModulestoreMigratedBlocksInfoUrl ( ) ) . reply ( 200 , [
111+ {
112+ sourceKey : 'block-v1:UNIX+UX2+2025_T2+type@library_content+block@test_lib_content' ,
113+ targetKey : null ,
114+ unsupportedReason : 'The "library_content" XBlock (ID: "test_lib_content") has children, so it not supported in content libraries. It has 2 children blocks.' ,
115+ } ,
116+ ] ) ;
117+ ( useGetContentHits as jest . Mock ) . mockReturnValue ( {
118+ isPending : false ,
119+ data : {
120+ hits : [
121+ {
122+ display_name : 'Randomized Content Block' ,
123+ usage_key : 'block-v1:UNIX+UX2+2025_T2+type@library_content+block@test_lib_content' ,
124+ block_type : 'library_content' ,
125+ } ,
126+ ] ,
127+ query : '' ,
128+ processingTimeMs : 0 ,
129+ limit : 1 ,
130+ offset : 0 ,
131+ estimatedTotalHits : 1 ,
132+ } ,
133+ } ) ;
134+ mockUseSearchContext . mockReturnValue ( {
135+ totalContentAndCollectionHits : 0 ,
136+ contentAndCollectionHits : [ ] ,
137+ isFetchingNextPage : false ,
138+ hasNextPage : false ,
139+ fetchNextPage : mockFetchNextPage ,
140+ searchKeywords : '' ,
141+ isFiltered : false ,
142+ isPending : false ,
143+ hits : libraryComponentsMock ,
144+ } ) ;
145+
99146 render ( mockGetMigrationStatus . migrationIdPartial ) ;
100147 expect ( await screen . findByText ( / p a r t i a l i m p o r t s u c c e s s f u l / i) ) . toBeInTheDocument ( ) ;
101148
102149 expect ( screen . getByText (
103150 / 8 5 % o f c o u r s e t e s t c o u r s e h a s b e e n i m p o r t e d s u c c e s s f u l l y / i,
104151 ) ) . toBeInTheDocument ( ) ;
105152
106- expect ( screen . getByRole ( 'cell' , {
107- name : / l e g a c y l i b r a r y c o n t e n t / i,
153+ expect ( await screen . findByRole ( 'cell' , {
154+ name : / r a n d o m i z e d c o n t e n t b l o c k / i,
155+ } ) ) . toBeInTheDocument ( ) ;
156+ expect ( await screen . findByRole ( 'cell' , {
157+ name : 'library_content' ,
108158 } ) ) . toBeInTheDocument ( ) ;
109- expect ( screen . getByRole ( 'cell' , {
110- name : / l i b r a r y _ c o n t e n t / i,
159+ expect ( await screen . findByRole ( 'cell' , {
160+ name : / h a s c h i l d r e n , s o i t n o t s u p p o r t e d i n c o n t e n t l i b r a r i e s / i,
111161 } ) ) . toBeInTheDocument ( ) ;
112- expect ( screen . getByRole ( 'cell' , {
113- name : / t h e b l o c k h a s c h i l d r e n , s o i t i s n o t s u p p o r t e d i n c o n t e n t l i b r a r i e s / i,
114- } ) ) ;
115162
116163 const viewImportedContentBtn = screen . getByRole ( 'button' , {
117164 name : / v i e w i m p o r t e d c o n t e n t / i,
0 commit comments