2022-08-11 00:53:05 +00:00
|
|
|
import { faker } from "@faker-js/faker";
|
2023-05-24 23:35:44 +00:00
|
|
|
import { describe, expect, it, vi } from "vitest";
|
2022-08-11 00:53:05 +00:00
|
|
|
|
2023-04-13 19:03:08 +00:00
|
|
|
import {
|
|
|
|
getLocation,
|
|
|
|
getPublicVideoCallUrl,
|
|
|
|
getVideoCallPassword,
|
|
|
|
getVideoCallUrlFromCalEvent,
|
|
|
|
} from "../CalEventParser";
|
2022-08-11 00:53:05 +00:00
|
|
|
import { buildCalendarEvent, buildVideoCallData } from "./builder";
|
|
|
|
|
2023-05-24 23:35:44 +00:00
|
|
|
vi.mock("@calcom/lib/constants", () => ({
|
2022-08-29 22:33:53 +00:00
|
|
|
WEBAPP_URL: "http://localhost:3000",
|
|
|
|
}));
|
|
|
|
|
2023-05-24 23:35:44 +00:00
|
|
|
vi.mock("short-uuid", () => ({
|
2022-08-29 22:33:53 +00:00
|
|
|
__esModule: true,
|
|
|
|
default: () => ({ fromUUID: () => "FAKE_UUID" }),
|
|
|
|
}));
|
|
|
|
|
2022-08-11 00:53:05 +00:00
|
|
|
describe("getLocation", () => {
|
|
|
|
it("should return a meetingUrl for video call meetings", () => {
|
|
|
|
const calEvent = buildCalendarEvent({
|
|
|
|
videoCallData: buildVideoCallData({
|
|
|
|
type: "daily_video",
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
|
2023-04-13 19:03:08 +00:00
|
|
|
expect(getLocation(calEvent)).toEqual(getVideoCallUrlFromCalEvent(calEvent));
|
2022-08-11 00:53:05 +00:00
|
|
|
});
|
|
|
|
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",
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
|
2023-04-13 19:03:08 +00:00
|
|
|
expect(getVideoCallUrlFromCalEvent(calEvent)).toEqual(getPublicVideoCallUrl(calEvent));
|
2022-08-11 00:53:05 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("getVideoCallPassword", () => {
|
|
|
|
it("should return an empty password for daily call meetings", () => {
|
|
|
|
const calEvent = buildCalendarEvent({
|
|
|
|
videoCallData: buildVideoCallData({
|
|
|
|
type: "daily_video",
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(getVideoCallPassword(calEvent)).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)).toEqual(calEvent?.videoCallData.password);
|
|
|
|
});
|
|
|
|
});
|