@@ -38,12 +38,14 @@ jest.mock('@src/course-outline/CourseOutlineContext', () => ({
3838} ) ) ;
3939
4040const startCurrentFlow = jest . fn ( ) ;
41+ const openContainerInfoSidebar = jest . fn ( ) ;
4142let currentFlow : OutlineFlow | null = null ;
4243jest . mock ( '@src/course-outline/outline-sidebar/OutlineSidebarContext' , ( ) => ( {
4344 ...jest . requireActual ( '@src/course-outline/outline-sidebar/OutlineSidebarContext' ) ,
4445 useOutlineSidebarContext : ( ) => ( {
4546 ...jest . requireActual ( '@src/course-outline/outline-sidebar/OutlineSidebarContext' ) . useOutlineSidebarContext ( ) ,
4647 startCurrentFlow,
48+ openContainerInfoSidebar,
4749 currentFlow,
4850 isCurrentFlowOn : ! ! currentFlow ,
4951 } ) ,
@@ -104,21 +106,35 @@ jest.mock('@src/course-outline/outline-sidebar/OutlineSidebarContext', () => ({
104106 switch ( containerType ) {
105107 case ContainerType . Section :
106108 await waitFor ( ( ) =>
107- expect ( handleAddBlock . mutateAsync ) . toHaveBeenCalledWith ( {
108- type : ContainerType . Chapter ,
109- parentLocator : courseUsageKey ,
110- displayName : 'Section' ,
111- } )
109+ expect ( handleAddBlock . mutateAsync ) . toHaveBeenCalledWith (
110+ {
111+ type : ContainerType . Chapter ,
112+ parentLocator : courseUsageKey ,
113+ displayName : 'Section' ,
114+ } ,
115+ expect . objectContaining ( { onSuccess : expect . any ( Function ) } ) ,
116+ )
112117 ) ;
118+ handleAddBlock . mutateAsync . mock . calls [ 0 ] [ 1 ] . onSuccess ( { locator : 'new-section-id' } ) ;
119+ expect ( openContainerInfoSidebar ) . toHaveBeenCalledWith ( 'new-section-id' , undefined , 'new-section-id' ) ;
113120 break ;
114121 case ContainerType . Subsection :
115122 await waitFor ( ( ) =>
116- expect ( handleAddBlock . mutateAsync ) . toHaveBeenCalledWith ( {
117- type : ContainerType . Sequential ,
118- parentLocator,
119- displayName : 'Subsection' ,
120- sectionId : parentLocator ,
121- } )
123+ expect ( handleAddBlock . mutateAsync ) . toHaveBeenCalledWith (
124+ {
125+ type : ContainerType . Sequential ,
126+ parentLocator,
127+ displayName : 'Subsection' ,
128+ sectionId : parentLocator ,
129+ } ,
130+ expect . objectContaining ( { onSuccess : expect . any ( Function ) } ) ,
131+ )
132+ ) ;
133+ handleAddBlock . mutateAsync . mock . calls [ 0 ] [ 1 ] . onSuccess ( { locator : 'new-subsection-id' } ) ;
134+ expect ( openContainerInfoSidebar ) . toHaveBeenCalledWith (
135+ 'new-subsection-id' ,
136+ 'new-subsection-id' ,
137+ parentLocator ,
122138 ) ;
123139 break ;
124140 case ContainerType . Unit :
0 commit comments