@@ -2291,41 +2291,38 @@ describe('<CourseUnit />', () => {
22912291 } ) ;
22922292
22932293 it ( 'renders and navigates to the new HTML XBlock editor after xblock duplicating' , async ( ) => {
2294- render ( < RootWrapper /> ) ;
22952294 const updatedCourseVerticalChildrenMock = JSON . parse ( JSON . stringify ( courseVerticalChildrenMock ) ) ;
2296- const targetBlockId = updatedCourseVerticalChildrenMock . children [ 1 ] . block_id ;
2297-
2298- updatedCourseVerticalChildrenMock . children = updatedCourseVerticalChildrenMock . children
2299- . map ( ( child ) => ( child . block_id === targetBlockId
2300- ? { ...child , block_type : 'html' }
2301- : child ) ) ;
2295+ // Convert the second child from drag and drop to HTML:
2296+ const targetChild = updatedCourseVerticalChildrenMock . children [ 1 ] ;
2297+ targetChild . block_type = 'html' ;
2298+ targetChild . name = 'Test HTML Block' ;
2299+ targetChild . block_id = 'block-v1:OpenedX+L153+3T2023+type@html+block@test123original' ;
23022300
23032301 axiosMock
23042302 . onPost ( postXBlockBaseApiUrl ( {
23052303 parent_locator : blockId ,
2306- duplicate_source_locator : courseVerticalChildrenMock . children [ 0 ] . block_id ,
2304+ duplicate_source_locator : targetChild . block_id ,
23072305 } ) )
23082306 . replyOnce ( 200 , { locator : '1234567890' } ) ;
23092307
23102308 axiosMock
23112309 . onGet ( getCourseVerticalChildrenApiUrl ( blockId ) )
23122310 . reply ( 200 , updatedCourseVerticalChildrenMock ) ;
23132311
2312+ render ( < RootWrapper /> ) ;
23142313 await executeThunk ( fetchCourseVerticalChildrenData ( blockId ) , store . dispatch ) ;
23152314
23162315 await waitFor ( ( ) => {
23172316 const iframe = screen . getByTitle ( xblockContainerIframeMessages . xblockIframeTitle . defaultMessage ) ;
23182317 expect ( iframe ) . toBeInTheDocument ( ) ;
2319- simulatePostMessageEvent ( messageTypes . currentXBlockId , {
2320- id : targetBlockId ,
2321- } ) ;
23222318 } ) ;
23232319
2320+ // After duplicating, the editor modal will open:
2321+ expect ( screen . queryByRole ( "dialog" ) ) . not . toBeInTheDocument ( )
2322+ simulatePostMessageEvent ( messageTypes . duplicateXBlock , { usageId : targetChild . block_id } ) ;
2323+ simulatePostMessageEvent ( messageTypes . newXBlockEditor , { blockType : 'html' , usageId : targetChild . block_id } ) ;
23242324 await waitFor ( ( ) => {
2325- simulatePostMessageEvent ( messageTypes . duplicateXBlock , { } ) ;
2326- simulatePostMessageEvent ( messageTypes . newXBlockEditor , { } ) ;
2327- expect ( mockedUsedNavigate )
2328- . toHaveBeenCalledWith ( `/course/${ courseId } /editor/html/${ targetBlockId } ` , { replace : true } ) ;
2325+ expect ( screen . queryByRole ( "dialog" ) ) . toBeInTheDocument ( )
23292326 } ) ;
23302327 } ) ;
23312328
0 commit comments