Some cleanup
parent
82bea948ea
commit
839bffaf9b
|
@ -1,3 +1,5 @@
|
||||||
|
import prismaMock from "../../../../../tests/libs/__mocks__/prisma";
|
||||||
|
|
||||||
import type { Payment, Prisma, PaymentOption, Booking } from "@prisma/client";
|
import type { Payment, Prisma, PaymentOption, Booking } from "@prisma/client";
|
||||||
import { v4 as uuidv4 } from "uuid";
|
import { v4 as uuidv4 } from "uuid";
|
||||||
import "vitest-fetch-mock";
|
import "vitest-fetch-mock";
|
||||||
|
@ -7,8 +9,6 @@ import logger from "@calcom/lib/logger";
|
||||||
import type { CalendarEvent } from "@calcom/types/Calendar";
|
import type { CalendarEvent } from "@calcom/types/Calendar";
|
||||||
import type { IAbstractPaymentService } from "@calcom/types/PaymentService";
|
import type { IAbstractPaymentService } from "@calcom/types/PaymentService";
|
||||||
|
|
||||||
import prismaMock from "../../../../../tests/libs/__mocks__/prisma";
|
|
||||||
|
|
||||||
export function getMockPaymentService() {
|
export function getMockPaymentService() {
|
||||||
function createPaymentLink(/*{ paymentUid, name, email, date }*/) {
|
function createPaymentLink(/*{ paymentUid, name, email, date }*/) {
|
||||||
return "http://mock-payment.example.com/";
|
return "http://mock-payment.example.com/";
|
||||||
|
|
|
@ -232,3 +232,36 @@ export function expectBookingRequestedWebhookToHaveBeenFired({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function expectBookingCreatedWebhookToHaveBeenFired({
|
||||||
|
organizer,
|
||||||
|
booker,
|
||||||
|
location,
|
||||||
|
subscriberUrl,
|
||||||
|
paidEvent,
|
||||||
|
videoCallUrl,
|
||||||
|
}: {
|
||||||
|
organizer: { email: string; name: string };
|
||||||
|
booker: { email: string; name: string };
|
||||||
|
subscriberUrl: string;
|
||||||
|
location: string;
|
||||||
|
paidEvent?: boolean;
|
||||||
|
videoCallUrl: string;
|
||||||
|
}) {
|
||||||
|
expectWebhookToHaveBeenCalledWith(subscriberUrl, {
|
||||||
|
triggerEvent: "BOOKING_CREATED",
|
||||||
|
payload: {
|
||||||
|
metadata: {
|
||||||
|
videoCallUrl,
|
||||||
|
},
|
||||||
|
responses: {
|
||||||
|
name: { label: "your_name", value: booker.name },
|
||||||
|
email: { label: "email_address", value: booker.email },
|
||||||
|
location: {
|
||||||
|
label: "location",
|
||||||
|
value: { optionValue: "", value: location },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ import {
|
||||||
expectAwaitingPaymentEmails,
|
expectAwaitingPaymentEmails,
|
||||||
expectBookingRequestedEmails,
|
expectBookingRequestedEmails,
|
||||||
expectBookingRequestedWebhookToHaveBeenFired,
|
expectBookingRequestedWebhookToHaveBeenFired,
|
||||||
|
expectBookingCreatedWebhookToHaveBeenFired,
|
||||||
} from "@calcom/web/test/utils/bookingScenario/expects";
|
} from "@calcom/web/test/utils/bookingScenario/expects";
|
||||||
|
|
||||||
type CustomNextApiRequest = NextApiRequest & Request;
|
type CustomNextApiRequest = NextApiRequest & Request;
|
||||||
|
@ -148,23 +149,13 @@ describe("handleNewBooking", () => {
|
||||||
expectWorkflowToBeTriggered();
|
expectWorkflowToBeTriggered();
|
||||||
|
|
||||||
expectSuccessfulBookingCreationEmails({booker, organizer, emails})
|
expectSuccessfulBookingCreationEmails({booker, organizer, emails})
|
||||||
|
expectBookingCreatedWebhookToHaveBeenFired({
|
||||||
expectWebhookToHaveBeenCalledWith("http://my-webhook.example.com", {
|
booker,
|
||||||
triggerEvent: "BOOKING_CREATED",
|
organizer,
|
||||||
payload: {
|
location: "integrations:daily",
|
||||||
metadata: {
|
subscriberUrl: "http://my-webhook.example.com",
|
||||||
videoCallUrl: `${WEBAPP_URL}/video/DYNAMIC_UID`,
|
videoCallUrl: `${WEBAPP_URL}/video/DYNAMIC_UID`,
|
||||||
},
|
})
|
||||||
responses: {
|
|
||||||
name: { label: "your_name", value: "Booker" },
|
|
||||||
email: { label: "email_address", value: "booker@example.com" },
|
|
||||||
location: {
|
|
||||||
label: "location",
|
|
||||||
value: { optionValue: "", value: "integrations:daily" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
timeout
|
timeout
|
||||||
);
|
);
|
||||||
|
@ -292,6 +283,7 @@ describe('Event Type that requires confirmation', () => {
|
||||||
email: "booker@example.com",
|
email: "booker@example.com",
|
||||||
name: "Booker",
|
name: "Booker",
|
||||||
});
|
});
|
||||||
|
const subscriberUrl = "http://my-webhook.example.com"
|
||||||
|
|
||||||
const organizer = getOrganizer({
|
const organizer = getOrganizer({
|
||||||
name: "Organizer",
|
name: "Organizer",
|
||||||
|
@ -307,7 +299,7 @@ describe('Event Type that requires confirmation', () => {
|
||||||
{
|
{
|
||||||
userId: organizer.id,
|
userId: organizer.id,
|
||||||
eventTriggers: ["BOOKING_CREATED"],
|
eventTriggers: ["BOOKING_CREATED"],
|
||||||
subscriberUrl: "http://my-webhook.example.com",
|
subscriberUrl,
|
||||||
active: true,
|
active: true,
|
||||||
eventTypeId: 1,
|
eventTypeId: 1,
|
||||||
appId: null,
|
appId: null,
|
||||||
|
@ -380,22 +372,14 @@ describe('Event Type that requires confirmation', () => {
|
||||||
|
|
||||||
expectSuccessfulBookingCreationEmails({booker, organizer, emails})
|
expectSuccessfulBookingCreationEmails({booker, organizer, emails})
|
||||||
|
|
||||||
expectWebhookToHaveBeenCalledWith("http://my-webhook.example.com", {
|
|
||||||
triggerEvent: "BOOKING_CREATED",
|
expectBookingCreatedWebhookToHaveBeenFired({
|
||||||
payload: {
|
booker,
|
||||||
metadata: {
|
organizer,
|
||||||
videoCallUrl: `${WEBAPP_URL}/video/DYNAMIC_UID`,
|
location: "integrations:daily",
|
||||||
},
|
subscriberUrl,
|
||||||
responses: {
|
videoCallUrl: `${WEBAPP_URL}/video/DYNAMIC_UID`,
|
||||||
name: { label: "your_name", value: "Booker" },
|
})
|
||||||
email: { label: "email_address", value: "booker@example.com" },
|
|
||||||
location: {
|
|
||||||
label: "location",
|
|
||||||
value: { optionValue: "", value: "integrations:daily" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
timeout
|
timeout
|
||||||
);
|
);
|
||||||
|
@ -582,6 +566,7 @@ describe('Event Type that requires confirmation', () => {
|
||||||
`should create a successful booking with Zoom if used`,
|
`should create a successful booking with Zoom if used`,
|
||||||
async ({ emails }) => {
|
async ({ emails }) => {
|
||||||
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
|
const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default;
|
||||||
|
const subscriberUrl = "http://my-webhook.example.com"
|
||||||
const booker = getBooker({
|
const booker = getBooker({
|
||||||
email: "booker@example.com",
|
email: "booker@example.com",
|
||||||
name: "Booker",
|
name: "Booker",
|
||||||
|
@ -614,7 +599,7 @@ describe('Event Type that requires confirmation', () => {
|
||||||
{
|
{
|
||||||
userId: organizer.id,
|
userId: organizer.id,
|
||||||
eventTriggers: ["BOOKING_CREATED"],
|
eventTriggers: ["BOOKING_CREATED"],
|
||||||
subscriberUrl: "http://my-webhook.example.com",
|
subscriberUrl,
|
||||||
active: true,
|
active: true,
|
||||||
eventTypeId: 1,
|
eventTypeId: 1,
|
||||||
appId: null,
|
appId: null,
|
||||||
|
@ -642,22 +627,13 @@ describe('Event Type that requires confirmation', () => {
|
||||||
|
|
||||||
expectSuccessfulBookingCreationEmails({booker, organizer, emails})
|
expectSuccessfulBookingCreationEmails({booker, organizer, emails})
|
||||||
|
|
||||||
expectWebhookToHaveBeenCalledWith("http://my-webhook.example.com", {
|
expectBookingCreatedWebhookToHaveBeenFired({
|
||||||
triggerEvent: "BOOKING_CREATED",
|
booker,
|
||||||
payload: {
|
organizer,
|
||||||
metadata: {
|
location: "integrations:zoom",
|
||||||
videoCallUrl: "http://mock-zoomvideo.example.com",
|
subscriberUrl,
|
||||||
},
|
videoCallUrl: "http://mock-zoomvideo.example.com",
|
||||||
responses: {
|
})
|
||||||
name: { label: "your_name", value: "Booker" },
|
|
||||||
email: { label: "email_address", value: "booker@example.com" },
|
|
||||||
location: {
|
|
||||||
label: "location",
|
|
||||||
value: { optionValue: "", value: "integrations:zoom" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
timeout
|
timeout
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue