11import { useCourseDetails } from '@src/course-outline/data/apiHooks' ;
22import { useMigrationInfo } from '@src/library-authoring/data/apiHooks' ;
3- import { useGetBlockTypes } from '@src/search-manager' ;
3+ import { useGetBlockTypes , useGetContentHits } from '@src/search-manager' ;
44import { render as baseRender , screen , initializeMocks } from '@src/testUtils' ;
55import { LibraryProvider } from '@src/library-authoring/common/context/LibraryContext' ;
66import { mockContentLibrary } from '@src/library-authoring/data/api.mocks' ;
@@ -25,6 +25,7 @@ jest.mock('@src/library-authoring/data/apiHooks', () => ({
2525// Mock the useGetBlockTypes hook
2626jest . mock ( '@src/search-manager' , ( ) => ( {
2727 useGetBlockTypes : jest . fn ( ) . mockReturnValue ( { isPending : true , data : null } ) ,
28+ useGetContentHits : jest . fn ( ) . mockReturnValue ( { isPending : true , data : null } ) ,
2829} ) ) ;
2930
3031const render = ( element : React . ReactElement ) => {
@@ -80,7 +81,7 @@ describe('ReviewImportDetails', () => {
8081 } ] ,
8182 } ,
8283 } ) ;
83- ( useGetBlockTypes as jest . Mock ) . mockReturnValue ( {
84+ ( useGetBlockTypes as jest . Mock ) . mockReturnValueOnce ( {
8485 isPending : false ,
8586 data : { html : 1 } ,
8687 } ) ;
@@ -103,7 +104,7 @@ describe('ReviewImportDetails', () => {
103104 isPending : false ,
104105 data : null ,
105106 } ) ;
106- ( useGetBlockTypes as jest . Mock ) . mockReturnValue ( {
107+ ( useGetBlockTypes as jest . Mock ) . mockReturnValueOnce ( {
107108 isPending : false ,
108109 data : {
109110 chapter : 1 ,
@@ -134,13 +135,63 @@ describe('ReviewImportDetails', () => {
134135 expect ( markAnalysisComplete ) . toHaveBeenCalledWith ( true ) ;
135136 } ) ;
136137
138+ it ( 'considers children blocks of unsupportedBlocks' , async ( ) => {
139+ ( useCourseDetails as jest . Mock ) . mockReturnValue ( { isPending : false , data : { title : 'Test Course' } } ) ;
140+ ( useMigrationInfo as jest . Mock ) . mockReturnValue ( {
141+ isPending : false ,
142+ data : null ,
143+ } ) ;
144+ ( useGetContentHits as jest . Mock ) . mockReturnValue ( {
145+ isPending : false ,
146+ data : {
147+ hits : [ { usage_key : "some-usage-key" } ] ,
148+ estimatedTotalHits : 1 ,
149+ } ,
150+ } ) ;
151+ ( useGetBlockTypes as jest . Mock ) . mockReturnValueOnce ( {
152+ isPending : false ,
153+ data : {
154+ chapter : 1 ,
155+ sequential : 2 ,
156+ vertical : 3 ,
157+ library_content : 1 ,
158+ html : 1 ,
159+ problem : 4 ,
160+ } ,
161+ } ) . mockReturnValueOnce ( {
162+ isPending : false ,
163+ data : {
164+ problem : 2 ,
165+ } ,
166+ } ) ;
167+
168+ render ( < ReviewImportDetails markAnalysisComplete = { markAnalysisComplete } courseId = "test-course-id" /> ) ;
169+
170+ expect ( await screen . findByRole ( 'alert' ) ) . toBeInTheDocument ( ) ;
171+ expect ( await screen . findByText ( / I m p o r t A n a l y s i s C o m p l e t e / i) ) . toBeInTheDocument ( ) ;
172+ expect ( await screen . findByText (
173+ / 2 5 .0 0 % o f c o n t e n t c a n n o t b e i m p o r t e d . F o r d e t a i l s s e e b e l o w ./ i,
174+ ) ) . toBeInTheDocument ( ) ;
175+ expect ( await screen . findByText ( / T o t a l B l o c k s / i) ) . toBeInTheDocument ( ) ;
176+ expect ( await screen . findByText ( '9/12' ) ) . toBeInTheDocument ( ) ;
177+ expect ( await screen . findByText ( 'Sections' ) ) . toBeInTheDocument ( ) ;
178+ expect ( await screen . findByText ( '1' ) ) . toBeInTheDocument ( ) ;
179+ expect ( await screen . findByText ( 'Subsections' ) ) . toBeInTheDocument ( ) ;
180+ expect ( await screen . findByText ( '2' ) ) . toBeInTheDocument ( ) ;
181+ expect ( await screen . findByText ( 'Units' ) ) . toBeInTheDocument ( ) ;
182+ expect ( await screen . findByText ( '3' ) ) . toBeInTheDocument ( ) ;
183+ expect ( await screen . findByText ( 'Components' ) ) . toBeInTheDocument ( ) ;
184+ expect ( await screen . findByText ( '3/6' ) ) . toBeInTheDocument ( ) ;
185+ expect ( markAnalysisComplete ) . toHaveBeenCalledWith ( true ) ;
186+ } ) ;
187+
137188 it ( 'renders success alert when no unsupported blocks' , async ( ) => {
138189 ( useCourseDetails as jest . Mock ) . mockReturnValue ( { isPending : false , data : { title : 'Test Course' } } ) ;
139190 ( useMigrationInfo as jest . Mock ) . mockReturnValue ( {
140191 isPending : false ,
141192 data : null ,
142193 } ) ;
143- ( useGetBlockTypes as jest . Mock ) . mockReturnValue ( {
194+ ( useGetBlockTypes as jest . Mock ) . mockReturnValueOnce ( {
144195 isPending : false ,
145196 data : {
146197 chapter : 1 ,
0 commit comments