Files
calendar/apps/web/test/lib/confirm.handler.test.ts
T
1d25265c56 feat: workflows v3 UI (#22772)
* early UI refresher of workflows using v3 designs. needs tons of testing, might have broken

* Delete .claude/settings.local.json

* fix: bunch of design fixes, merge conflict fixes

* fix: e2e and type-check

* fix: await button click

* review fixes

* code rabbit fixes

* fix styles in variables dropdown

* fix text truncate

* fix: unit tests

* fix: unit tests

* chore: add missing i18n

* review fixes

* review fixes

* fix testing info message

* move timeSectionText up

* fix which team does this apply to info message

* disable set up agent button with read only

* fix: cal.ai breaking on mobile screen

---------

Co-authored-by: Amit Sharma <74371312+Amit91848@users.noreply.github.com>
Co-authored-by: Udit Takkar <udit222001@gmail.com>
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
2025-09-11 17:01:42 +05:30

111 lines
3.2 KiB
TypeScript

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 { confirmHandler } from "@calcom/trpc/server/routers/viewer/bookings/confirm.handler";
import type { TrpcSessionUser } from "@calcom/trpc/server/types";
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: "test@example.com",
name: "test name",
id: 102,
schedules: [TestData.schedules.IstWorkHours],
});
const organizer = getOrganizer({
name: "Organizer",
email: "organizer@example.com",
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);
});
});