From dbba2b8d42cee7a94ce6e20bea053bc066d5c417 Mon Sep 17 00:00:00 2001 From: CarinaWolli Date: Wed, 24 Apr 2024 15:22:50 -0400 Subject: [PATCH 01/11] add tests for workflow sms --- apps/web/test/fixtures/fixtures.ts | 11 + .../utils/bookingScenario/bookingScenario.ts | 5 +- .../web/test/utils/bookingScenario/expects.ts | 32 +++ .../test/workflow-notifications.test.ts | 246 ++++++++++++++++++ .../lib/reminders/providers/twilioProvider.ts | 20 +- packages/lib/testSMS.ts | 21 ++ 6 files changed, 332 insertions(+), 3 deletions(-) create mode 100644 packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts create mode 100644 packages/lib/testSMS.ts diff --git a/apps/web/test/fixtures/fixtures.ts b/apps/web/test/fixtures/fixtures.ts index 121c188bb3bd7..438874624b48e 100644 --- a/apps/web/test/fixtures/fixtures.ts +++ b/apps/web/test/fixtures/fixtures.ts @@ -2,15 +2,20 @@ import { test as base } from "vitest"; import { getTestEmails } from "@calcom/lib/testEmails"; +import { getTestSMS } from "@calcom/lib/testSMS"; export interface Fixtures { emails: ReturnType; + sms: ReturnType; } export const test = base.extend({ emails: async ({}, use) => { await use(getEmailsFixture()); }, + sms: async ({}, use) => { + await use(getSMSFixture()); + }, }); function getEmailsFixture() { @@ -18,3 +23,9 @@ function getEmailsFixture() { get: getTestEmails, }; } + +function getSMSFixture() { + return { + get: getTestSMS, + }; +} diff --git a/apps/web/test/utils/bookingScenario/bookingScenario.ts b/apps/web/test/utils/bookingScenario/bookingScenario.ts index de929ff154550..e202773b13ad5 100644 --- a/apps/web/test/utils/bookingScenario/bookingScenario.ts +++ b/apps/web/test/utils/bookingScenario/bookingScenario.ts @@ -19,7 +19,7 @@ import logger from "@calcom/lib/logger"; import { safeStringify } from "@calcom/lib/safeStringify"; import { ProfileRepository } from "@calcom/lib/server/repository/profile"; import type { WorkflowActions, WorkflowTemplates, WorkflowTriggerEvents } from "@calcom/prisma/client"; -import type { SchedulingType } from "@calcom/prisma/enums"; +import type { SchedulingType, SMSLockState } from "@calcom/prisma/enums"; import type { BookingStatus } from "@calcom/prisma/enums"; import type { teamMetadataSchema } from "@calcom/prisma/zod-utils"; import type { userMetadataType } from "@calcom/prisma/zod-utils"; @@ -952,6 +952,7 @@ export function getOrganizer({ teams, organizationId, metadata, + smsLockState, }: { name: string; email: string; @@ -965,6 +966,7 @@ export function getOrganizer({ weekStart?: WeekDays; teams?: InputUser["teams"]; metadata?: userMetadataType; + smsLockState?: SMSLockState; }) { return { ...TestData.users.example, @@ -981,6 +983,7 @@ export function getOrganizer({ organizationId, profiles: [], metadata, + smsLockState, }; } diff --git a/apps/web/test/utils/bookingScenario/expects.ts b/apps/web/test/utils/bookingScenario/expects.ts index a018ebae9d03e..5730c9360d3bb 100644 --- a/apps/web/test/utils/bookingScenario/expects.ts +++ b/apps/web/test/utils/bookingScenario/expects.ts @@ -344,6 +344,38 @@ export function expectWorkflowToBeNotTriggered({ ); } +export function expectSMSWorkflowToBeTriggered({ + sms, + toNumber, +}: { + sms: Fixtures["sms"]; + toNumber: string; +}) { + expect(sms.get()).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + to: toNumber, + }), + ]) + ); +} + +export function expectSMSWorkflowToBeNotTriggered({ + sms, + toNumber, +}: { + sms: Fixtures["sms"]; + toNumber: string; +}) { + expect(sms.get()).not.toEqual( + expect.arrayContaining([ + expect.objectContaining({ + to: toNumber, + }), + ]) + ); +} + export async function expectBookingToBeInDatabase( booking: Partial & Pick & { references?: Partial[] } ) { diff --git a/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts b/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts new file mode 100644 index 0000000000000..560130cc18c7b --- /dev/null +++ b/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts @@ -0,0 +1,246 @@ +import { describe } from "vitest"; + +import { resetTestSMS } from "@calcom/lib/testSMS"; +import { SMSLockState } from "@calcom/prisma/enums"; +import { test } from "@calcom/web/test/fixtures/fixtures"; +import { + createBookingScenario, + getGoogleCalendarCredential, + TestData, + getOrganizer, + getBooker, + getScenarioData, + mockSuccessfulVideoMeetingCreation, + mockCalendarToHaveNoBusySlots, + BookingLocations, +} from "@calcom/web/test/utils/bookingScenario/bookingScenario"; +import { createMockNextJsRequest } from "@calcom/web/test/utils/bookingScenario/createMockNextJsRequest"; +import { + expectWorkflowToBeTriggered, + expectSMSWorkflowToBeTriggered, + expectSMSWorkflowToBeNotTriggered, +} from "@calcom/web/test/utils/bookingScenario/expects"; +import { getMockRequestDataForBooking } from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForBooking"; +import { setupAndTeardown } from "@calcom/web/test/utils/bookingScenario/setupAndTeardown"; + +// Local test runs sometime gets too slow +const timeout = process.env.CI ? 5000 : 20000; + +describe("handleNewBooking", () => { + setupAndTeardown(); + + describe("Workflow notifications", () => { + test( + "should send email amd sms for workflow when booking is created", + async ({ emails, sms }) => { + const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default; + const booker = getBooker({ + email: "booker@example.com", + name: "Booker", + }); + + const organizerOtherEmail = "organizer2@example.com"; + const organizerDestinationCalendarEmailOnEventType = "organizerEventTypeEmail@example.com"; + + const organizer = getOrganizer({ + name: "Organizer", + email: "organizer@example.com", + id: 101, + schedules: [TestData.schedules.IstWorkHours], + credentials: [getGoogleCalendarCredential()], + selectedCalendars: [TestData.selectedCalendars.google], + destinationCalendar: { + integration: "google_calendar", + externalId: "organizer@google-calendar.com", + primaryEmail: organizerOtherEmail, + }, + }); + + await createBookingScenario( + getScenarioData({ + workflows: [ + { + userId: organizer.id, + trigger: "NEW_EVENT", + action: "EMAIL_HOST", + template: "REMINDER", + activeEventTypeId: 1, + }, + { + userId: organizer.id, + trigger: "NEW_EVENT", + action: "SMS_ATTENDEE", + template: "REMINDER", + activeEventTypeId: 1, + }, + ], + eventTypes: [ + { + id: 1, + slotInterval: 30, + length: 30, + useEventTypeDestinationCalendarEmail: true, + users: [ + { + id: 101, + }, + ], + destinationCalendar: { + integration: "google_calendar", + externalId: "event-type-1@google-calendar.com", + primaryEmail: organizerDestinationCalendarEmailOnEventType, + }, + }, + ], + organizer, + apps: [TestData.apps["google-calendar"], TestData.apps["daily-video"]], + }) + ); + + mockSuccessfulVideoMeetingCreation({ + metadataLookupKey: "dailyvideo", + videoMeetingData: { + id: "MOCK_ID", + password: "MOCK_PASS", + url: `http://mock-dailyvideo.example.com/meeting-1`, + }, + }); + + mockCalendarToHaveNoBusySlots("googlecalendar", { + create: { + id: "MOCKED_GOOGLE_CALENDAR_EVENT_ID", + }, + }); + + const mockBookingData = getMockRequestDataForBooking({ + data: { + user: organizer.username, + eventTypeId: 1, + responses: { + email: booker.email, + name: booker.name, + location: { optionValue: "", value: BookingLocations.CalVideo }, + smsReminderNumber: "000", + }, + }, + }); + + const { req } = createMockNextJsRequest({ + method: "POST", + body: mockBookingData, + }); + + await handleNewBooking(req); + + expectSMSWorkflowToBeTriggered({ + sms, + toNumber: "000", + }); + + expectWorkflowToBeTriggered({ + organizer, + emails, + destinationEmail: organizerDestinationCalendarEmailOnEventType, + }); + }, + timeout + ); + test( + "should not send sms when booking is created if the organizer is locked for sms sending", + async ({ sms }) => { + resetTestSMS(); + const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default; + const booker = getBooker({ + email: "booker@example.com", + name: "Booker", + }); + + const organizerOtherEmail = "organizer2@example.com"; + const organizerDestinationCalendarEmailOnEventType = "organizerEventTypeEmail@example.com"; + + const organizer = getOrganizer({ + name: "Organizer", + email: "organizer@example.com", + id: 101, + schedules: [TestData.schedules.IstWorkHours], + credentials: [getGoogleCalendarCredential()], + selectedCalendars: [TestData.selectedCalendars.google], + destinationCalendar: { + integration: "google_calendar", + externalId: "organizer@google-calendar.com", + primaryEmail: organizerOtherEmail, + }, + smsLockState: SMSLockState.LOCKED, + }); + + await createBookingScenario( + getScenarioData({ + workflows: [ + { + userId: organizer.id, + trigger: "NEW_EVENT", + action: "SMS_ATTENDEE", + template: "REMINDER", + activeEventTypeId: 1, + }, + ], + eventTypes: [ + { + id: 1, + slotInterval: 30, + length: 30, + useEventTypeDestinationCalendarEmail: true, + users: [ + { + id: 101, + }, + ], + destinationCalendar: { + integration: "google_calendar", + externalId: "event-type-1@google-calendar.com", + primaryEmail: organizerDestinationCalendarEmailOnEventType, + }, + }, + ], + organizer, + apps: [TestData.apps["google-calendar"], TestData.apps["daily-video"]], + }) + ); + + mockCalendarToHaveNoBusySlots("googlecalendar", { + create: { + id: "MOCKED_GOOGLE_CALENDAR_EVENT_ID", + }, + }); + + const mockBookingData = getMockRequestDataForBooking({ + data: { + user: organizer.username, + eventTypeId: 1, + responses: { + email: booker.email, + name: booker.name, + location: { optionValue: "", value: BookingLocations.CalVideo }, + smsReminderNumber: "000", + }, + }, + }); + + const { req } = createMockNextJsRequest({ + method: "POST", + body: mockBookingData, + }); + + await handleNewBooking(req); + + expectSMSWorkflowToBeNotTriggered({ + sms, + toNumber: "000", + }); + }, + timeout + ); + }); + + test.todo("CRM calendar events creation verification"); +}); diff --git a/packages/features/ee/workflows/lib/reminders/providers/twilioProvider.ts b/packages/features/ee/workflows/lib/reminders/providers/twilioProvider.ts index 1f136929dd2fe..a6d782a002d97 100644 --- a/packages/features/ee/workflows/lib/reminders/providers/twilioProvider.ts +++ b/packages/features/ee/workflows/lib/reminders/providers/twilioProvider.ts @@ -2,6 +2,7 @@ import TwilioClient from "twilio"; import { checkSMSRateLimit } from "@calcom/lib/checkRateLimitAndThrowError"; import logger from "@calcom/lib/logger"; +import { setTestSMS } from "@calcom/lib/testSMS"; import prisma from "@calcom/prisma"; import { SMSLockState } from "@calcom/prisma/enums"; @@ -46,8 +47,6 @@ export const sendSMS = async ( teamId?: number | null, whatsapp = false ) => { - assertTwilio(twilio); - const isSMSSendingLocked = await isLockedForSMSSending(userId, teamId); if (isSMSSendingLocked) { @@ -55,6 +54,23 @@ export const sendSMS = async ( return; } + const testMode = process.env.NEXT_PUBLIC_IS_E2E || process.env.INTEGRATION_TEST_MODE; + + if (testMode) { + setTestSMS({ + to: getSMSNumber(phoneNumber, whatsapp), + from: whatsapp ? getDefaultSender(whatsapp) : sender ? sender : getDefaultSender(), + message: body, + }); + console.log( + "Skipped sending SMS because process.env.NEXT_PUBLIC_IS_E2E or process.env.INTEGRATION_TEST_MODE is set. SMS are available in globalThis.testSMS" + ); + + return; + } + + assertTwilio(twilio); + if (!teamId && userId) { await checkSMSRateLimit({ identifier: `sms:user:${userId}`, diff --git a/packages/lib/testSMS.ts b/packages/lib/testSMS.ts new file mode 100644 index 0000000000000..60952a606d40e --- /dev/null +++ b/packages/lib/testSMS.ts @@ -0,0 +1,21 @@ +declare global { + // eslint-disable-next-line no-var + var testSMS: { + to: string; + from: string; + message: string; + }[]; +} + +export const setTestSMS = (sms: (typeof globalThis.testSMS)[number]) => { + globalThis.testSMS = globalThis.testSMS || []; + globalThis.testSMS.push(sms); +}; + +export const getTestSMS = () => { + return globalThis.testSMS; +}; + +export const resetTestSMS = () => { + globalThis.testSMS = []; +}; From 49b173e43d225d4a17a13835d28d06e6f48595ae Mon Sep 17 00:00:00 2001 From: CarinaWolli Date: Wed, 24 Apr 2024 15:30:24 -0400 Subject: [PATCH 02/11] fix type error --- .../test/utils/bookingScenario/getMockRequestDataForBooking.ts | 1 + .../lib/handleNewBooking/test/workflow-notifications.test.ts | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/web/test/utils/bookingScenario/getMockRequestDataForBooking.ts b/apps/web/test/utils/bookingScenario/getMockRequestDataForBooking.ts index 00bddf9fefc11..49298a98dffb4 100644 --- a/apps/web/test/utils/bookingScenario/getMockRequestDataForBooking.ts +++ b/apps/web/test/utils/bookingScenario/getMockRequestDataForBooking.ts @@ -30,6 +30,7 @@ export function getMockRequestDataForBooking({ email: string; name: string; location: { optionValue: ""; value: string }; + smsReminderNumber?: string; }; }; }) { diff --git a/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts b/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts index 560130cc18c7b..328e424e3f14a 100644 --- a/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts +++ b/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts @@ -241,6 +241,4 @@ describe("handleNewBooking", () => { timeout ); }); - - test.todo("CRM calendar events creation verification"); }); From 32d5a337e004cdf219b59980e8332c52b08545ae Mon Sep 17 00:00:00 2001 From: CarinaWolli Date: Wed, 24 Apr 2024 15:47:49 -0400 Subject: [PATCH 03/11] improvements --- .../lib/handleNewBooking/test/workflow-notifications.test.ts | 4 ++-- .../ee/workflows/lib/reminders/providers/twilioProvider.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts b/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts index 328e424e3f14a..8ce61c1f0f7c6 100644 --- a/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts +++ b/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts @@ -31,7 +31,7 @@ describe("handleNewBooking", () => { describe("Workflow notifications", () => { test( - "should send email amd sms for workflow when booking is created", + "should send work email and sms when booking is created", async ({ emails, sms }) => { const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default; const booker = getBooker({ @@ -146,7 +146,7 @@ describe("handleNewBooking", () => { timeout ); test( - "should not send sms when booking is created if the organizer is locked for sms sending", + "should not send workflow sms when booking is created if the organizer is locked for sms sending", async ({ sms }) => { resetTestSMS(); const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default; diff --git a/packages/features/ee/workflows/lib/reminders/providers/twilioProvider.ts b/packages/features/ee/workflows/lib/reminders/providers/twilioProvider.ts index a6d782a002d97..bcd466e4da6dc 100644 --- a/packages/features/ee/workflows/lib/reminders/providers/twilioProvider.ts +++ b/packages/features/ee/workflows/lib/reminders/providers/twilioProvider.ts @@ -32,7 +32,7 @@ function getDefaultSender(whatsapp = false) { if (whatsapp) { defaultSender = `whatsapp:+${process.env.TWILIO_WHATSAPP_PHONE_NUMBER}`; } - return defaultSender; + return defaultSender || ""; } function getSMSNumber(phone: string, whatsapp = false) { From 1b4b210c7c702dd2eac6e5359b1a648694645c52 Mon Sep 17 00:00:00 2001 From: CarinaWolli Date: Wed, 24 Apr 2024 19:56:29 -0400 Subject: [PATCH 04/11] add tests for team workflow --- .../web/test/utils/bookingScenario/expects.ts | 44 +-- .../test/fresh-booking.test.ts | 8 +- .../handleNewBooking/test/reschedule.test.ts | 14 +- .../test/workflow-notifications.test.ts | 323 +++++++++++++++++- 4 files changed, 352 insertions(+), 37 deletions(-) diff --git a/apps/web/test/utils/bookingScenario/expects.ts b/apps/web/test/utils/bookingScenario/expects.ts index 5730c9360d3bb..128a325f34bdc 100644 --- a/apps/web/test/utils/bookingScenario/expects.ts +++ b/apps/web/test/utils/bookingScenario/expects.ts @@ -307,41 +307,45 @@ export function expectWebhookToHaveBeenCalledWith( export function expectWorkflowToBeTriggered({ emails, - organizer, + emailsToReceive, destinationEmail, }: { emails: Fixtures["emails"]; - organizer: { email: string; name: string; timeZone: string }; + emailsToReceive: string[]; destinationEmail?: string; }) { const subjectPattern = /^Reminder: /i; - expect(emails.get()).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - subject: expect.stringMatching(subjectPattern), - to: destinationEmail ?? organizer.email, - }), - ]) - ); + emailsToReceive.forEach((email) => { + expect(emails.get()).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + subject: expect.stringMatching(subjectPattern), + to: destinationEmail ?? email, + }), + ]) + ); + }); } export function expectWorkflowToBeNotTriggered({ emails, - organizer, + emailsToReceive, }: { emails: Fixtures["emails"]; - organizer: { email: string; name: string; timeZone: string }; + emailsToReceive: string[]; }) { const subjectPattern = /^Reminder: /i; - expect(emails.get()).not.toEqual( - expect.arrayContaining([ - expect.objectContaining({ - subject: expect.stringMatching(subjectPattern), - to: organizer.email, - }), - ]) - ); + emailsToReceive.forEach((email) => { + expect(emails.get()).not.toEqual( + expect.arrayContaining([ + expect.objectContaining({ + subject: expect.stringMatching(subjectPattern), + to: email, + }), + ]) + ); + }); } export function expectSMSWorkflowToBeTriggered({ diff --git a/packages/features/bookings/lib/handleNewBooking/test/fresh-booking.test.ts b/packages/features/bookings/lib/handleNewBooking/test/fresh-booking.test.ts index 8857811a4ec79..2d7706f5aade7 100644 --- a/packages/features/bookings/lib/handleNewBooking/test/fresh-booking.test.ts +++ b/packages/features/bookings/lib/handleNewBooking/test/fresh-booking.test.ts @@ -215,7 +215,7 @@ describe("handleNewBooking", () => { }); expectWorkflowToBeTriggered({ - organizer, + emailsToReceive: [organizer.email], emails, destinationEmail: organizerDestinationCalendarEmailOnEventType, }); @@ -379,7 +379,7 @@ describe("handleNewBooking", () => { iCalUID: createdBooking.iCalUID, }); - expectWorkflowToBeTriggered({ organizer, emails }); + expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails }); expectSuccessfulCalendarEventCreationInCalendar(calendarMock, { videoCallUrl: "http://mock-dailyvideo.example.com/meeting-1", // We won't be sending evt.destinationCalendar in this case. @@ -541,7 +541,7 @@ describe("handleNewBooking", () => { iCalUID: createdBooking.iCalUID, }); - expectWorkflowToBeTriggered({ organizer, emails }); + expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails }); expectSuccessfulCalendarEventCreationInCalendar(calendarMock, { calendarId: "organizer@google-calendar.com", videoCallUrl: "http://mock-dailyvideo.example.com/meeting-1", @@ -675,7 +675,7 @@ describe("handleNewBooking", () => { ], }); - expectWorkflowToBeTriggered({ organizer, emails }); + expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails }); // FIXME: We should send Broken Integration emails on calendar event creation failure // expectCalendarEventCreationFailureEmails({ booker, organizer, emails }); diff --git a/packages/features/bookings/lib/handleNewBooking/test/reschedule.test.ts b/packages/features/bookings/lib/handleNewBooking/test/reschedule.test.ts index b942c118b02da..f332a036824b7 100644 --- a/packages/features/bookings/lib/handleNewBooking/test/reschedule.test.ts +++ b/packages/features/bookings/lib/handleNewBooking/test/reschedule.test.ts @@ -240,7 +240,7 @@ describe("handleNewBooking", () => { ], }, }); - expectWorkflowToBeTriggered({ emails, organizer }); + expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails }); expectSuccessfulVideoMeetingUpdationInCalendar(videoMock, { calEvent: { @@ -459,7 +459,7 @@ describe("handleNewBooking", () => { }, }); - expectWorkflowToBeTriggered({ emails, organizer }); + expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails }); expectSuccessfulVideoMeetingUpdationInCalendar(videoMock, { calEvent: { @@ -656,7 +656,7 @@ describe("handleNewBooking", () => { }, }); - expectWorkflowToBeTriggered({ emails, organizer }); + expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails }); // FIXME: We should send Broken Integration emails on calendar event updation failure // expectBrokenIntegrationEmails({ booker, organizer, emails }); @@ -850,7 +850,7 @@ describe("handleNewBooking", () => { }, }); - expectWorkflowToBeTriggered({ emails, organizer }); + expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails }); expectBookingRequestedEmails({ booker, @@ -1085,7 +1085,7 @@ describe("handleNewBooking", () => { }, }); - expectWorkflowToBeTriggered({ emails, organizer }); + expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails }); expectSuccessfulVideoMeetingUpdationInCalendar(videoMock, { calEvent: { @@ -1312,7 +1312,7 @@ describe("handleNewBooking", () => { }, }); - //expectWorkflowToBeTriggered({emails, organizer}); + //expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails }); expectBookingRequestedEmails({ booker, @@ -1559,7 +1559,7 @@ describe("handleNewBooking", () => { }, }); - expectWorkflowToBeTriggered({ emails, organizer }); + expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails }); expectSuccessfulVideoMeetingUpdationInCalendar(videoMock, { calEvent: { diff --git a/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts b/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts index 8ce61c1f0f7c6..74dd599a591b3 100644 --- a/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts +++ b/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts @@ -1,7 +1,7 @@ -import { describe } from "vitest"; +import { describe, beforeEach } from "vitest"; import { resetTestSMS } from "@calcom/lib/testSMS"; -import { SMSLockState } from "@calcom/prisma/enums"; +import { SMSLockState, SchedulingType } from "@calcom/prisma/enums"; import { test } from "@calcom/web/test/fixtures/fixtures"; import { createBookingScenario, @@ -13,6 +13,8 @@ import { mockSuccessfulVideoMeetingCreation, mockCalendarToHaveNoBusySlots, BookingLocations, + getDate, + Timezones, } from "@calcom/web/test/utils/bookingScenario/bookingScenario"; import { createMockNextJsRequest } from "@calcom/web/test/utils/bookingScenario/createMockNextJsRequest"; import { @@ -29,9 +31,13 @@ const timeout = process.env.CI ? 5000 : 20000; describe("handleNewBooking", () => { setupAndTeardown(); - describe("Workflow notifications", () => { + beforeEach(() => { + resetTestSMS(); + }); + + describe("User Workflows", () => { test( - "should send work email and sms when booking is created", + "should send workflow email and sms when booking is created", async ({ emails, sms }) => { const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default; const booker = getBooker({ @@ -138,7 +144,7 @@ describe("handleNewBooking", () => { }); expectWorkflowToBeTriggered({ - organizer, + emailsToReceive: [organizer.email], emails, destinationEmail: organizerDestinationCalendarEmailOnEventType, }); @@ -148,7 +154,6 @@ describe("handleNewBooking", () => { test( "should not send workflow sms when booking is created if the organizer is locked for sms sending", async ({ sms }) => { - resetTestSMS(); const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default; const booker = getBooker({ email: "booker@example.com", @@ -241,4 +246,310 @@ describe("handleNewBooking", () => { timeout ); }); + describe("Team Workflows", () => { + test( + "should send workflow email and sms when booking is created", + async ({ emails, sms }) => { + const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default; + const booker = getBooker({ + email: "booker@example.com", + name: "Booker", + }); + + const organizerDestinationCalendarEmailOnEventType = "organizerEventTypeEmail@example.com"; + + const organizer = getOrganizer({ + name: "Organizer", + email: "organizer@example.com", + id: 101, + schedules: [TestData.schedules.IstWorkHours], + credentials: [getGoogleCalendarCredential()], + selectedCalendars: [TestData.selectedCalendars.google], + destinationCalendar: { + integration: "google_calendar", + externalId: "organizer@google-calendar.com", + primaryEmail: organizerDestinationCalendarEmailOnEventType, + }, + teams: [ + { + membership: { + accepted: true, + }, + team: { + id: 1, + name: "Team 1", + slug: "team-1", + }, + }, + ], + }); + + const otherTeamMembers = [ + { + name: "Other Team Member 1", + username: "other-team-member-1", + defaultScheduleId: null, + email: "other-team-member-1@example.com", + timeZone: Timezones["+0:00"], + id: 102, + schedules: [TestData.schedules.IstWorkHours], + credentials: [getGoogleCalendarCredential()], + selectedCalendars: [TestData.selectedCalendars.google], + destinationCalendar: { + integration: TestData.apps["google-calendar"].type, + externalId: "other-team-member-1@google-calendar.com", + }, + }, + ]; + + await createBookingScenario( + getScenarioData({ + webhooks: [ + { + userId: organizer.id, + eventTriggers: ["BOOKING_CREATED"], + subscriberUrl: "http://my-webhook.example.com", + active: true, + eventTypeId: 1, + appId: null, + }, + ], + workflows: [ + { + teamId: 1, + trigger: "NEW_EVENT", + action: "EMAIL_HOST", + template: "REMINDER", + activeEventTypeId: 1, + }, + { + teamId: 1, + trigger: "NEW_EVENT", + action: "SMS_ATTENDEE", + template: "REMINDER", + activeEventTypeId: 1, + }, + ], + eventTypes: [ + { + id: 1, + slotInterval: 15, + schedulingType: SchedulingType.COLLECTIVE, + length: 15, + users: [ + { + id: 101, + }, + ], + teamId: 1, + destinationCalendar: { + integration: TestData.apps["google-calendar"].type, + externalId: "event-type-1@google-calendar.com", + }, + }, + ], + organizer, + usersApartFromOrganizer: otherTeamMembers, + apps: [TestData.apps["google-calendar"], TestData.apps["daily-video"]], + }) + ); + + mockSuccessfulVideoMeetingCreation({ + metadataLookupKey: "dailyvideo", + videoMeetingData: { + id: "MOCK_ID", + password: "MOCK_PASS", + url: `http://mock-dailyvideo.example.com/meeting-1`, + }, + }); + + mockCalendarToHaveNoBusySlots("googlecalendar", { + create: { + id: "MOCKED_GOOGLE_CALENDAR_EVENT_ID", + iCalUID: "MOCKED_GOOGLE_CALENDAR_ICS_ID", + }, + }); + + const mockBookingData = getMockRequestDataForBooking({ + data: { + start: `${getDate({ dateIncrement: 1 }).dateString}T09:00:00.000Z`, + end: `${getDate({ dateIncrement: 1 }).dateString}T09:15:00.000Z`, + user: organizer.username, + eventTypeId: 1, + responses: { + email: booker.email, + name: booker.name, + location: { optionValue: "", value: BookingLocations.CalVideo }, + smsReminderNumber: "000", + }, + }, + }); + + const { req } = createMockNextJsRequest({ + method: "POST", + body: mockBookingData, + }); + + await handleNewBooking(req); + + expectSMSWorkflowToBeTriggered({ + sms, + toNumber: "000", + }); + + expectWorkflowToBeTriggered({ + emailsToReceive: [organizer.email], // should send to the other team members too + emails, + }); + }, + timeout + ); + + test( + "should not send workflow email and sms when booking is created", + async ({ emails, sms }) => { + const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default; + const booker = getBooker({ + email: "booker@example.com", + name: "Booker", + }); + + const organizerDestinationCalendarEmailOnEventType = "organizerEventTypeEmail@example.com"; + + const organizer = getOrganizer({ + name: "Organizer", + email: "organizer@example.com", + id: 101, + schedules: [TestData.schedules.IstWorkHours], + credentials: [getGoogleCalendarCredential()], + selectedCalendars: [TestData.selectedCalendars.google], + destinationCalendar: { + integration: "google_calendar", + externalId: "organizer@google-calendar.com", + primaryEmail: organizerDestinationCalendarEmailOnEventType, + }, + teams: [ + { + membership: { + accepted: true, + }, + team: { + id: 1, + name: "Team 1", + slug: "team-1", + smsLockState: SMSLockState.LOCKED, + }, + }, + ], + }); + + const otherTeamMembers = [ + { + name: "Other Team Member 1", + username: "other-team-member-1", + defaultScheduleId: null, + email: "other-team-member-1@example.com", + timeZone: Timezones["+0:00"], + id: 102, + schedules: [TestData.schedules.IstWorkHours], + credentials: [getGoogleCalendarCredential()], + selectedCalendars: [TestData.selectedCalendars.google], + destinationCalendar: { + integration: TestData.apps["google-calendar"].type, + externalId: "other-team-member-1@google-calendar.com", + }, + }, + ]; + + await createBookingScenario( + getScenarioData({ + webhooks: [ + { + userId: organizer.id, + eventTriggers: ["BOOKING_CREATED"], + subscriberUrl: "http://my-webhook.example.com", + active: true, + eventTypeId: 1, + appId: null, + }, + ], + workflows: [ + { + teamId: 1, + trigger: "NEW_EVENT", + action: "SMS_ATTENDEE", + template: "REMINDER", + activeEventTypeId: 1, + }, + ], + eventTypes: [ + { + id: 1, + slotInterval: 15, + schedulingType: SchedulingType.COLLECTIVE, + length: 15, + users: [ + { + id: 101, + }, + ], + teamId: 1, + destinationCalendar: { + integration: TestData.apps["google-calendar"].type, + externalId: "event-type-1@google-calendar.com", + }, + }, + ], + organizer, + usersApartFromOrganizer: otherTeamMembers, + apps: [TestData.apps["google-calendar"], TestData.apps["daily-video"]], + }) + ); + + mockSuccessfulVideoMeetingCreation({ + metadataLookupKey: "dailyvideo", + videoMeetingData: { + id: "MOCK_ID", + password: "MOCK_PASS", + url: `http://mock-dailyvideo.example.com/meeting-1`, + }, + }); + + mockCalendarToHaveNoBusySlots("googlecalendar", { + create: { + id: "MOCKED_GOOGLE_CALENDAR_EVENT_ID", + iCalUID: "MOCKED_GOOGLE_CALENDAR_ICS_ID", + }, + }); + + const mockBookingData = getMockRequestDataForBooking({ + data: { + start: `${getDate({ dateIncrement: 1 }).dateString}T09:00:00.000Z`, + end: `${getDate({ dateIncrement: 1 }).dateString}T09:15:00.000Z`, + user: organizer.username, + eventTypeId: 1, + responses: { + email: booker.email, + name: booker.name, + location: { optionValue: "", value: BookingLocations.CalVideo }, + smsReminderNumber: "000", + }, + }, + }); + + const { req } = createMockNextJsRequest({ + method: "POST", + body: mockBookingData, + }); + + await handleNewBooking(req); + + expectSMSWorkflowToBeNotTriggered({ + sms, + toNumber: "000", + }); + }, + timeout + ); + }); }); From 5652c9bdad41644f4cc9c20858f22d29b003da37 Mon Sep 17 00:00:00 2001 From: CarinaWolli Date: Wed, 24 Apr 2024 20:00:30 -0400 Subject: [PATCH 05/11] rename test --- .../lib/handleNewBooking/test/workflow-notifications.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts b/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts index 74dd599a591b3..283ad48fc48ae 100644 --- a/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts +++ b/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts @@ -406,7 +406,7 @@ describe("handleNewBooking", () => { ); test( - "should not send workflow email and sms when booking is created", + "should not send workflow email and sms when booking is created if the team is locked for sms sending", async ({ emails, sms }) => { const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default; const booker = getBooker({ From 1200687b2009423f1266d0aabc1d156bf3e94ae0 Mon Sep 17 00:00:00 2001 From: CarinaWolli Date: Wed, 24 Apr 2024 20:02:51 -0400 Subject: [PATCH 06/11] add emailsToReceive everywhere --- .../test/fresh-booking.test.ts | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/features/bookings/lib/handleNewBooking/test/fresh-booking.test.ts b/packages/features/bookings/lib/handleNewBooking/test/fresh-booking.test.ts index 2d7706f5aade7..89356f125c119 100644 --- a/packages/features/bookings/lib/handleNewBooking/test/fresh-booking.test.ts +++ b/packages/features/bookings/lib/handleNewBooking/test/fresh-booking.test.ts @@ -51,7 +51,6 @@ import { expectBookingPaymentIntiatedWebhookToHaveBeenFired, expectBrokenIntegrationEmails, expectSuccessfulCalendarEventCreationInCalendar, - expectWorkflowToBeNotTriggered, expectICalUIDAsString, } from "@calcom/web/test/utils/bookingScenario/expects"; import { getMockRequestDataForBooking } from "@calcom/web/test/utils/bookingScenario/getMockRequestDataForBooking"; @@ -825,7 +824,7 @@ describe("handleNewBooking", () => { iCalUID: createdBooking.iCalUID, }); - expectWorkflowToBeTriggered({ organizer, emails }); + expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails }); expectSuccessfulCalendarEventCreationInCalendar(calendarMock, { calendarId: "organizer@google-calendar.com", @@ -982,7 +981,7 @@ describe("handleNewBooking", () => { ], }); - expectWorkflowToBeTriggered({ organizer, emails }); + expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails }); expectSuccessfulCalendarEventCreationInCalendar(calendarMock, { calendarId: "organizer@google-calendar.com", videoCallUrl: "http://mock-dailyvideo.example.com/meeting-1", @@ -1511,7 +1510,7 @@ describe("handleNewBooking", () => { status: BookingStatus.PENDING, }); - expectWorkflowToBeNotTriggered({ organizer, emails }); + expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails }); expectBookingRequestedEmails({ booker, @@ -1636,7 +1635,7 @@ describe("handleNewBooking", () => { }), }); - expectWorkflowToBeNotTriggered({ organizer, emails }); + expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails }); expectBookingRequestedEmails({ booker, @@ -1764,7 +1763,7 @@ describe("handleNewBooking", () => { iCalUID: createdBooking.iCalUID, }); - expectWorkflowToBeTriggered({ organizer, emails }); + expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails }); const iCalUID = expectICalUIDAsString(createdBooking.iCalUID); @@ -1897,7 +1896,7 @@ describe("handleNewBooking", () => { iCalUID: createdBooking.iCalUID, }); - expectWorkflowToBeNotTriggered({ organizer, emails }); + expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails }); expectBookingRequestedEmails({ booker, organizer, emails }); @@ -2076,7 +2075,7 @@ describe("handleNewBooking", () => { iCalUID: createdBooking.iCalUID, }); - expectWorkflowToBeTriggered({ organizer, emails }); + expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails }); const iCalUID = expectICalUIDAsString(createdBooking.iCalUID); @@ -2220,7 +2219,7 @@ describe("handleNewBooking", () => { }), }); - expectWorkflowToBeNotTriggered({ organizer, emails }); + expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails }); expectAwaitingPaymentEmails({ organizer, booker, emails }); @@ -2244,7 +2243,7 @@ describe("handleNewBooking", () => { status: BookingStatus.ACCEPTED, }); - expectWorkflowToBeTriggered({ organizer, emails }); + expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails }); expectBookingCreatedWebhookToHaveBeenFired({ booker, @@ -2374,7 +2373,7 @@ describe("handleNewBooking", () => { status: BookingStatus.PENDING, }); - expectWorkflowToBeNotTriggered({ organizer, emails }); + expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails }); expectAwaitingPaymentEmails({ organizer, booker, emails }); expectBookingPaymentIntiatedWebhookToHaveBeenFired({ From f03e58ef92afb993027995e8d8ea3428cd836410 Mon Sep 17 00:00:00 2001 From: CarinaWolli Date: Wed, 24 Apr 2024 20:08:23 -0400 Subject: [PATCH 07/11] fix type errors --- apps/web/test/utils/bookingScenario/test.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/web/test/utils/bookingScenario/test.ts b/apps/web/test/utils/bookingScenario/test.ts index 7a00f894fd8a3..b3957f982f061 100644 --- a/apps/web/test/utils/bookingScenario/test.ts +++ b/apps/web/test/utils/bookingScenario/test.ts @@ -15,7 +15,7 @@ const _testWithAndWithoutOrg = ( const t = mode === "only" ? test.only : mode === "skip" ? test.skip : test; t( `${description} - With org`, - async ({ emails, meta, task, onTestFailed, expect, skip }) => { + async ({ emails, sms, meta, task, onTestFailed, expect, skip }) => { const org = await createOrganization({ name: "Test Org", slug: "testorg", @@ -27,6 +27,7 @@ const _testWithAndWithoutOrg = ( onTestFailed, expect, emails, + sms, skip, org: { organization: org, @@ -39,9 +40,10 @@ const _testWithAndWithoutOrg = ( t( `${description}`, - async ({ emails, meta, task, onTestFailed, expect, skip }) => { + async ({ emails, sms, meta, task, onTestFailed, expect, skip }) => { await fn({ emails, + sms, meta, task, onTestFailed, From d55a7451bdda60201965e22d9a0644b4bc75504b Mon Sep 17 00:00:00 2001 From: CarinaWolli Date: Wed, 24 Apr 2024 20:15:42 -0400 Subject: [PATCH 08/11] code clean up --- .../test/workflow-notifications.test.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts b/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts index 283ad48fc48ae..aab8c0e65b365 100644 --- a/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts +++ b/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts @@ -340,6 +340,9 @@ describe("handleNewBooking", () => { { id: 101, }, + { + id: 102, + }, ], teamId: 1, destinationCalendar: { @@ -398,7 +401,8 @@ describe("handleNewBooking", () => { }); expectWorkflowToBeTriggered({ - emailsToReceive: [organizer.email], // should send to the other team members too + // emailsToReceive: [organizer.email].concat(otherTeamMembers.map(member => member.email)), + emailsToReceive: [organizer.email], emails, }); }, @@ -406,7 +410,7 @@ describe("handleNewBooking", () => { ); test( - "should not send workflow email and sms when booking is created if the team is locked for sms sending", + "should not send workflow sms when booking is created if the team is locked for sms sending", async ({ emails, sms }) => { const handleNewBooking = (await import("@calcom/features/bookings/lib/handleNewBooking")).default; const booker = getBooker({ @@ -492,6 +496,9 @@ describe("handleNewBooking", () => { { id: 101, }, + { + id: 102, + }, ], teamId: 1, destinationCalendar: { From 002308631ebeb8d4ac2d22ce78da562fb8ab7dfe Mon Sep 17 00:00:00 2001 From: CarinaWolli Date: Wed, 24 Apr 2024 20:37:26 -0400 Subject: [PATCH 09/11] fix fresh-booking.test.ts --- .../lib/handleNewBooking/test/fresh-booking.test.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/features/bookings/lib/handleNewBooking/test/fresh-booking.test.ts b/packages/features/bookings/lib/handleNewBooking/test/fresh-booking.test.ts index 89356f125c119..929bafa463736 100644 --- a/packages/features/bookings/lib/handleNewBooking/test/fresh-booking.test.ts +++ b/packages/features/bookings/lib/handleNewBooking/test/fresh-booking.test.ts @@ -42,6 +42,7 @@ import { import { createMockNextJsRequest } from "@calcom/web/test/utils/bookingScenario/createMockNextJsRequest"; import { expectWorkflowToBeTriggered, + expectWorkflowToBeNotTriggered, expectSuccessfulBookingCreationEmails, expectBookingToBeInDatabase, expectAwaitingPaymentEmails, @@ -1510,7 +1511,7 @@ describe("handleNewBooking", () => { status: BookingStatus.PENDING, }); - expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails }); + expectWorkflowToBeNotTriggered({ emailsToReceive: [organizer.email], emails }); expectBookingRequestedEmails({ booker, @@ -1635,7 +1636,7 @@ describe("handleNewBooking", () => { }), }); - expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails }); + expectWorkflowToBeNotTriggered({ emailsToReceive: [organizer.email], emails }); expectBookingRequestedEmails({ booker, @@ -1896,7 +1897,7 @@ describe("handleNewBooking", () => { iCalUID: createdBooking.iCalUID, }); - expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails }); + expectWorkflowToBeNotTriggered({ emailsToReceive: [organizer.email], emails }); expectBookingRequestedEmails({ booker, organizer, emails }); @@ -2219,7 +2220,7 @@ describe("handleNewBooking", () => { }), }); - expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails }); + expectWorkflowToBeNotTriggered({ emailsToReceive: [organizer.email], emails }); expectAwaitingPaymentEmails({ organizer, booker, emails }); @@ -2373,7 +2374,7 @@ describe("handleNewBooking", () => { status: BookingStatus.PENDING, }); - expectWorkflowToBeTriggered({ emailsToReceive: [organizer.email], emails }); + expectWorkflowToBeNotTriggered({ emailsToReceive: [organizer.email], emails }); expectAwaitingPaymentEmails({ organizer, booker, emails }); expectBookingPaymentIntiatedWebhookToHaveBeenFired({ From d3063b6fffabc8740970d9322ba483d04bd723c5 Mon Sep 17 00:00:00 2001 From: CarinaWolli Date: Wed, 24 Apr 2024 20:48:30 -0400 Subject: [PATCH 10/11] add destination email to emailsToReceive --- apps/web/test/utils/bookingScenario/expects.ts | 4 +--- .../bookings/lib/handleNewBooking/test/fresh-booking.test.ts | 3 +-- .../lib/handleNewBooking/test/workflow-notifications.test.ts | 3 +-- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/apps/web/test/utils/bookingScenario/expects.ts b/apps/web/test/utils/bookingScenario/expects.ts index 128a325f34bdc..c01bc1745ea5b 100644 --- a/apps/web/test/utils/bookingScenario/expects.ts +++ b/apps/web/test/utils/bookingScenario/expects.ts @@ -308,11 +308,9 @@ export function expectWebhookToHaveBeenCalledWith( export function expectWorkflowToBeTriggered({ emails, emailsToReceive, - destinationEmail, }: { emails: Fixtures["emails"]; emailsToReceive: string[]; - destinationEmail?: string; }) { const subjectPattern = /^Reminder: /i; emailsToReceive.forEach((email) => { @@ -320,7 +318,7 @@ export function expectWorkflowToBeTriggered({ expect.arrayContaining([ expect.objectContaining({ subject: expect.stringMatching(subjectPattern), - to: destinationEmail ?? email, + to: email, }), ]) ); diff --git a/packages/features/bookings/lib/handleNewBooking/test/fresh-booking.test.ts b/packages/features/bookings/lib/handleNewBooking/test/fresh-booking.test.ts index 929bafa463736..a9130663163d4 100644 --- a/packages/features/bookings/lib/handleNewBooking/test/fresh-booking.test.ts +++ b/packages/features/bookings/lib/handleNewBooking/test/fresh-booking.test.ts @@ -215,9 +215,8 @@ describe("handleNewBooking", () => { }); expectWorkflowToBeTriggered({ - emailsToReceive: [organizer.email], + emailsToReceive: [organizerDestinationCalendarEmailOnEventType], emails, - destinationEmail: organizerDestinationCalendarEmailOnEventType, }); expectSuccessfulCalendarEventCreationInCalendar(calendarMock, { calendarId: "event-type-1@google-calendar.com", diff --git a/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts b/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts index aab8c0e65b365..7e8d6685d7ed4 100644 --- a/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts +++ b/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts @@ -144,9 +144,8 @@ describe("handleNewBooking", () => { }); expectWorkflowToBeTriggered({ - emailsToReceive: [organizer.email], + emailsToReceive: [organizerDestinationCalendarEmailOnEventType], emails, - destinationEmail: organizerDestinationCalendarEmailOnEventType, }); }, timeout From 500f94bb71355c15f38027195a7005097262428f Mon Sep 17 00:00:00 2001 From: CarinaWolli Date: Wed, 24 Apr 2024 20:51:17 -0400 Subject: [PATCH 11/11] remove unused webhooks --- .../test/workflow-notifications.test.ts | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts b/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts index 7e8d6685d7ed4..b11ca02128e4c 100644 --- a/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts +++ b/packages/features/bookings/lib/handleNewBooking/test/workflow-notifications.test.ts @@ -303,16 +303,6 @@ describe("handleNewBooking", () => { await createBookingScenario( getScenarioData({ - webhooks: [ - { - userId: organizer.id, - eventTriggers: ["BOOKING_CREATED"], - subscriberUrl: "http://my-webhook.example.com", - active: true, - eventTypeId: 1, - appId: null, - }, - ], workflows: [ { teamId: 1, @@ -466,16 +456,6 @@ describe("handleNewBooking", () => { await createBookingScenario( getScenarioData({ - webhooks: [ - { - userId: organizer.id, - eventTriggers: ["BOOKING_CREATED"], - subscriberUrl: "http://my-webhook.example.com", - active: true, - eventTypeId: 1, - appId: null, - }, - ], workflows: [ { teamId: 1,