mirror of
https://github.com/hanzoai/calendar.git
synced 2026-10-30 14:46:43 +00:00
* 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 <[email protected]> Co-authored-by: Udit Takkar <[email protected]> Co-authored-by: CarinaWolli <[email protected]>
205 lines
5.5 KiB
TypeScript
205 lines
5.5 KiB
TypeScript
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
// @ts-nocheck
|
|
// TODO: Bring this test back with the correct setup (no illegal imports)
|
|
import { describe, beforeEach, vi, expect, test } from "vitest";
|
|
|
|
import { BookingStatus } from "@calcom/prisma/enums";
|
|
|
|
import type { TrpcSessionUser } from "../../../types";
|
|
import { confirmHandler } from "./confirm.handler";
|
|
|
|
//eslint-disable-next-line playwright/no-skipped-test
|
|
describe.skip("confirmHandler", () => {
|
|
beforeEach(() => {
|
|
// Reset all mocks before each test
|
|
vi.clearAllMocks();
|
|
// mockNoTranslations();
|
|
});
|
|
|
|
test("should successfully confirm booking when event type doesn't have any default location", async ({
|
|
emails,
|
|
}) => {
|
|
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 = "n5Wv3eHgconAED2j4gcVhP";
|
|
const iCalUID = `${uidOfBooking}@Cal.com`;
|
|
|
|
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
|
|
|
|
await createBookingScenario(
|
|
getScenarioData({
|
|
webhooks: [
|
|
{
|
|
userId: organizer.id,
|
|
eventTriggers: ["BOOKING_CREATED"],
|
|
subscriberUrl: "http://my-webhook.example.com",
|
|
active: true,
|
|
eventTypeId: 1,
|
|
appId: null,
|
|
},
|
|
],
|
|
workflows: [
|
|
{
|
|
userId: organizer.id,
|
|
trigger: "NEW_EVENT",
|
|
action: "EMAIL_HOST",
|
|
template: "REMINDER",
|
|
activeOn: [1],
|
|
},
|
|
],
|
|
eventTypes: [
|
|
{
|
|
id: 1,
|
|
slotInterval: 15,
|
|
length: 15,
|
|
locations: [],
|
|
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, guests: [] },
|
|
userPrimaryEmail: organizer.email,
|
|
},
|
|
],
|
|
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: "" },
|
|
});
|
|
|
|
expect(res?.status).toBe(BookingStatus.ACCEPTED);
|
|
expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails });
|
|
});
|
|
|
|
test("should trigger BOOKING_REJECTED workflow when booking is rejected", async ({ emails }) => {
|
|
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 = "n5Wv3eHgconAED2j4gcVhP";
|
|
const iCalUID = `${uidOfBooking}@Cal.com`;
|
|
|
|
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
|
|
|
|
await createBookingScenario(
|
|
getScenarioData({
|
|
workflows: [
|
|
{
|
|
userId: organizer.id,
|
|
trigger: "NEW_EVENT",
|
|
action: "EMAIL_HOST",
|
|
template: "REMINDER",
|
|
activeOn: [1],
|
|
},
|
|
],
|
|
eventTypes: [
|
|
{
|
|
id: 1,
|
|
slotInterval: 15,
|
|
length: 15,
|
|
locations: [],
|
|
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, guests: [] },
|
|
userPrimaryEmail: organizer.email,
|
|
},
|
|
],
|
|
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: false, reason: "Testing rejection" },
|
|
});
|
|
|
|
expect(res?.status).toBe(BookingStatus.REJECTED);
|
|
expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails });
|
|
});
|
|
});
|