66 render ,
77 screen ,
88 waitFor ,
9+ within ,
910} from '@src/testUtils' ;
1011import studioHomeMock from '@src/studio-home/__mocks__/studioHomeMock' ;
1112import { mockGetContentLibraryV2List } from '@src/library-authoring/data/api.mocks' ;
@@ -184,7 +185,7 @@ describe('<LegacyLibMigrationPage />', () => {
184185 nextButton . click ( ) ;
185186
186187 // Should show alert of SelectDestinationView
187- expect ( await screen . findByText ( / a n y l e g a c y l i b r a r i e s t h a t a r e u s e d / i) ) . toBeInTheDocument ( ) ;
188+ expect ( await screen . findByText ( / y o u s e l e c t e d w i l l b e m i g r a t e d t o t h i s n e w l i b r a r y / i) ) . toBeInTheDocument ( ) ;
188189
189190 const backButton = screen . getByRole ( 'button' , { name : / b a c k / i } ) ;
190191 backButton . click ( ) ;
@@ -210,7 +211,7 @@ describe('<LegacyLibMigrationPage />', () => {
210211 nextButton . click ( ) ;
211212
212213 // Should show alert of SelectDestinationView
213- expect ( await screen . findByText ( / a n y l e g a c y l i b r a r i e s t h a t a r e u s e d / i) ) . toBeInTheDocument ( ) ;
214+ expect ( await screen . findByText ( / y o u s e l e c t e d w i l l b e m i g r a t e d t o t h i s n e w l i b r a r y / i) ) . toBeInTheDocument ( ) ;
214215
215216 // The next button is disabled
216217 expect ( nextButton ) . toBeDisabled ( ) ;
@@ -224,24 +225,31 @@ describe('<LegacyLibMigrationPage />', () => {
224225 } ) ;
225226
226227 it ( 'should back to select library destination' , async ( ) => {
228+ const user = userEvent . setup ( ) ;
227229 renderPage ( ) ;
228230 expect ( await screen . findByText ( 'Migrate Legacy Libraries' ) ) . toBeInTheDocument ( ) ;
229231 expect ( await screen . findByText ( 'MBA' ) ) . toBeInTheDocument ( ) ;
230232
231233 const legacyLibrary = screen . getByRole ( 'checkbox' , { name : 'MBA' } ) ;
232- legacyLibrary . click ( ) ;
234+ await user . click ( legacyLibrary ) ;
233235
234- const nextButton = screen . getByRole ( 'button' , { name : / n e x t / i } ) ;
235- nextButton . click ( ) ;
236+ const nextButton = await screen . findByRole ( 'button' , { name : / n e x t / i } ) ;
237+ await user . click ( nextButton ) ;
236238
237239 // Should show alert of SelectDestinationView
238- expect ( await screen . findByText ( / a n y l e g a c y l i b r a r i e s t h a t a r e u s e d / i) ) . toBeInTheDocument ( ) ;
240+ expect ( await screen . findByText ( / y o u s e l e c t e d w i l l b e m i g r a t e d t o t h i s n e w l i b r a r y / i) ) . toBeInTheDocument ( ) ;
239241 expect ( await screen . findByText ( 'Test Library 1' ) ) . toBeInTheDocument ( ) ;
240242 const radioButton = screen . getByRole ( 'radio' , { name : / t e s t l i b r a r y 1 / i } ) ;
241- radioButton . click ( ) ;
243+ await user . click ( radioButton ) ;
242244
243- nextButton . click ( ) ;
244- expect ( await screen . findByText ( / t h e s e 1 l e g a c y l i b r a r y w i l l b e m i g r a t e d t o / i) ) . toBeInTheDocument ( ) ;
245+ await user . click ( nextButton ) ;
246+ const alert = await screen . findByRole ( 'alert' ) ;
247+ expect ( await within ( alert ) . findByText (
248+ / A l l c o n t e n t f r o m t h e 1 l e g a c y l i b r a r y y o u s e l e c t e d w i l l b e m i g r a t e d t o / i,
249+ ) ) . toBeInTheDocument ( ) ;
250+ expect ( await within ( alert ) . findByText (
251+ / t e s t l i b r a r y 1 / i,
252+ ) ) . toBeInTheDocument ( ) ;
245253
246254 const backButton = screen . getByRole ( 'button' , { name : / b a c k / i } ) ;
247255 backButton . click ( ) ;
@@ -269,7 +277,7 @@ describe('<LegacyLibMigrationPage />', () => {
269277 nextButton . click ( ) ;
270278
271279 // Should show alert of SelectDestinationView
272- expect ( await screen . findByText ( / a n y l e g a c y l i b r a r i e s t h a t a r e u s e d / i) ) . toBeInTheDocument ( ) ;
280+ expect ( await screen . findByText ( / y o u s e l e c t e d w i l l b e m i g r a t e d t o t h i s n e w l i b r a r y / i) ) . toBeInTheDocument ( ) ;
273281
274282 const createButton = await screen . findByRole ( 'button' , { name : / c r e a t e n e w l i b r a r y / i } ) ;
275283 expect ( createButton ) . toBeInTheDocument ( ) ;
@@ -336,18 +344,24 @@ describe('<LegacyLibMigrationPage />', () => {
336344 legacyLibrary3 . click ( ) ;
337345
338346 const nextButton = screen . getByRole ( 'button' , { name : / n e x t / i } ) ;
339- nextButton . click ( ) ;
347+ await user . click ( nextButton ) ;
340348
341349 // Should show alert of SelectDestinationView
342- expect ( await screen . findByText ( / a n y l e g a c y l i b r a r i e s t h a t a r e u s e d / i) ) . toBeInTheDocument ( ) ;
350+ expect ( await screen . findByText ( / y o u s e l e c t e d w i l l b e m i g r a t e d t o t h i s n e w l i b r a r y / i) ) . toBeInTheDocument ( ) ;
343351 expect ( await screen . findByText ( 'Test Library 1' ) ) . toBeInTheDocument ( ) ;
344352 const radioButton = screen . getByRole ( 'radio' , { name : / t e s t l i b r a r y 1 / i } ) ;
345- radioButton . click ( ) ;
353+ await user . click ( radioButton ) ;
346354
347- nextButton . click ( ) ;
355+ await user . click ( nextButton ) ;
348356
349357 // Should show alert of ConfirmationView
350- expect ( await screen . findByText ( / t h e s e 3 l e g a c y l i b r a r i e s w i l l b e m i g r a t e d t o / i) ) . toBeInTheDocument ( ) ;
358+ const alert = await screen . findByRole ( 'alert' ) ;
359+ expect ( await within ( alert ) . findByText (
360+ / A l l c o n t e n t f r o m t h e 3 l e g a c y l i b r a r i e s y o u s e l e c t e d w i l l b e m i g r a t e d t o / i,
361+ ) ) . toBeInTheDocument ( ) ;
362+ expect ( await within ( alert ) . findByText (
363+ / t e s t l i b r a r y 1 / i,
364+ ) ) . toBeInTheDocument ( ) ;
351365 expect ( screen . getByText ( 'MBA' ) ) . toBeInTheDocument ( ) ;
352366 expect ( screen . getByText ( 'Legacy library 1' ) ) . toBeInTheDocument ( ) ;
353367 expect ( screen . getByText ( 'MBA 1' ) ) . toBeInTheDocument ( ) ;
@@ -390,18 +404,26 @@ describe('<LegacyLibMigrationPage />', () => {
390404 legacyLibrary3 . click ( ) ;
391405
392406 const nextButton = screen . getByRole ( 'button' , { name : / n e x t / i } ) ;
393- nextButton . click ( ) ;
407+ await user . click ( nextButton ) ;
394408
395409 // Should show alert of SelectDestinationView
396- expect ( await screen . findByText ( / a n y l e g a c y l i b r a r i e s t h a t a r e u s e d / i) ) . toBeInTheDocument ( ) ;
410+ expect ( await screen . findByText ( / y o u s e l e c t e d w i l l b e m i g r a t e d t o t h i s n e w l i b r a r y / i) ) . toBeInTheDocument ( ) ;
397411 expect ( await screen . findByText ( 'Test Library 1' ) ) . toBeInTheDocument ( ) ;
398412 const radioButton = screen . getByRole ( 'radio' , { name : / t e s t l i b r a r y 1 / i } ) ;
399- radioButton . click ( ) ;
413+ await user . click ( radioButton ) ;
400414
401- nextButton . click ( ) ;
415+ await user . click ( nextButton ) ;
402416
403417 // Should show alert of ConfirmationView
404- expect ( await screen . findByText ( / t h e s e 3 l e g a c y l i b r a r i e s w i l l b e m i g r a t e d t o / i) ) . toBeInTheDocument ( ) ;
418+ const alert = await screen . findByRole ( 'alert' ) ;
419+ expect ( await within ( alert ) . findByText (
420+ / A l l c o n t e n t f r o m t h e 3 l e g a c y l i b r a r i e s y o u s e l e c t e d w i l l b e m i g r a t e d t o / i,
421+ { exact : false } ,
422+ ) ) . toBeInTheDocument ( ) ;
423+ expect ( await within ( alert ) . findByText (
424+ / t e s t l i b r a r y 1 / i,
425+ { exact : false } ,
426+ ) ) . toBeInTheDocument ( ) ;
405427 expect ( screen . getByText ( 'MBA' ) ) . toBeInTheDocument ( ) ;
406428 expect ( screen . getByText ( 'Legacy library 1' ) ) . toBeInTheDocument ( ) ;
407429 expect ( screen . getByText ( 'MBA 1' ) ) . toBeInTheDocument ( ) ;
0 commit comments