fix: cancel workflow (#26915)
This commit is contained in:
1 parent
8d1ad74650
commit
04c9453d5c
2 files changed
+140
No files matched your search
@@ -402,6 +402,7 @@ async function handler(input: CancelBookingInput, dependencies?: Dependencies) {
|
||||
platformBookingUrl,
|
||||
customReplyToEmail: bookingToDelete.eventType?.customReplyToEmail,
|
||||
organizationId: ownerProfile?.organizationId ?? null,
|
||||
schedulingType: bookingToDelete.eventType?.schedulingType,
|
||||
};
|
||||
|
||||
const dataForWebhooks = { evt, webhooks, eventTypeInfo };
|
||||
|
||||
@@ -436,6 +436,145 @@ describe("Cancel Booking", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("Should send EMAIL_HOST cancel workflow notification to both primary and secondary hosts in round robin events", async ({
|
||||
emails,
|
||||
}) => {
|
||||
const handleCancelBooking = (await import("@calcom/features/bookings/lib/handleCancelBooking")).default;
|
||||
|
||||
const booker = getBooker({
|
||||
email: "[email protected]",
|
||||
name: "Booker",
|
||||
});
|
||||
|
||||
const primaryHost = getOrganizer({
|
||||
name: "Primary Host",
|
||||
email: "[email protected]",
|
||||
id: 101,
|
||||
schedules: [TestData.schedules.IstWorkHours],
|
||||
credentials: [getGoogleCalendarCredential()],
|
||||
selectedCalendars: [TestData.selectedCalendars.google],
|
||||
});
|
||||
|
||||
const secondaryHost = getOrganizer({
|
||||
name: "Secondary Host",
|
||||
email: "[email protected]",
|
||||
id: 102,
|
||||
schedules: [TestData.schedules.IstWorkHours],
|
||||
credentials: [getGoogleCalendarCredential()],
|
||||
selectedCalendars: [TestData.selectedCalendars.google],
|
||||
});
|
||||
|
||||
const uidOfBookingToBeCancelled = "round-robin-email-host-workflow-uid";
|
||||
const idOfBookingToBeCancelled = 2040;
|
||||
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
|
||||
|
||||
await createBookingScenario(
|
||||
getScenarioData({
|
||||
eventTypes: [
|
||||
{
|
||||
id: 2,
|
||||
slotInterval: 30,
|
||||
length: 30,
|
||||
schedulingType: "ROUND_ROBIN",
|
||||
teamId: 1,
|
||||
users: [
|
||||
{
|
||||
id: 101,
|
||||
},
|
||||
{
|
||||
id: 102,
|
||||
},
|
||||
],
|
||||
hosts: [
|
||||
{
|
||||
userId: 101,
|
||||
isFixed: false,
|
||||
},
|
||||
{
|
||||
userId: 102,
|
||||
isFixed: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
workflows: [
|
||||
{
|
||||
id: 1,
|
||||
name: "Cancel Email Host Workflow",
|
||||
teamId: 1,
|
||||
trigger: "EVENT_CANCELLED",
|
||||
action: "EMAIL_HOST",
|
||||
template: "REMINDER",
|
||||
activeOn: [2],
|
||||
},
|
||||
],
|
||||
bookings: [
|
||||
{
|
||||
id: idOfBookingToBeCancelled,
|
||||
uid: uidOfBookingToBeCancelled,
|
||||
eventTypeId: 2,
|
||||
userId: 101,
|
||||
responses: {
|
||||
email: booker.email,
|
||||
name: booker.name,
|
||||
location: { optionValue: "", value: BookingLocations.CalVideo },
|
||||
},
|
||||
status: BookingStatus.ACCEPTED,
|
||||
startTime: `${plus1DateString}T05:00:00.000Z`,
|
||||
endTime: `${plus1DateString}T05:30:00.000Z`,
|
||||
attendees: [
|
||||
{
|
||||
email: booker.email,
|
||||
timeZone: "Asia/Kolkata",
|
||||
locale: "en",
|
||||
},
|
||||
{
|
||||
email: secondaryHost.email,
|
||||
timeZone: "Asia/Kolkata",
|
||||
locale: "en",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
users: [primaryHost, secondaryHost],
|
||||
apps: [TestData.apps["daily-video"]],
|
||||
})
|
||||
);
|
||||
|
||||
mockSuccessfulVideoMeetingCreation({
|
||||
metadataLookupKey: "dailyvideo",
|
||||
videoMeetingData: {
|
||||
id: "MOCK_ID",
|
||||
password: "MOCK_PASS",
|
||||
url: `http://mock-dailyvideo.example.com/meeting-3`,
|
||||
},
|
||||
});
|
||||
|
||||
mockCalendarToHaveNoBusySlots("googlecalendar", {
|
||||
create: {
|
||||
id: "MOCKED_GOOGLE_CALENDAR_EVENT_ID_3",
|
||||
},
|
||||
});
|
||||
|
||||
const result = await handleCancelBooking({
|
||||
bookingData: {
|
||||
id: idOfBookingToBeCancelled,
|
||||
uid: uidOfBookingToBeCancelled,
|
||||
cancelledBy: primaryHost.email,
|
||||
cancellationReason: "Testing EMAIL_HOST workflow sends to secondary host in round robin",
|
||||
},
|
||||
});
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.bookingId).toBe(idOfBookingToBeCancelled);
|
||||
expect(result.bookingUid).toBe(uidOfBookingToBeCancelled);
|
||||
|
||||
expectWorkflowToBeTriggered({
|
||||
emailsToReceive: [primaryHost.email, secondaryHost.email],
|
||||
emails,
|
||||
});
|
||||
});
|
||||
|
||||
test("Should block cancelling past bookings", async () => {
|
||||
const handleCancelBooking = (await import("@calcom/features/bookings/lib/handleCancelBooking")).default;
|
||||
|
||||
|
||||
Reference in new issue
Block a user