@@ -76,11 +76,16 @@ describe('<CourseLibraries />', () => {
7676
7777 it ( 'shows alert when out of sync components are present' , async ( ) => {
7878 await renderCourseLibrariesPage ( mockGetEntityLinks . courseKey ) ;
79+ const allTab = await screen . findByRole ( 'tab' , { name : 'Libraries' } ) ;
80+ const reviewTab = await screen . findByRole ( 'tab' , { name : 'Review Content Updates 5' } ) ;
81+ // review tab should be open by default as outOfSyncCount is greater than 0
82+ expect ( reviewTab ) . toHaveAttribute ( 'aria-selected' , 'true' ) ;
83+
84+ userEvent . click ( allTab ) ;
7985 const alert = await screen . findByRole ( 'alert' ) ;
8086 expect ( await within ( alert ) . findByText (
8187 '5 library components are out of sync. Review updates to accept or ignore changes' ,
8288 ) ) . toBeInTheDocument ( ) ;
83- const allTab = await screen . findByRole ( 'tab' , { name : 'Libraries' } ) ;
8489 expect ( allTab ) . toHaveAttribute ( 'aria-selected' , 'true' ) ;
8590
8691 const reviewBtn = await screen . findByRole ( 'button' , { name : 'Review' } ) ;
@@ -89,31 +94,29 @@ describe('<CourseLibraries />', () => {
8994 expect ( allTab ) . toHaveAttribute ( 'aria-selected' , 'false' ) ;
9095 expect ( await screen . findByRole ( 'tab' , { name : 'Review Content Updates 5' } ) ) . toHaveAttribute ( 'aria-selected' , 'true' ) ;
9196 expect ( alert ) . not . toBeInTheDocument ( ) ;
92-
93- // go back to all tab
94- userEvent . click ( allTab ) ;
95- // alert should not be back
96- expect ( alert ) . not . toBeInTheDocument ( ) ;
97- expect ( allTab ) . toHaveAttribute ( 'aria-selected' , 'true' ) ;
98-
99- // review updates button
100- const reviewActionBtn = await screen . findByRole ( 'button' , { name : 'Review Updates' } ) ;
101- userEvent . click ( reviewActionBtn ) ;
102- expect ( await screen . findByRole ( 'tab' , { name : 'Review Content Updates 5' } ) ) . toHaveAttribute ( 'aria-selected' , 'true' ) ;
10397 } ) ;
10498
10599 it ( 'hide alert on dismiss' , async ( ) => {
106100 await renderCourseLibrariesPage ( mockGetEntityLinks . courseKey ) ;
101+ const reviewTab = await screen . findByRole ( 'tab' , { name : 'Review Content Updates 5' } ) ;
102+ // review tab should be open by default as outOfSyncCount is greater than 0
103+ expect ( reviewTab ) . toHaveAttribute ( 'aria-selected' , 'true' ) ;
104+ const allTab = await screen . findByRole ( 'tab' , { name : 'Libraries' } ) ;
105+ userEvent . click ( allTab ) ;
106+ expect ( allTab ) . toHaveAttribute ( 'aria-selected' , 'true' ) ;
107+
107108 const alert = await screen . findByRole ( 'alert' ) ;
108109 expect ( await within ( alert ) . findByText (
109110 '5 library components are out of sync. Review updates to accept or ignore changes' ,
110111 ) ) . toBeInTheDocument ( ) ;
111112 const dismissBtn = await screen . findByRole ( 'button' , { name : 'Dismiss' } ) ;
112113 userEvent . click ( dismissBtn ) ;
113- const allTab = await screen . findByRole ( 'tab' , { name : 'Libraries' } ) ;
114114 expect ( allTab ) . toHaveAttribute ( 'aria-selected' , 'true' ) ;
115-
116- expect ( alert ) . not . toBeInTheDocument ( ) ;
115+ waitFor ( ( ) => expect ( alert ) . not . toBeInTheDocument ( ) ) ;
116+ // review updates button
117+ const reviewActionBtn = await screen . findByRole ( 'button' , { name : 'Review Updates' } ) ;
118+ userEvent . click ( reviewActionBtn ) ;
119+ expect ( await screen . findByRole ( 'tab' , { name : 'Review Content Updates 5' } ) ) . toHaveAttribute ( 'aria-selected' , 'true' ) ;
117120 } ) ;
118121} ) ;
119122
0 commit comments