Skip to content

Commit d30d279

Browse files
weknowyourgamekart1kasupalarry
authored
fix: hide notes (calcom#22061)
* fix: hide notes * test: re-enable confirmHandler tests and add tests for hide notes fix * fix: replace deprecated getDate with hardcoded dates for timezone safety * fix: hide notes test * refactor: move test from trpc to web package --------- Co-authored-by: Kartik Saini <41051387+kart1ka@users.noreply.github.com> Co-authored-by: supalarry <laurisskraucis@gmail.com> Co-authored-by: Lauris Skraucis <lauris.skraucis@gmail.com>
1 parent ba50268 commit d30d279

3 files changed

Lines changed: 115 additions & 1 deletion

File tree

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import {
2+
createBookingScenario,
3+
getOrganizer,
4+
getScenarioData,
5+
TestData,
6+
mockSuccessfulVideoMeetingCreation,
7+
} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
8+
9+
import { describe, it, beforeEach, vi, expect } from "vitest";
10+
11+
import * as handleConfirmationModule from "@calcom/features/bookings/lib/handleConfirmation";
12+
import { BookingStatus } from "@calcom/prisma/enums";
13+
import type { TrpcSessionUser } from "@calcom/trpc/server/types";
14+
import { confirmHandler } from "@calcom/trpc/server/routers/viewer/bookings/confirm.handler";
15+
16+
describe("confirmHandler", () => {
17+
beforeEach(() => {
18+
vi.clearAllMocks();
19+
});
20+
21+
it("should pass hideCalendarNotes property to CalendarEvent when enabled", async () => {
22+
vi.setSystemTime("2050-01-07T00:00:00Z");
23+
24+
const handleConfirmationSpy = vi.spyOn(handleConfirmationModule, "handleConfirmation");
25+
26+
const attendeeUser = getOrganizer({
27+
email: "test@example.com",
28+
name: "test name",
29+
id: 102,
30+
schedules: [TestData.schedules.IstWorkHours],
31+
});
32+
33+
const organizer = getOrganizer({
34+
name: "Organizer",
35+
email: "organizer@example.com",
36+
id: 101,
37+
schedules: [TestData.schedules.IstWorkHours],
38+
});
39+
40+
const uidOfBooking = "hideNotes123";
41+
const iCalUID = `${uidOfBooking}@Cal.com`;
42+
43+
const plus1DateString = "2050-01-08";
44+
45+
await createBookingScenario(
46+
getScenarioData({
47+
eventTypes: [
48+
{
49+
id: 1,
50+
slotInterval: 15,
51+
length: 15,
52+
locations: [],
53+
hideCalendarNotes: true,
54+
hideCalendarEventDetails: true,
55+
requiresConfirmation: true,
56+
users: [
57+
{
58+
id: 101,
59+
},
60+
],
61+
},
62+
],
63+
bookings: [
64+
{
65+
id: 101,
66+
uid: uidOfBooking,
67+
eventTypeId: 1,
68+
status: BookingStatus.PENDING,
69+
startTime: `${plus1DateString}T05:00:00.000Z`,
70+
endTime: `${plus1DateString}T05:15:00.000Z`,
71+
references: [],
72+
iCalUID,
73+
location: "integrations:daily",
74+
attendees: [attendeeUser],
75+
responses: { name: attendeeUser.name, email: attendeeUser.email, notes: "Sensitive information" },
76+
},
77+
],
78+
organizer,
79+
apps: [TestData.apps["daily-video"]],
80+
})
81+
);
82+
83+
mockSuccessfulVideoMeetingCreation({
84+
metadataLookupKey: "dailyvideo",
85+
});
86+
87+
const ctx = {
88+
user: {
89+
id: organizer.id,
90+
name: organizer.name,
91+
timeZone: organizer.timeZone,
92+
username: organizer.username,
93+
} as NonNullable<TrpcSessionUser>,
94+
};
95+
96+
const res = await confirmHandler({
97+
ctx,
98+
input: { bookingId: 101, confirmed: true, reason: "", emailsEnabled: true },
99+
});
100+
101+
expect(res?.status).toBe(BookingStatus.ACCEPTED);
102+
expect(handleConfirmationSpy).toHaveBeenCalledTimes(1);
103+
104+
const handleConfirmationCall = handleConfirmationSpy.mock.calls[0][0];
105+
const calendarEvent = handleConfirmationCall.evt;
106+
107+
expect(calendarEvent.hideCalendarNotes).toBe(true);
108+
expect(calendarEvent.hideCalendarEventDetails).toBe(true);
109+
});
110+
});

packages/trpc/server/routers/viewer/bookings/confirm.handler.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,4 +200,4 @@ describe.skip("confirmHandler", () => {
200200
expect(res?.status).toBe(BookingStatus.REJECTED);
201201
expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails });
202202
});
203-
});
203+
});

packages/trpc/server/routers/viewer/bookings/confirm.handler.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ export const confirmHandler = async ({ ctx, input }: ConfirmOptions) => {
8585
price: true,
8686
bookingFields: true,
8787
hideOrganizerEmail: true,
88+
hideCalendarNotes: true,
89+
hideCalendarEventDetails: true,
8890
disableGuests: true,
8991
customReplyToEmail: true,
9092
metadata: true,
@@ -233,6 +235,8 @@ export const confirmHandler = async ({ ctx, input }: ConfirmOptions) => {
233235
: [],
234236
requiresConfirmation: booking?.eventType?.requiresConfirmation ?? false,
235237
hideOrganizerEmail: booking.eventType?.hideOrganizerEmail,
238+
hideCalendarNotes: booking.eventType?.hideCalendarNotes,
239+
hideCalendarEventDetails: booking.eventType?.hideCalendarEventDetails,
236240
eventTypeId: booking.eventType?.id,
237241
customReplyToEmail: booking.eventType?.customReplyToEmail,
238242
team: !!booking.eventType?.team

0 commit comments

Comments
 (0)