@@ -60,6 +60,7 @@ describe("Organizations TeamsBookings Endpoints 2024-08-13", () => {
6060 let teamUser2 : User ;
6161
6262 let team1EventTypeId : number ;
63+ let bookingUid : string ;
6364
6465 beforeAll ( async ( ) => {
6566 const moduleRef = await withApiAuth (
@@ -237,6 +238,7 @@ describe("Organizations TeamsBookings Endpoints 2024-08-13", () => {
237238 const data : BookingOutput_2024_08_13 = responseBody . data ;
238239 expect ( data . id ) . toBeDefined ( ) ;
239240 expect ( data . uid ) . toBeDefined ( ) ;
241+ bookingUid = data . uid ;
240242 expect ( data . hosts . length ) . toEqual ( 1 ) ;
241243 expect ( data . hosts [ 0 ] . id ) . toEqual ( teamUser . id ) ;
242244 expect ( data . status ) . toEqual ( "accepted" ) ;
@@ -308,6 +310,27 @@ describe("Organizations TeamsBookings Endpoints 2024-08-13", () => {
308310 } ) ;
309311 } ) ;
310312
313+ it ( "should get bookings by teamId and bookingUid" , async ( ) => {
314+ return request ( app . getHttpServer ( ) )
315+ . get ( `/v2/organizations/${ organization . id } /teams/${ team1 . id } /bookings?bookingUid=${ bookingUid } ` )
316+ . set ( CAL_API_VERSION_HEADER , VERSION_2024_08_13 )
317+ . set ( X_CAL_CLIENT_ID , oAuthClient . id )
318+ . set ( X_CAL_SECRET_KEY , oAuthClient . secret )
319+ . expect ( 200 )
320+ . then ( async ( response ) => {
321+ const responseBody : GetBookingsOutput_2024_08_13 = response . body ;
322+ expect ( responseBody . status ) . toEqual ( SUCCESS_STATUS ) ;
323+ expect ( responseBody . data ) . toBeDefined ( ) ;
324+ const data : (
325+ | BookingOutput_2024_08_13
326+ | RecurringBookingOutput_2024_08_13
327+ | GetSeatedBookingOutput_2024_08_13
328+ ) [ ] = responseBody . data ;
329+ expect ( data . length ) . toEqual ( 1 ) ;
330+ expect ( data [ 0 ] . uid ) . toEqual ( bookingUid ) ;
331+ } ) ;
332+ } ) ;
333+
311334 it ( "should not get bookings by teamId and non existing eventTypeId" , async ( ) => {
312335 return request ( app . getHttpServer ( ) )
313336 . get ( `/v2/organizations/${ organization . id } /teams/${ team1 . id } /bookings?eventTypeId=90909` )
@@ -336,8 +359,8 @@ describe("Organizations TeamsBookings Endpoints 2024-08-13", () => {
336359 return client ;
337360 }
338361
339- function responseDataIsBooking ( data : any ) : data is BookingOutput_2024_08_13 {
340- return ! Array . isArray ( data ) && typeof data === "object" && data && "id" in data ;
362+ function responseDataIsBooking ( data : unknown ) : data is BookingOutput_2024_08_13 {
363+ return ! Array . isArray ( data ) && typeof data === "object" && data !== null && "id" in data ;
341364 }
342365
343366 afterAll ( async ( ) => {
0 commit comments