@@ -71,25 +71,19 @@ const defaultProps = {
7171} ;
7272
7373type InitialState = {
74- sidebarOpen : boolean ,
7574 activeBlock ?: Block | null ,
7675 filterUnit ?: Block | null ,
7776 filteredBlocks ?: string [ ]
7877} ;
7978
8079// Helper component to set context values for tests
8180function TestContextHelper ( {
82- sidebarOpen = true , activeBlock = null , filterUnit = null , filteredBlocks = [ ] ,
81+ activeBlock = null , filterUnit = null , filteredBlocks = [ ] ,
8382} : InitialState ) {
8483 const {
85- setSidebarOpen , setActiveBlock, setFilterUnit, setFilteredBlocks,
84+ setActiveBlock, setFilterUnit, setFilteredBlocks,
8685 } = useAspectsSidebarContext ( ) ;
8786
88- // This effect is run only one to set the initial state for the tests.
89- React . useEffect ( ( ) => {
90- setSidebarOpen ( sidebarOpen ) ;
91- } , [ ] ) ; // eslint-disable-line react-hooks/exhaustive-deps
92-
9387 // The sidebar will clear active/filter stuff to render cleanly on initalization
9488 // So, we can't set these values in the useEffect above. The only way to cleanly
9589 // do it is by userEvent.click - simulating real-world scenario
@@ -109,7 +103,7 @@ function TestContextHelper({
109103
110104describe ( 'AspectsSidebar' , ( ) => {
111105 const renderComponent = (
112- initialState : InitialState = { sidebarOpen : true } ,
106+ initialState : InitialState = { } ,
113107 props ?: Partial < React . ComponentProps < typeof AspectsSidebar > > ,
114108 ) => render (
115109
@@ -126,19 +120,6 @@ describe('AspectsSidebar', () => {
126120 jest . clearAllMocks ( ) ;
127121 } ) ;
128122
129- it ( 'closes the sidebar when the close button is clicked' , async ( ) => {
130- renderComponent ( ) ;
131- // Ensure the sidebar is initially open and visible
132- expect ( screen . getByTestId ( 'sidebar' ) ) . toBeVisible ( ) ;
133- expect ( screen . getByTestId ( 'sidebar-title' ) ) . toHaveTextContent ( 'Test Course' ) ;
134-
135- const closeButton = screen . getByRole ( 'button' , { name : 'Close' } ) ;
136- fireEvent . click ( closeButton ) ;
137-
138- // Assert that the sidebar is no longer visible
139- expect ( screen . queryByTestId ( 'sidebar' ) ) . not . toBeInTheDocument ( ) ;
140- } ) ;
141-
142123 it ( 'shows the back button and changes the title when a block is clicked' , ( ) => {
143124 renderComponent ( ) ;
144125
@@ -168,7 +149,7 @@ describe('AspectsSidebar', () => {
168149
169150 it ( 'shows an Alert message when the content lists are empty on a Unit Page' , ( ) => {
170151 // NOTE: Currently there is not "Unit Page Dashboard", hence the alert
171- renderComponent ( { sidebarOpen : true } , { blockType : BlockTypes . vertical , contentLists : [ ] } ) ;
152+ renderComponent ( undefined , { blockType : BlockTypes . vertical , contentLists : [ ] } ) ;
172153
173154 expect ( mockDashboard ) . not . toHaveBeenCalled ( ) ;
174155 expect ( screen . getByRole ( 'alert' ) ) . toHaveTextContent ( messages . noAnalyticsForUnit . defaultMessage ) ;
@@ -177,7 +158,6 @@ describe('AspectsSidebar', () => {
177158 it ( 'shows filtered set of components in the Course Outline view when specific unit is selected' , ( ) => {
178159 // render the component as if the "UnitActionsButton" has been clicked
179160 renderComponent ( {
180- sidebarOpen : true ,
181161 activeBlock : mockUnit ,
182162 filterUnit : mockUnit ,
183163 filteredBlocks : [ 'block-v1:TEST+COURSE+SECTION1+prob2' ] ,
@@ -194,7 +174,6 @@ describe('AspectsSidebar', () => {
194174
195175 it ( 'navigate to component and back in filtered unit view' , ( ) => {
196176 renderComponent ( {
197- sidebarOpen : true ,
198177 activeBlock : mockUnit ,
199178 filterUnit : mockUnit ,
200179 filteredBlocks : [ 'block-v1:TEST+COURSE+SECTION1+prob2' ] ,
@@ -220,7 +199,7 @@ describe('AspectsSidebar', () => {
220199
221200 it ( 'posts a callback with the activatedBlock in Unit Page View' , ( ) => {
222201 const callback = jest . fn ( ) ;
223- renderComponent ( { sidebarOpen : true } , {
202+ renderComponent ( undefined , {
224203 title : 'Test Unit' ,
225204 blockType : BlockTypes . vertical ,
226205 contentLists : mockContentLists . slice ( 0 , 1 ) ,
0 commit comments