@@ -322,6 +322,47 @@ function buildReorderOutlineSpec(): NodeSpec[] {
322322 ] ;
323323}
324324
325+ /** Build a 4-section NodeSpec for delete/duplicate/publish tests. */
326+ function buildOperationsOutlineSpec ( ) : NodeSpec [ ] {
327+ const id = ( type : string , block : string ) => `block-v1:edX+DemoX+Demo_Course+type@${ type } +block@${ block } ` ;
328+ return [
329+ {
330+ id : id ( 'chapter' , 'd8a6192ade314473a78242dfeedfbf5b' ) ,
331+ displayName : 'Introduction 12' ,
332+ overrides : { visibilityState : 'draft' , published : false } ,
333+ children : [
334+ {
335+ id : id ( 'sequential' , '8a85e287e30a47e98d8c1f37f74a6a9d' ) ,
336+ displayName : 'Subsection 1A' ,
337+ overrides : { visibilityState : 'draft' , published : false } ,
338+ children : [ {
339+ id : id ( 'vertical' , '0f652012aa294ed9b4360a1e4f6c5232' ) ,
340+ displayName : 'Unit 1A1' ,
341+ overrides : { visibilityState : 'draft' , published : false } ,
342+ } ] ,
343+ } ,
344+ {
345+ id : id ( 'sequential' , 'b713bc2830f34f6f87554028c3068729' ) ,
346+ displayName : 'Subsection 1B' ,
347+ overrides : { visibilityState : 'draft' , published : false } ,
348+ } ,
349+ ] ,
350+ } ,
351+ { id : id ( 'chapter' , 'section-2' ) , displayName : 'Section 2' , overrides : { visibilityState : 'live' } } ,
352+ { id : id ( 'chapter' , 'section-3' ) , displayName : 'Section 3' , overrides : { visibilityState : 'live' } } ,
353+ { id : id ( 'chapter' , 'section-4' ) , displayName : 'Section 4' , overrides : { visibilityState : 'live' } } ,
354+ ] ;
355+ }
356+
357+ function useOperationsTestOutline ( ) {
358+ useTestOutline ( {
359+ sections : buildOperationsOutlineSpec ( ) ,
360+ overrides : {
361+ courseStructure : { id : 'block-v1:edX+DemoX+Demo_Course+type@course+block@course' } ,
362+ } ,
363+ } ) ;
364+ }
365+
325366/** Wrapper around useTestOutline for reorder/move tests — overrides courseStructure.id to match old mock. */
326367function useReorderTestOutline ( ) {
327368 useTestOutline ( {
@@ -644,6 +685,7 @@ describe('<CourseOutline />', () => {
644685 } ) ;
645686
646687 it ( 'adds new section correctly' , async ( ) => {
688+ useTestOutline ( ) ;
647689 const user = userEvent . setup ( ) ;
648690 renderComponent ( ) ;
649691 let elements = await screen . findAllByTestId ( 'section-card' ) ;
@@ -677,6 +719,7 @@ describe('<CourseOutline />', () => {
677719 } ) ;
678720
679721 it ( 'adds new subsection correctly' , async ( ) => {
722+ useOperationsTestOutline ( ) ;
680723 const user = userEvent . setup ( ) ;
681724 const { findAllByTestId } = renderComponent ( ) ;
682725 const [ section ] = await findAllByTestId ( 'section-card' ) ;
@@ -742,6 +785,7 @@ describe('<CourseOutline />', () => {
742785 } ) ;
743786
744787 it ( 'adds a unit from library correctly' , async ( ) => {
788+ useTestOutline ( ) ;
745789 const user = userEvent . setup ( ) ;
746790 renderComponent ( ) ;
747791 const [ sectionElement ] = await screen . findAllByTestId ( 'section-card' ) ;
@@ -765,6 +809,7 @@ describe('<CourseOutline />', () => {
765809 } ) ;
766810
767811 it ( 'adds a subsection from library correctly' , async ( ) => {
812+ useOperationsTestOutline ( ) ;
768813 const user = userEvent . setup ( ) ;
769814 renderComponent ( ) ;
770815 const [ sectionElement ] = await screen . findAllByTestId ( 'section-card' ) ;
@@ -786,6 +831,7 @@ describe('<CourseOutline />', () => {
786831 } ) ;
787832
788833 it ( 'adds a section from library correctly' , async ( ) => {
834+ useTestOutline ( ) ;
789835 const user = userEvent . setup ( ) ;
790836 renderComponent ( ) ;
791837 const sections = await screen . findAllByTestId ( 'section-card' ) ;
@@ -1014,6 +1060,7 @@ describe('<CourseOutline />', () => {
10141060 } ) ;
10151061
10161062 it ( 'check whether section, subsection and unit is deleted when corresponding delete button is clicked' , async ( ) => {
1063+ useOperationsTestOutline ( ) ;
10171064 const user = userEvent . setup ( ) ;
10181065 renderComponent ( ) ;
10191066 // get section, subsection and unit
@@ -1092,6 +1139,7 @@ describe('<CourseOutline />', () => {
10921139 } ) ;
10931140
10941141 it ( 'check whether section, subsection and unit is duplicated successfully' , async ( ) => {
1142+ useOperationsTestOutline ( ) ;
10951143 const { findAllByTestId } = renderComponent ( ) ;
10961144 // get section, subsection and unit
10971145 const [ section ] = courseOutlineIndexMock . courseStructure . childInfo . children as unknown as XBlock [ ] ;
@@ -1190,6 +1238,7 @@ describe('<CourseOutline />', () => {
11901238 } ) ;
11911239
11921240 it ( 'check section, subsection & unit is published when publish button is clicked' , async ( ) => {
1241+ useOperationsTestOutline ( ) ;
11931242 const { findAllByTestId, findByTestId } = renderComponent ( ) ;
11941243 const [ section ] = courseOutlineIndexMock . courseStructure . childInfo . children as unknown as XBlock [ ] ;
11951244 const [ sectionElement ] = await findAllByTestId ( 'section-card' ) ;
@@ -2894,6 +2943,7 @@ describe('<CourseOutline />', () => {
28942943 } ) ;
28952944
28962945 it ( 'should show toats on export tags' , async ( ) => {
2946+ useTestOutline ( ) ;
28972947 const expectedResponse = 'this is a test' ;
28982948
28992949 // Delay to ensure we see "Please wait."
@@ -2923,6 +2973,7 @@ describe('<CourseOutline />', () => {
29232973 } ) ;
29242974
29252975 it ( 'should show toast on export tags error' , async ( ) => {
2976+ useTestOutline ( ) ;
29262977 // Delay to ensure we see "Please wait."
29272978 // Without the delay the error renders too quickly
29282979 axiosMock
0 commit comments