@@ -2218,7 +2218,7 @@ describe('<CourseUnit />', () => {
22182218 const currentSubSectionName = courseSectionVerticalMock . xblock_info . ancestor_info . ancestors [ 1 ] . display_name ;
22192219 const helpLinkUrl = 'https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/latest/developing_course/course_components.html#components-that-contain-other-components' ;
22202220
2221- waitFor ( ( ) => {
2221+ await waitFor ( ( ) => {
22222222 const unitHeaderTitle = screen . getByTestId ( 'unit-header-title' ) ;
22232223 expect ( screen . getByText ( unitDisplayName ) ) . toBeInTheDocument ( ) ;
22242224 expect ( within ( unitHeaderTitle ) . getByRole ( 'button' , { name : headerTitleMessages . altButtonEdit . defaultMessage } ) ) . toBeInTheDocument ( ) ;
@@ -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
2324- waitFor ( ( ) => {
2325- simulatePostMessageEvent ( messageTypes . duplicateXBlock , { } ) ;
2326- simulatePostMessageEvent ( messageTypes . newXBlockEditor , { } ) ;
2327- expect ( mockedUsedNavigate )
2328- . toHaveBeenCalledWith ( `/course/${ courseId } /editor/html/${ targetBlockId } ` , { replace : true } ) ;
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 } ) ;
2324+ await waitFor ( ( ) => {
2325+ expect ( screen . queryByRole ( 'dialog' ) ) . toBeInTheDocument ( ) ;
23292326 } ) ;
23302327 } ) ;
23312328
0 commit comments