@@ -82,13 +82,23 @@ describe('<LegacyLibMigrationPage />', () => {
8282 } ) ;
8383
8484 it ( 'should select legacy libraries' , async ( ) => {
85+ const user = userEvent . setup ( ) ;
8586 renderPage ( ) ;
8687 expect ( await screen . findByText ( 'Migrate Legacy Libraries' ) ) . toBeInTheDocument ( ) ;
8788
8889 const nextButton = screen . getByRole ( 'button' , { name : / n e x t / i } ) ;
8990 // The next button is disabled
9091 expect ( nextButton ) . toBeDisabled ( ) ;
9192
93+ // The filter is Unmigrated by default
94+ const filterButton = await screen . findByRole ( 'button' , { name : / u n m i g r a t e d / i } ) ;
95+ expect ( filterButton ) . toBeInTheDocument ( ) ;
96+
97+ // Clear filter to show all
98+ await user . click ( filterButton ) ;
99+ const clearButton = await screen . findByRole ( 'button' , { name : / c l e a r f i l t e r / i } ) ;
100+ await user . click ( clearButton ) ;
101+
92102 expect ( await screen . findByText ( 'MBA' ) ) . toBeInTheDocument ( ) ;
93103 expect ( await screen . findByText ( 'Legacy library 1' ) ) . toBeInTheDocument ( ) ;
94104 expect ( await screen . findByText ( 'MBA 1' ) ) . toBeInTheDocument ( ) ;
@@ -116,6 +126,37 @@ describe('<LegacyLibMigrationPage />', () => {
116126 expect ( nextButton ) . not . toBeDisabled ( ) ;
117127 } ) ;
118128
129+ it ( 'should select all legacy libraries' , async ( ) => {
130+ const user = userEvent . setup ( ) ;
131+ renderPage ( ) ;
132+ expect ( await screen . findByText ( 'Migrate Legacy Libraries' ) ) . toBeInTheDocument ( ) ;
133+
134+ // The filter is Unmigrated by default
135+ const filterButton = await screen . findByRole ( 'button' , { name : / u n m i g r a t e d / i } ) ;
136+ expect ( filterButton ) . toBeInTheDocument ( ) ;
137+
138+ // Clear filter to show all
139+ await user . click ( filterButton ) ;
140+ const clearButton = await screen . findByRole ( 'button' , { name : / c l e a r f i l t e r / i } ) ;
141+ await user . click ( clearButton ) ;
142+
143+ const selectAll = screen . getByRole ( 'checkbox' , { name : / s e l e c t a l l / i } ) ;
144+ await user . click ( selectAll ) ;
145+
146+ const library1 = screen . getByRole ( 'checkbox' , { name : 'MBA' } ) ;
147+ const library2 = screen . getByRole ( 'checkbox' , { name : / l e g a c y l i b r a r y 1 i m p o r t e d l i b r a r y / i } ) ;
148+ const library3 = screen . getByRole ( 'checkbox' , { name : 'MBA 1' } ) ;
149+
150+ expect ( library1 ) . toBeChecked ( ) ;
151+ expect ( library2 ) . toBeChecked ( ) ;
152+ expect ( library3 ) . toBeChecked ( ) ;
153+
154+ await user . click ( selectAll ) ;
155+ expect ( library1 ) . not . toBeChecked ( ) ;
156+ expect ( library2 ) . not . toBeChecked ( ) ;
157+ expect ( library3 ) . not . toBeChecked ( ) ;
158+ } ) ;
159+
119160 it ( 'should back to select legacy libraries' , async ( ) => {
120161 renderPage ( ) ;
121162 expect ( await screen . findByText ( 'Migrate Legacy Libraries' ) ) . toBeInTheDocument ( ) ;
@@ -250,10 +291,18 @@ describe('<LegacyLibMigrationPage />', () => {
250291 } ) ;
251292
252293 it ( 'should confirm migration' , async ( ) => {
294+ const user = userEvent . setup ( ) ;
253295 renderPage ( ) ;
254296 expect ( await screen . findByText ( 'Migrate Legacy Libraries' ) ) . toBeInTheDocument ( ) ;
255297 expect ( await screen . findByText ( 'MBA' ) ) . toBeInTheDocument ( ) ;
256298
299+ // The filter is 'unmigrated' by default.
300+ // Clear the filter to select all libraries
301+ const filterButton = screen . getByRole ( 'button' , { name : / u n m i g r a t e d / i } ) ;
302+ await user . click ( filterButton ) ;
303+ const clearButton = await screen . findByRole ( 'button' , { name : / c l e a r f i l t e r / i } ) ;
304+ await user . click ( clearButton ) ;
305+
257306 const legacyLibrary1 = screen . getByRole ( 'checkbox' , { name : 'MBA' } ) ;
258307 const legacyLibrary2 = screen . getByRole ( 'checkbox' , { name : / l e g a c y l i b r a r y 1 i m p o r t e d l i b r a r y / i } ) ;
259308 const legacyLibrary3 = screen . getByRole ( 'checkbox' , { name : 'MBA 1' } ) ;
0 commit comments