Skip to content

Commit 9d48145

Browse files
authored
cleanup(test): remove team bookings handler integration coverage (calcom#29017)
1 parent 84815a9 commit 9d48145

1 file changed

Lines changed: 5 additions & 80 deletions

File tree

packages/trpc/server/routers/viewer/bookings/get.handler.integration-test.ts

Lines changed: 5 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
import prisma from "@calcom/prisma";
22
import kysely from "@calcom/kysely";
3-
import type { Booking, EventType, Team, User } from "@calcom/prisma/client";
4-
import { BookingStatus, MembershipRole } from "@calcom/prisma/enums";
3+
import type { Booking, EventType, User } from "@calcom/prisma/client";
4+
import { BookingStatus } from "@calcom/prisma/enums";
55
import { afterAll, beforeAll, describe, expect, it } from "vitest";
66
import { getBookings } from "./get.handler";
77

88
let user1: User;
99
let user2: User;
10-
let team1: Team;
1110
let eventType1: EventType;
1211
let booking1: Booking;
1312
let booking2: Booking;
1413
let booking3: Booking;
15-
let booking4: Booking;
16-
let teamEventType: EventType;
1714

1815
const timestamp = Date.now();
1916

@@ -35,29 +32,6 @@ describe("getBookings - integration", () => {
3532
},
3633
});
3734

38-
team1 = await prisma.team.create({
39-
data: {
40-
name: `GetBookings Team ${timestamp}`,
41-
slug: `getbookings-team-${timestamp}`,
42-
members: {
43-
create: {
44-
userId: user1.id,
45-
role: MembershipRole.ADMIN,
46-
accepted: true,
47-
},
48-
},
49-
},
50-
});
51-
52-
await prisma.membership.create({
53-
data: {
54-
userId: user2.id,
55-
teamId: team1.id,
56-
role: MembershipRole.MEMBER,
57-
accepted: true,
58-
},
59-
});
60-
6135
eventType1 = await prisma.eventType.create({
6236
data: {
6337
title: `GetBookings Event ${timestamp}`,
@@ -127,52 +101,19 @@ describe("getBookings - integration", () => {
127101
},
128102
},
129103
});
130-
131-
teamEventType = await prisma.eventType.create({
132-
data: {
133-
title: `GetBookings Team Event ${timestamp}`,
134-
slug: `getbookings-team-event-${timestamp}`,
135-
length: 30,
136-
teamId: team1.id,
137-
},
138-
});
139-
140-
const futureDate4 = new Date(Date.now() + 10 * 24 * 60 * 60 * 1000);
141-
booking4 = await prisma.booking.create({
142-
data: {
143-
uid: `getbookings-booking4-${timestamp}`,
144-
title: "Team Booking - multi branch",
145-
startTime: futureDate4,
146-
endTime: new Date(futureDate4.getTime() + 30 * 60 * 1000),
147-
userId: user1.id,
148-
eventTypeId: teamEventType.id,
149-
status: BookingStatus.ACCEPTED,
150-
attendees: {
151-
create: {
152-
email: user1.email,
153-
name: user1.name ?? "User 1",
154-
timeZone: "UTC",
155-
},
156-
},
157-
},
158-
});
159104
});
160105

161106
afterAll(async () => {
162107
try {
163-
const bookingIds = [booking1?.id, booking2?.id, booking3?.id, booking4?.id].filter(Boolean);
108+
const bookingIds = [booking1?.id, booking2?.id, booking3?.id].filter(Boolean);
164109
if (bookingIds.length > 0) {
165110
await prisma.attendee.deleteMany({ where: { bookingId: { in: bookingIds } } });
166111
await prisma.booking.deleteMany({ where: { id: { in: bookingIds } } });
167112
}
168-
const eventTypeIds = [eventType1?.id, teamEventType?.id].filter(Boolean);
113+
const eventTypeIds = [eventType1?.id].filter(Boolean);
169114
if (eventTypeIds.length > 0) {
170115
await prisma.eventType.deleteMany({ where: { id: { in: eventTypeIds } } });
171116
}
172-
const teamIds = [team1?.id].filter(Boolean);
173-
if (teamIds.length > 0) {
174-
await prisma.team.deleteMany({ where: { id: { in: teamIds } } });
175-
}
176117
const userIds = [user1?.id, user2?.id].filter(Boolean);
177118
if (userIds.length > 0) {
178119
await prisma.user.deleteMany({ where: { id: { in: userIds } } });
@@ -242,30 +183,14 @@ describe("getBookings - integration", () => {
242183
skip: 0,
243184
});
244185

245-
const expectedBookingIds = [booking1.id, booking2.id, booking3.id, booking4.id];
186+
const expectedBookingIds = [booking1.id, booking2.id, booking3.id];
246187
const returnedIds = resultUser1.bookings.map((b) => b.id);
247188
for (const id of expectedBookingIds) {
248189
expect(returnedIds).toContain(id);
249190
}
250191
expect(resultUser1.totalCount).toBe(resultUser1.bookings.length);
251192
});
252193

253-
it("should count booking4 exactly once in totalCount even though it matches multiple union branches", async () => {
254-
const result = await getBookings({
255-
user: { id: user1.id, email: user1.email, orgId: null },
256-
prisma,
257-
kysely,
258-
bookingListingByStatus: ["upcoming"],
259-
filters: {},
260-
take: 50,
261-
skip: 0,
262-
});
263-
264-
const booking4Occurrences = result.bookings.filter((b) => b.id === booking4.id);
265-
expect(booking4Occurrences).toHaveLength(1);
266-
expect(result.totalCount).toBe(result.bookings.length);
267-
});
268-
269194
it("should respect pagination with correct ordering", async () => {
270195
const page1 = await getBookings({
271196
user: { id: user1.id, email: user1.email, orgId: null },

0 commit comments

Comments
 (0)