Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ import { SchedulingType } from "@calcom/prisma/enums";
import { BookingStatus } from "@calcom/prisma/enums";
import { test } from "@calcom/web/test/fixtures/fixtures";

import { getNewBookingHandler } from "./test/getNewBookingHandler";

// Local test runs sometime gets too slow
const timeout = process.env.CI ? 5000 : 20000;

const eventLength = 30;

const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;

const booker = getBooker({
email: "booker@example.com",
name: "Booker",
Expand Down Expand Up @@ -69,6 +69,7 @@ describe(
// eslint-disable-next-line playwright/no-skipped-test
test(`Booking limits per week
`, async ({}) => {
const handleNewBooking = getNewBookingHandler();
await createBookingScenario(
getScenarioData({
eventTypes: [
Expand Down Expand Up @@ -207,6 +208,7 @@ describe(
});

test(`Booking limits per day`, async ({}) => {
const handleNewBooking = getNewBookingHandler();
await createBookingScenario(
getScenarioData({
eventTypes: [
Expand Down Expand Up @@ -293,6 +295,7 @@ describe(
});

test(`Booking limits per month`, async ({}) => {
const handleNewBooking = getNewBookingHandler();
await createBookingScenario(
getScenarioData({
eventTypes: [
Expand Down Expand Up @@ -424,6 +427,7 @@ describe(
});

test(`Booking limits per year`, async ({}) => {
const handleNewBooking = getNewBookingHandler();
await createBookingScenario(
getScenarioData({
eventTypes: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import { PeriodType } from "@calcom/prisma/enums";
import { BookingStatus } from "@calcom/prisma/enums";
import { test } from "@calcom/web/test/fixtures/fixtures";

import { getNewBookingHandler } from "./getNewBookingHandler";

// Local test runs sometime gets too slow
const timeout = process.env.CI ? 5000 : 20000;

Expand All @@ -49,7 +51,7 @@ describe("handleNewBooking", () => {
2. following year without bookings: should create a booking in the database
`,
async ({}) => {
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
const handleNewBooking = getNewBookingHandler();

const booker = getBooker({
email: "booker@example.com",
Expand Down Expand Up @@ -167,7 +169,7 @@ describe("handleNewBooking", () => {
2. following year without bookings: should create a booking in the database
`,
async ({}) => {
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
const handleNewBooking = getNewBookingHandler();

const booker = getBooker({
email: "booker@example.com",
Expand Down Expand Up @@ -296,7 +298,7 @@ describe("handleNewBooking", () => {
test.skipIf([todayDate, tomorrowDate].includes("01"))(
`should fail a booking if exceeds booking limits with bookings in the past`,
async ({}) => {
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
const handleNewBooking = getNewBookingHandler();

const booker = getBooker({
email: "booker@example.com",
Expand Down Expand Up @@ -377,7 +379,7 @@ describe("handleNewBooking", () => {
test(
`should fail a booking if exceeds booking limits with bookings in week across two months`,
async ({}) => {
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
const handleNewBooking = getNewBookingHandler();

const booker = getBooker({
email: "booker@example.com",
Expand Down Expand Up @@ -466,7 +468,7 @@ describe("handleNewBooking", () => {

describe("Buffers", () => {
test("should throw error when booking is not respecting buffers with event types that have before and after buffer ", async ({}) => {
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
const handleNewBooking = getNewBookingHandler();

const booker = getBooker({
email: "booker@example.com",
Expand Down Expand Up @@ -560,7 +562,7 @@ describe("handleNewBooking", () => {

test(`should throw error when booking is within a before event buffer of an existing booking
`, async ({}) => {
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
const handleNewBooking = getNewBookingHandler();

const booker = getBooker({
email: "booker@example.com",
Expand Down Expand Up @@ -627,7 +629,7 @@ describe("handleNewBooking", () => {
});
test(`should throw error when booking is within a after event buffer of an existing booking
`, async ({}) => {
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
const handleNewBooking = getNewBookingHandler();

const booker = getBooker({
email: "booker@example.com",
Expand Down Expand Up @@ -695,7 +697,7 @@ describe("handleNewBooking", () => {
test(
`should fail booking if the start date is in the past`,
async ({}) => {
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
const handleNewBooking = getNewBookingHandler();
const booker = getBooker({
email: "booker@example.com",
name: "Booker",
Expand Down Expand Up @@ -770,7 +772,7 @@ describe("handleNewBooking", () => {
async () => {
// In IST it is 2024-05-22 12:39am
vi.setSystemTime("2024-05-21T19:09:13Z");
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
const handleNewBooking = getNewBookingHandler();
const booker = getBooker({
email: "booker@example.com",
name: "Booker",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import dayjs from "@calcom/dayjs";
import { BookingStatus } from "@calcom/prisma/enums";
import { test } from "@calcom/web/test/fixtures/fixtures";

import { getNewBookingHandler } from "./getNewBookingHandler";

export const Timezones = {
"-05:00": "America/New_York",
"00:00": "Europe/London",
Expand All @@ -48,7 +50,7 @@ describe("handleNewBooking", () => {
async ({ emails }) => {
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const newYorkTimeZone = Timezones["-05:00"];
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
const handleNewBooking = getNewBookingHandler();
const booker = getBooker({
email: "booker@example.com",
name: "Booker",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import dayjs from "@calcom/dayjs";
import { BookingStatus } from "@calcom/prisma/enums";
import { test } from "@calcom/web/test/fixtures/fixtures";

import { getNewBookingHandler } from "./getNewBookingHandler";

export const Timezones = {
"-05:00": "America/New_York",
"00:00": "Europe/London",
Expand All @@ -48,7 +50,7 @@ describe("handleNewBooking", () => {
async ({ emails }) => {
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const newYorkTimeZone = Timezones["-05:00"];
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
const handleNewBooking = getNewBookingHandler();
const booker = getBooker({
email: "booker@example.com",
name: "Booker",
Expand Down Expand Up @@ -210,7 +212,7 @@ describe("handleNewBooking", () => {
async ({ emails }) => {
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const newYorkTimeZone = Timezones["-05:00"];
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
const handleNewBooking = getNewBookingHandler();
const booker = getBooker({
email: "booker@example.com",
name: "Booker",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ import { BookingStatus } from "@calcom/prisma/enums";
import { MembershipRole } from "@calcom/prisma/enums";
import { test } from "@calcom/web/test/fixtures/fixtures";

import { getNewBookingHandler } from "./getNewBookingHandler";

vi.mock("@calcom/app-store/calendar.services.generated", () => {
class MockGoogleCalendarService {
credential: any;
Expand Down Expand Up @@ -160,7 +162,7 @@ describe("handleNewBooking", () => {
3. Should use Google Meet as the location even when not explicitly set.
`,
async ({ emails }) => {
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
const handleNewBooking = getNewBookingHandler();

const org = await createOrganization({
name: "Test Org",
Expand Down Expand Up @@ -339,7 +341,7 @@ describe("handleNewBooking", () => {
3. Should use Google Meet as the location even when not explicitly set and no destination calendar is set for User/EventType
`,
async ({ emails }) => {
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
const handleNewBooking = getNewBookingHandler();

const org = await createOrganization({
name: "Test Org",
Expand Down Expand Up @@ -516,7 +518,7 @@ describe("handleNewBooking", () => {
2. Should create an event in Outlook calendar with Delegation credential
`,
async ({ emails }) => {
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
const handleNewBooking = getNewBookingHandler();

const org = await createOrganization({
name: "Test Org",
Expand Down Expand Up @@ -709,7 +711,7 @@ describe("handleNewBooking", () => {
test(
`should fail calendar event creation when organizer isn't part of the organization of DelegationCredential Credential`,
async () => {
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
const handleNewBooking = getNewBookingHandler();

const org = await createOrganization({
name: "Test Org",
Expand Down Expand Up @@ -878,7 +880,7 @@ describe("handleNewBooking", () => {
3. Should use Google Meet as the location even when not explicitly set.
`,
async () => {
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
const handleNewBooking = getNewBookingHandler();

const org = await createOrganization({
name: "Test Org",
Expand Down Expand Up @@ -1031,7 +1033,7 @@ describe("handleNewBooking", () => {
test(
`should use Cal Video as the location if that is the default conferencing app set by the user. It must not use Google Meet coming from Delegation credential.`,
async () => {
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
const handleNewBooking = getNewBookingHandler();

const org = await createOrganization({
name: "Test Org",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import { ErrorCode } from "@calcom/lib/errorCodes";
import { BookingStatus } from "@calcom/prisma/enums";
import { test } from "@calcom/web/test/fixtures/fixtures";

import { getNewBookingHandler } from "./getNewBookingHandler";

export type CustomNextApiRequest = NextApiRequest & Request;

export type CustomNextApiResponse = NextApiResponse & Response;
Expand All @@ -41,7 +43,7 @@ describe("handleNewBooking", () => {
test(
`should allow a booking if there is no conflicting booking in any of the users' selectedCalendars`,
async () => {
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
const handleNewBooking = getNewBookingHandler();
const groupUserId1 = 101;
const groupUserId2 = 102;
const booker = getBooker({
Expand Down Expand Up @@ -137,7 +139,7 @@ describe("handleNewBooking", () => {
test(
`should fail a booking if there is already a conflicting booking in the first user's selectedCalendars`,
async () => {
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
const handleNewBooking = getNewBookingHandler();
const groupUserId1 = 101;
const groupUserId2 = 102;
const booker = getBooker({
Expand Down Expand Up @@ -217,7 +219,7 @@ describe("handleNewBooking", () => {
test(
`should fail a booking if there is already a conflicting booking in the second user's selectedCalendars`,
async () => {
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
const handleNewBooking = getNewBookingHandler();
const groupUserId1 = 101;
const groupUserId2 = 102;
const booker = getBooker({
Expand Down
Loading
Loading