From 81a99ea0b2567a01c48f7cd503fc6b3727b66a68 Mon Sep 17 00:00:00 2001 From: Rajiv Sahal Date: Fri, 7 Nov 2025 17:52:45 +0000 Subject: [PATCH] chore: add `bookingUid` filter to get org teams booking endpoint (#24960) * chore: add bookingUid filter to get org teams booking input * chore: update tests --- .../get-organizations-teams-bookings.input.ts | 10 +++++++ ...ions-teams-bookings.controller.e2e-spec.ts | 27 +++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/apps/api/v2/src/modules/organizations/teams/bookings/inputs/get-organizations-teams-bookings.input.ts b/apps/api/v2/src/modules/organizations/teams/bookings/inputs/get-organizations-teams-bookings.input.ts index 423fdffc52..b344a255fa 100644 --- a/apps/api/v2/src/modules/organizations/teams/bookings/inputs/get-organizations-teams-bookings.input.ts +++ b/apps/api/v2/src/modules/organizations/teams/bookings/inputs/get-organizations-teams-bookings.input.ts @@ -73,6 +73,16 @@ export class GetOrganizationsTeamsBookingsInput_2024_08_13 { }) attendeeName?: string; + @IsString() + @IsOptional() + @ApiProperty({ + type: String, + required: false, + description: "Filter bookings by the booking Uid.", + example: "2NtaeaVcKfpmSZ4CthFdfk", + }) + bookingUid?: string; + @IsOptional() @Transform(({ value }) => { if (typeof value === "string") { diff --git a/apps/api/v2/src/modules/organizations/teams/bookings/organizations-teams-bookings.controller.e2e-spec.ts b/apps/api/v2/src/modules/organizations/teams/bookings/organizations-teams-bookings.controller.e2e-spec.ts index f88b9f0bf5..2e17ed90e4 100644 --- a/apps/api/v2/src/modules/organizations/teams/bookings/organizations-teams-bookings.controller.e2e-spec.ts +++ b/apps/api/v2/src/modules/organizations/teams/bookings/organizations-teams-bookings.controller.e2e-spec.ts @@ -60,6 +60,7 @@ describe("Organizations TeamsBookings Endpoints 2024-08-13", () => { let teamUser2: User; let team1EventTypeId: number; + let bookingUid: string; beforeAll(async () => { const moduleRef = await withApiAuth( @@ -237,6 +238,7 @@ describe("Organizations TeamsBookings Endpoints 2024-08-13", () => { const data: BookingOutput_2024_08_13 = responseBody.data; expect(data.id).toBeDefined(); expect(data.uid).toBeDefined(); + bookingUid = data.uid; expect(data.hosts.length).toEqual(1); expect(data.hosts[0].id).toEqual(teamUser.id); expect(data.status).toEqual("accepted"); @@ -308,6 +310,27 @@ describe("Organizations TeamsBookings Endpoints 2024-08-13", () => { }); }); + it("should get bookings by teamId and bookingUid", async () => { + return request(app.getHttpServer()) + .get(`/v2/organizations/${organization.id}/teams/${team1.id}/bookings?bookingUid=${bookingUid}`) + .set(CAL_API_VERSION_HEADER, VERSION_2024_08_13) + .set(X_CAL_CLIENT_ID, oAuthClient.id) + .set(X_CAL_SECRET_KEY, oAuthClient.secret) + .expect(200) + .then(async (response) => { + const responseBody: GetBookingsOutput_2024_08_13 = response.body; + expect(responseBody.status).toEqual(SUCCESS_STATUS); + expect(responseBody.data).toBeDefined(); + const data: ( + | BookingOutput_2024_08_13 + | RecurringBookingOutput_2024_08_13 + | GetSeatedBookingOutput_2024_08_13 + )[] = responseBody.data; + expect(data.length).toEqual(1); + expect(data[0].uid).toEqual(bookingUid); + }); + }); + it("should not get bookings by teamId and non existing eventTypeId", async () => { return request(app.getHttpServer()) .get(`/v2/organizations/${organization.id}/teams/${team1.id}/bookings?eventTypeId=90909`) @@ -336,8 +359,8 @@ describe("Organizations TeamsBookings Endpoints 2024-08-13", () => { return client; } - function responseDataIsBooking(data: any): data is BookingOutput_2024_08_13 { - return !Array.isArray(data) && typeof data === "object" && data && "id" in data; + function responseDataIsBooking(data: unknown): data is BookingOutput_2024_08_13 { + return !Array.isArray(data) && typeof data === "object" && data !== null && "id" in data; } afterAll(async () => {