Skip to content

Commit 31fc472

Browse files
fix: request reschedule link in email for an Org event (#12125)
1 parent f81f0a2 commit 31fc472

File tree

14 files changed

+491
-166
lines changed

14 files changed

+491
-166
lines changed

apps/web/test/utils/bookingScenario/bookingScenario.ts

+55-19
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ type InputUser = Omit<typeof TestData.users.example, "defaultScheduleId"> & {
6666
id: number;
6767
defaultScheduleId?: number | null;
6868
credentials?: InputCredential[];
69+
organizationId?: number | null;
6970
selectedCalendars?: InputSelectedCalendar[];
7071
schedules: {
7172
// Allows giving id in the input directly so that it can be referenced somewhere else as well
@@ -264,8 +265,21 @@ async function addBookingsToDb(
264265
})[]
265266
) {
266267
log.silly("TestData: Creating Bookings", JSON.stringify(bookings));
268+
269+
function getDateObj(time: string | Date) {
270+
return time instanceof Date ? time : new Date(time);
271+
}
272+
273+
// Make sure that we store the date in Date object always. This is to ensure consistency which Prisma does but not prismock
274+
log.silly("Handling Prismock bug-3");
275+
const fixedBookings = bookings.map((booking) => {
276+
const startTime = getDateObj(booking.startTime);
277+
const endTime = getDateObj(booking.endTime);
278+
return { ...booking, startTime, endTime };
279+
});
280+
267281
await prismock.booking.createMany({
268-
data: bookings,
282+
data: fixedBookings,
269283
});
270284
log.silly(
271285
"TestData: Bookings as in DB",
@@ -406,6 +420,7 @@ async function addUsers(users: InputUser[]) {
406420
},
407421
};
408422
}
423+
409424
return newUser;
410425
});
411426
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -446,6 +461,16 @@ export async function createBookingScenario(data: ScenarioData) {
446461
};
447462
}
448463

464+
export async function createOrganization(orgData: { name: string; slug: string }) {
465+
const org = await prismock.team.create({
466+
data: {
467+
name: orgData.name,
468+
slug: orgData.slug,
469+
},
470+
});
471+
return org;
472+
}
473+
449474
// async function addPaymentsToDb(payments: Prisma.PaymentCreateInput[]) {
450475
// await prismaMock.payment.createMany({
451476
// data: payments,
@@ -722,6 +747,7 @@ export function getOrganizer({
722747
}) {
723748
return {
724749
...TestData.users.example,
750+
organizationId: null as null | number,
725751
name,
726752
email,
727753
id,
@@ -733,24 +759,33 @@ export function getOrganizer({
733759
};
734760
}
735761

736-
export function getScenarioData({
737-
organizer,
738-
eventTypes,
739-
usersApartFromOrganizer = [],
740-
apps = [],
741-
webhooks,
742-
bookings,
743-
}: // hosts = [],
744-
{
745-
organizer: ReturnType<typeof getOrganizer>;
746-
eventTypes: ScenarioData["eventTypes"];
747-
apps?: ScenarioData["apps"];
748-
usersApartFromOrganizer?: ScenarioData["users"];
749-
webhooks?: ScenarioData["webhooks"];
750-
bookings?: ScenarioData["bookings"];
751-
// hosts?: ScenarioData["hosts"];
752-
}) {
762+
export function getScenarioData(
763+
{
764+
organizer,
765+
eventTypes,
766+
usersApartFromOrganizer = [],
767+
apps = [],
768+
webhooks,
769+
bookings,
770+
}: // hosts = [],
771+
{
772+
organizer: ReturnType<typeof getOrganizer>;
773+
eventTypes: ScenarioData["eventTypes"];
774+
apps?: ScenarioData["apps"];
775+
usersApartFromOrganizer?: ScenarioData["users"];
776+
webhooks?: ScenarioData["webhooks"];
777+
bookings?: ScenarioData["bookings"];
778+
// hosts?: ScenarioData["hosts"];
779+
},
780+
org?: { id: number | null } | undefined | null
781+
) {
753782
const users = [organizer, ...usersApartFromOrganizer];
783+
if (org) {
784+
users.forEach((user) => {
785+
user.organizationId = org.id;
786+
});
787+
}
788+
754789
eventTypes.forEach((eventType) => {
755790
if (
756791
eventType.users?.filter((eventTypeUser) => {
@@ -897,6 +932,7 @@ export function mockCalendar(
897932
url: "https://UNUSED_URL",
898933
});
899934
},
935+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
900936
deleteEvent: async (...rest: any[]) => {
901937
log.silly("mockCalendar.deleteEvent", JSON.stringify({ rest }));
902938
// eslint-disable-next-line prefer-rest-params
@@ -1021,6 +1057,7 @@ export function mockVideoApp({
10211057
...videoMeetingData,
10221058
});
10231059
},
1060+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
10241061
deleteMeeting: async (...rest: any[]) => {
10251062
log.silly("MockVideoApiAdapter.deleteMeeting", JSON.stringify(rest));
10261063
deleteMeetingCalls.push({
@@ -1153,7 +1190,6 @@ export async function mockPaymentSuccessWebhookFromStripe({ externalId }: { exte
11531190
await handleStripePaymentSuccess(getMockedStripePaymentEvent({ paymentIntentId: externalId }));
11541191
} catch (e) {
11551192
log.silly("mockPaymentSuccessWebhookFromStripe:catch", JSON.stringify(e));
1156-
11571193
webhookResponse = e as HttpError;
11581194
}
11591195
return { webhookResponse };

0 commit comments

Comments
 (0)