@@ -368,10 +368,11 @@ test.describe("Bookings", () => {
368368 ) ;
369369 } ) ;
370370
371- test ( "Round robin event type with confirmation required handles cancellation and rebooking correctly with the same details and slot" , async ( {
371+ test ( "Round robin event type with confirmation required handles rejection and rebooking correctly with the same details and slot" , async ( {
372372 page,
373373 users,
374374 orgs,
375+ browser,
375376 } ) => {
376377 const org = await orgs . create ( {
377378 name : "TestOrg" ,
@@ -421,38 +422,41 @@ test.describe("Bookings", () => {
421422 const bookingUid = page . url ( ) . split ( "/booking/" ) [ 1 ] ;
422423 expect ( bookingUid ) . not . toBeNull ( ) ;
423424
424- // Login as the host to cancel the booking
425425 await page . goto ( "/auth/logout" ) ;
426- const allUsers = await users . get ( ) ;
426+
427+ const allUsers = users . get ( ) ;
427428 const hostUser = allUsers . find ( ( mate ) => mate . name === firstHost ) ;
428429 if ( ! hostUser ) throw new Error ( "Host not found" ) ;
429430
430431 await hostUser . apiLogin ( ) ;
432+ const [ secondContext , secondPage ] = await hostUser . apiLoginOnNewBrowser ( browser ) ;
431433
432- // Cancel the booking
433- await page . goto ( `/booking/${ bookingUid } ` ) ;
434- await page . getByTestId ( "cancel" ) . click ( ) ;
435- await page . getByTestId ( "confirm_cancel" ) . click ( ) ;
436- await page . waitForResponse ( ( response ) => response . url ( ) . includes ( "/api/cancel" ) ) ;
434+ // Reject the booking
435+ await secondPage . goto ( "/bookings/upcoming" ) ;
436+ await secondPage . click ( '[data-testid="reject"]' ) ;
437+ await submitAndWaitForResponse ( secondPage , "/api/trpc/bookings/confirm?batch=1" , {
438+ action : ( ) => secondPage . click ( '[data-testid="rejection-confirm"]' ) ,
439+ } ) ;
437440
438441 // Logout and go back to booking page
439- await page . goto ( "/auth/logout" ) ;
440- await page . goto ( `/org/${ org . slug } /${ team . slug } /${ teamEvent . slug } ` ) ;
442+ await secondPage . goto ( "/auth/logout" ) ;
443+ await secondPage . goto ( `/org/${ org . slug } /${ team . slug } /${ teamEvent . slug } ` ) ;
441444
442445 // Rebook with the same details
443- await selectFirstAvailableTimeSlotNextMonth ( page ) ;
444- await bookTimeSlot ( page ) ;
445- await expect ( page . getByTestId ( "success-page" ) ) . toBeVisible ( ) ;
446+ await selectFirstAvailableTimeSlotNextMonth ( secondPage ) ;
447+ await bookTimeSlot ( secondPage ) ;
448+ await expect ( secondPage . getByTestId ( "success-page" ) ) . toBeVisible ( ) ;
446449
447450 // Verify a new host is assigned
448- const newHost = await page . getByTestId ( "booking-host-name" ) . textContent ( ) ;
451+ const newHost = await secondPage . getByTestId ( "booking-host-name" ) . textContent ( ) ;
449452 expect ( newHost ) . not . toBeNull ( ) ;
450453 expect ( newHost ) . toBe ( firstHost ) ;
451454
452455 // Verify the booking was successful by checking the new booking UID
453- const newBookingUid = page . url ( ) . split ( "/booking/" ) [ 1 ] ;
456+ const newBookingUid = secondPage . url ( ) . split ( "/booking/" ) [ 1 ] ;
454457 expect ( newBookingUid ) . not . toBeNull ( ) ;
455458 expect ( newBookingUid ) . not . toBe ( bookingUid ) ;
459+ await secondContext . close ( ) ;
456460 }
457461 ) ;
458462 } ) ;
0 commit comments