@@ -87,6 +87,48 @@ describe('CompareContainersWidget', () => {
8787 expect ( await screen . findByRole ( 'button' , { name : 'subsection block 0' } ) ) . toBeInTheDocument ( ) ;
8888 } ) ;
8989
90+ test ( 'should show removed container diff state' , async ( ) => {
91+ // mocks title
92+ axiosMock . onGet ( getLibraryContainerApiUrl ( mockGetContainerMetadata . sectionId ) ) . reply ( 200 , { publishedDisplayName : 'Test Title' } ) ;
93+ axiosMock . onGet (
94+ getLibraryContainerApiUrl ( 'lct:org1:Demo_course_generated:subsection:subsection-0' ) ,
95+ ) . reply ( 200 , { publishedDisplayName : 'subsection block 0' } ) ;
96+
97+ const user = userEvent . setup ( ) ;
98+ render ( < CompareContainersWidget
99+ upstreamBlockId = { mockGetContainerMetadata . sectionId }
100+ downstreamBlockId = { mockGetCourseContainerChildren . sectionId }
101+ /> ) ;
102+ expect ( ( await screen . findAllByText ( 'Test Title' ) ) . length ) . toEqual ( 2 ) ;
103+ // left i.e. before side block
104+ const block = await screen . findByText ( 'subsection block 00' ) ;
105+ await user . click ( block ) ;
106+
107+ const removedRows = await screen . findAllByText ( 'This unit was removed' ) ;
108+ await user . click ( removedRows [ 0 ] ) ;
109+
110+ expect ( await screen . findByText ( 'This unit has been removed' ) ) . toBeInTheDocument ( ) ;
111+ } ) ;
112+
113+ test ( 'should show new added container diff state' , async ( ) => {
114+ // mocks title
115+ axiosMock . onGet ( getLibraryContainerApiUrl ( mockGetContainerMetadata . sectionId ) ) . reply ( 200 , { publishedDisplayName : 'Test Title' } ) ;
116+ axiosMock . onGet (
117+ getLibraryContainerApiUrl ( 'lct:org1:Demo_course_generated:subsection:subsection-0' ) ,
118+ ) . reply ( 200 , { publishedDisplayName : 'subsection block 0' } ) ;
119+
120+ const user = userEvent . setup ( ) ;
121+ render ( < CompareContainersWidget
122+ upstreamBlockId = { mockGetContainerMetadata . sectionId }
123+ downstreamBlockId = "block-v1:UNIX+UX1+2025_T3+type@section+block@0-new"
124+ /> ) ;
125+ const blocks = await screen . findAllByText ( 'This subsection will be added in the new version' ) ;
126+ await user . click ( blocks [ 0 ] ) ;
127+
128+ screen . logTestingPlaygroundURL ( ) ;
129+ expect ( await screen . findByText ( / t h i s s u b s e c t i o n i s n e w / i) ) . toBeInTheDocument ( ) ;
130+ } ) ;
131+
90132 test ( 'should show alert if the only change is a single text component with local overrides' , async ( ) => {
91133 const url = getLibraryContainerApiUrl ( mockGetContainerMetadata . sectionId ) ;
92134 axiosMock . onGet ( url ) . reply ( 200 , { publishedDisplayName : 'Test Title' } ) ;
0 commit comments