Files
calendar/packages/lib/test/CalEventParser.test.ts
T
Anik Dhabal BabuGitHubDevin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>Morgan
9fcddbf27b refactor: calEventParser CalendarEvent ISP (#25890)
* refactor: calEventParser CalendarEvent ISP

* update

* fix: complete CalEventParser ISP refactoring - update call sites and fix type errors

- Update getUid call sites to pass only uid instead of whole CalendarEvent
- Update getLocation call sites to pass narrow shape with videoCallData, additionalInformation, location, uid
- Update narrow input shapes to accept null for location (matching CalendarEvent type)
- Update recurringEvent type to accept RecurringEvent | null instead of boolean
- Update videoCallData type to be more flexible ({ type?: string; url?: string })
- Fix ManageLink.tsx to pass recurringEvent directly instead of converting to boolean

Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>

* test: update CalEventParser tests to use narrow input shapes

- Update getPublicVideoCallUrl test to pass uid instead of calEvent
- Update getVideoCallPassword tests to pass videoCallData instead of calEvent

Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>

* few fix

* fix type error

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
2026-01-17 10:40:01 +05:30

80 lines
2.3 KiB
TypeScript

import { faker } from "@faker-js/faker";
import { describe, expect, it, vi } from "vitest";
import {
getLocation,
getPublicVideoCallUrl,
getVideoCallPassword,
getVideoCallUrlFromCalEvent,
} from "../CalEventParser";
import { buildCalendarEvent, buildVideoCallData } from "./builder";
vi.mock("@calcom/lib/constants", () => ({
WEBAPP_URL: "http://localhost:3000",
APP_NAME: "Cal.com",
}));
vi.mock("short-uuid", () => ({
__esModule: true,
default: () => ({ fromUUID: () => "FAKE_UUID" }),
}));
describe("getLocation", () => {
it("should return a meetingUrl for video call meetings", () => {
const calEvent = buildCalendarEvent({
videoCallData: buildVideoCallData({
type: "daily_video",
}),
});
expect(getLocation(calEvent)).toEqual(getVideoCallUrlFromCalEvent(calEvent));
});
it("should return an integration provider name from event", () => {
const provideName = "Cal.com";
const calEvent = buildCalendarEvent({
videoCallData: undefined,
location: `integrations:${provideName}`,
});
expect(getLocation(calEvent)).toEqual(provideName);
});
it("should return a real-world location from event", () => {
const calEvent = buildCalendarEvent({
videoCallData: undefined,
location: faker.address.streetAddress(true),
});
expect(getLocation(calEvent)).toEqual(calEvent.location);
});
});
describe("getVideoCallUrl", () => {
it("should return an app public url instead of meeting url for daily call meetings", () => {
const calEvent = buildCalendarEvent({
videoCallData: buildVideoCallData({
type: "daily_video",
}),
});
expect(getVideoCallUrlFromCalEvent(calEvent)).toEqual(getPublicVideoCallUrl(calEvent.uid));
});
});
describe("getVideoCallPassword", () => {
it("should return an empty password for daily call meetings", () => {
const calEvent = buildCalendarEvent({
videoCallData: buildVideoCallData({
type: "daily_video",
}),
});
expect(getVideoCallPassword(calEvent.videoCallData)).toEqual("");
});
it("should return original password for other video call meetings", () => {
const calEvent = buildCalendarEvent();
expect(calEvent?.videoCallData?.type).not.toBe("daily_video");
expect(getVideoCallPassword(calEvent.videoCallData)).toEqual(calEvent?.videoCallData?.password);
});
});