Skip to content

Commit 81a99ea

Browse files
authored
chore: add bookingUid filter to get org teams booking endpoint (calcom#24960)
* chore: add bookingUid filter to get org teams booking input * chore: update tests
1 parent 799e354 commit 81a99ea

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

apps/api/v2/src/modules/organizations/teams/bookings/inputs/get-organizations-teams-bookings.input.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@ export class GetOrganizationsTeamsBookingsInput_2024_08_13 {
7373
})
7474
attendeeName?: string;
7575

76+
@IsString()
77+
@IsOptional()
78+
@ApiProperty({
79+
type: String,
80+
required: false,
81+
description: "Filter bookings by the booking Uid.",
82+
example: "2NtaeaVcKfpmSZ4CthFdfk",
83+
})
84+
bookingUid?: string;
85+
7686
@IsOptional()
7787
@Transform(({ value }) => {
7888
if (typeof value === "string") {

apps/api/v2/src/modules/organizations/teams/bookings/organizations-teams-bookings.controller.e2e-spec.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)