Skip to content

Scheduling infrastructure for absolutely everyone.

fix: hide notes (#22061)

Sarthak Kapilad30d2792cde7
diff --git a/apps/web/test/lib/confirm.handler.test.ts b/apps/web/test/lib/confirm.handler.test.ts
new file mode 100644
index 00000000000..f6cfc16d658
--- /dev/null
+++ b/apps/web/test/lib/confirm.handler.test.ts
@@ -0,0 +1,110 @@
+import {
+ createBookingScenario,
+ getOrganizer,
+ getScenarioData,
+ TestData,
+ mockSuccessfulVideoMeetingCreation,
+} from "@calcom/web/test/utils/bookingScenario/bookingScenario";
+
+import { describe, it, beforeEach, vi, expect } from "vitest";
+
+import * as handleConfirmationModule from "@calcom/features/bookings/lib/handleConfirmation";
+import { BookingStatus } from "@calcom/prisma/enums";
+import type { TrpcSessionUser } from "@calcom/trpc/server/types";
+import { confirmHandler } from "@calcom/trpc/server/routers/viewer/bookings/confirm.handler";
+
+describe("confirmHandler", () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ });
+
+ it("should pass hideCalendarNotes property to CalendarEvent when enabled", async () => {
+ vi.setSystemTime("2050-01-07T00:00:00Z");
+
+ const handleConfirmationSpy = vi.spyOn(handleConfirmationModule, "handleConfirmation");
+
+ const attendeeUser = getOrganizer({
+ email: "[email protected]",
+ name: "test name",
+ id: 102,
+ schedules: [TestData.schedules.IstWorkHours],
+ });
+
+ const organizer = getOrganizer({
+ name: "Organizer",
+ email: "[email protected]",
+ id: 101,
+ schedules: [TestData.schedules.IstWorkHours],
+ });
+
+ const uidOfBooking = "hideNotes123";
+ const iCalUID = `${uidOfBooking}@Cal.com`;
+
+ const plus1DateString = "2050-01-08";
+
+ await createBookingScenario(
+ getScenarioData({
+ eventTypes: [
+ {
+ id: 1,
+ slotInterval: 15,
+ length: 15,
+ locations: [],
+ hideCalendarNotes: true,
+ hideCalendarEventDetails: true,
+ requiresConfirmation: true,
+ users: [
+ {
+ id: 101,
+ },
+ ],
+ },
+ ],
+ bookings: [
+ {
+ id: 101,
+ uid: uidOfBooking,
+ eventTypeId: 1,
+ status: BookingStatus.PENDING,
+ startTime: `${plus1DateString}T05:00:00.000Z`,
+ endTime: `${plus1DateString}T05:15:00.000Z`,
+ references: [],
+ iCalUID,
+ location: "integrations:daily",
+ attendees: [attendeeUser],
+ responses: { name: attendeeUser.name, email: attendeeUser.email, notes: "Sensitive information" },
+ },
+ ],
+ organizer,
+ apps: [TestData.apps["daily-video"]],
+ })
+ );
+
+ mockSuccessfulVideoMeetingCreation({
+ metadataLookupKey: "dailyvideo",
+ });
+
+ const ctx = {
+ user: {
+ id: organizer.id,
+ name: organizer.name,
+ timeZone: organizer.timeZone,
+ username: organizer.username,
+ } as NonNullable<TrpcSessionUser>,
+ };
+
+ const res = await confirmHandler({
+ ctx,
+ input: { bookingId: 101, confirmed: true, reason: "", emailsEnabled: true },
+ });
+
+ expect(res?.status).toBe(BookingStatus.ACCEPTED);
+ expect(handleConfirmationSpy).toHaveBeenCalledTimes(1);
+
+ const handleConfirmationCall = handleConfirmationSpy.mock.calls[0][0];
+ const calendarEvent = handleConfirmationCall.evt;
+
+ expect(calendarEvent.hideCalendarNotes).toBe(true);
+ expect(calendarEvent.hideCalendarEventDetails).toBe(true);
+ });
+});
diff --git a/packages/trpc/server/routers/viewer/bookings/confirm.handler.test.ts b/packages/trpc/server/routers/viewer/bookings/confirm.handler.test.ts
index 06f6b477936..33f3f3980d4 100644
--- a/packages/trpc/server/routers/viewer/bookings/confirm.handler.test.ts
+++ b/packages/trpc/server/routers/viewer/bookings/confirm.handler.test.ts
@@ -200,4 +200,4 @@ describe.skip("confirmHandler", () => {
expect(res?.status).toBe(BookingStatus.REJECTED);
expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails });
});
-});
+});
\ No newline at end of file
diff --git a/packages/trpc/server/routers/viewer/bookings/confirm.handler.ts b/packages/trpc/server/routers/viewer/bookings/confirm.handler.ts
index f7b151fc4b4..c1d99929e84 100644
--- a/packages/trpc/server/routers/viewer/bookings/confirm.handler.ts
+++ b/packages/trpc/server/routers/viewer/bookings/confirm.handler.ts
@@ -85,6 +85,8 @@ export const confirmHandler = async ({ ctx, input }: ConfirmOptions) => {
price: true,
bookingFields: true,
hideOrganizerEmail: true,
+ hideCalendarNotes: true,
+ hideCalendarEventDetails: true,
disableGuests: true,
customReplyToEmail: true,
metadata: true,
@@ -233,6 +235,8 @@ export const confirmHandler = async ({ ctx, input }: ConfirmOptions) => {
: [],
requiresConfirmation: booking?.eventType?.requiresConfirmation ?? false,
hideOrganizerEmail: booking.eventType?.hideOrganizerEmail,
+ hideCalendarNotes: booking.eventType?.hideCalendarNotes,
+ hideCalendarEventDetails: booking.eventType?.hideCalendarEventDetails,
eventTypeId: booking.eventType?.id,
customReplyToEmail: booking.eventType?.customReplyToEmail,
team: !!booking.eventType?.team