Scheduling infrastructure for absolutely everyone.
chore: add `bookingUid` filter to get org teams booking endpoint (#24960)
Rajiv Sahal81a99ea0b256
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.tsindex 423fdffc523..b344a255fae 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.tsindex f88b9f0bf52..2e17ed90e4c 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 () => {