feat: Add consistent iCalUID (#12122)

Co-authored-by: Hariom <[email protected]>
Co-authored-by: Keith Williams <[email protected]>
This commit is contained in:
authored and GitHub committed 2023-12-15 10:28:32 -05:00
1 parent 0e8ac7e4ed
commit 9dfa596e3e
33 files changed
+568 -195

No files matched your search

+1
View File
@@ -62,6 +62,7 @@ export const createBookingsFixture = (page: Page) => {
rescheduled,
paid,
status,
iCalUID: `${uid}@cal.com`,
},
});
const bookingFixture = createBookingFixture(booking, store.page);
+28 -4
View File
@@ -68,6 +68,7 @@ type ExpectedEmail = {
filename: string;
iCalUID?: string;
recurrence?: Recurrence;
method: string;
};
/**
* Checks that there is no
@@ -162,9 +163,14 @@ expect.extend({
}
if (!expectedEmail.noIcs && !isIcsUIDExpected) {
const icsObjectKeys = icsObject ? Object.keys(icsObject) : [];
const icsKey = icsObjectKeys.find((key) => key !== "vcalendar");
if (!icsKey) throw new Error("icsKey not found");
return {
pass: false,
actual: JSON.stringify(icsObject),
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
actual: icsObject[icsKey].uid!,
expected: expectedEmail.ics?.iCalUID,
message: () => `Expected ICS UID ${isNot ? "is" : "isn't"} present in actual`,
};
@@ -375,6 +381,7 @@ export function expectSuccessfulBookingCreationEmails({
filename: "event.ics",
iCalUID: `${iCalUID}`,
recurrence,
method: "REQUEST",
},
},
`${organizer.email}`
@@ -397,8 +404,9 @@ export function expectSuccessfulBookingCreationEmails({
to: `${booker.name} <${booker.email}>`,
ics: {
filename: "event.ics",
iCalUID: iCalUID,
iCalUID: `${iCalUID}`,
recurrence,
method: "REQUEST",
},
links: recurrence
? [
@@ -436,7 +444,8 @@ export function expectSuccessfulBookingCreationEmails({
to: `${otherTeamMember.email}`,
ics: {
filename: "event.ics",
iCalUID: iCalUID,
iCalUID: `${iCalUID}`,
method: "REQUEST",
},
links: [
{
@@ -472,7 +481,8 @@ export function expectSuccessfulBookingCreationEmails({
to: `${guest.email}`,
ics: {
filename: "event.ics",
iCalUID: iCalUID,
iCalUID: `${iCalUID}`,
method: "REQUEST",
},
},
`${guest.name} <${guest.email}`
@@ -529,6 +539,7 @@ export function expectCalendarEventCreationFailureEmails({
ics: {
filename: "event.ics",
iCalUID,
method: "REQUEST",
},
},
`${organizer.email}`
@@ -541,6 +552,7 @@ export function expectCalendarEventCreationFailureEmails({
ics: {
filename: "event.ics",
iCalUID,
method: "REQUEST",
},
},
`${booker.name} <${booker.email}>`
@@ -612,6 +624,7 @@ export function expectSuccessfulBookingRescheduledEmails({
ics: {
filename: "event.ics",
iCalUID,
method: "REQUEST",
},
appsStatus,
},
@@ -625,6 +638,7 @@ export function expectSuccessfulBookingRescheduledEmails({
ics: {
filename: "event.ics",
iCalUID,
method: "REQUEST",
},
},
`${booker.name} <${booker.email}>`
@@ -711,6 +725,7 @@ export function expectBookingRequestRescheduledEmails({
to: `${booker.email}`,
ics: {
filename: "event.ics",
method: "REQUEST",
},
},
`${booker.email}`
@@ -724,6 +739,7 @@ export function expectBookingRequestRescheduledEmails({
to: `${loggedInUser.email}`,
ics: {
filename: "event.ics",
method: "REQUEST",
},
},
`${loggedInUser.email}`
@@ -1074,3 +1090,11 @@ export async function expectBookingInDBToBeRescheduledFromTo({ from, to }: { fro
...to,
});
}
export function expectICalUIDAsString(iCalUID: string | undefined | null) {
if (typeof iCalUID !== "string") {
throw new Error("iCalUID is not a string");
}
return iCalUID;
}