fix: hide notes (#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 <[email protected]> Co-authored-by: supalarry <[email protected]> Co-authored-by: Lauris Skraucis <[email protected]>
This commit is contained in:
3 files changed
+115
-1
No files matched your search
@@ -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);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user