Skip to content

Commit

Permalink
fix: request reschedule link in email for an Org event (#12125)
Browse files Browse the repository at this point in the history
  • Loading branch information
hariombalhara authored Oct 30, 2023
1 parent f81f0a2 commit 31fc472
Show file tree
Hide file tree
Showing 14 changed files with 491 additions and 166 deletions.
74 changes: 55 additions & 19 deletions apps/web/test/utils/bookingScenario/bookingScenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type InputUser = Omit<typeof TestData.users.example, "defaultScheduleId"> & {
id: number;
defaultScheduleId?: number | null;
credentials?: InputCredential[];
organizationId?: number | null;
selectedCalendars?: InputSelectedCalendar[];
schedules: {
// Allows giving id in the input directly so that it can be referenced somewhere else as well
Expand Down Expand Up @@ -264,8 +265,21 @@ async function addBookingsToDb(
})[]
) {
log.silly("TestData: Creating Bookings", JSON.stringify(bookings));

function getDateObj(time: string | Date) {
return time instanceof Date ? time : new Date(time);
}

// Make sure that we store the date in Date object always. This is to ensure consistency which Prisma does but not prismock
log.silly("Handling Prismock bug-3");
const fixedBookings = bookings.map((booking) => {
const startTime = getDateObj(booking.startTime);
const endTime = getDateObj(booking.endTime);
return { ...booking, startTime, endTime };
});

await prismock.booking.createMany({
data: bookings,
data: fixedBookings,
});
log.silly(
"TestData: Bookings as in DB",
Expand Down Expand Up @@ -406,6 +420,7 @@ async function addUsers(users: InputUser[]) {
},
};
}

return newUser;
});
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand Down Expand Up @@ -446,6 +461,16 @@ export async function createBookingScenario(data: ScenarioData) {
};
}

export async function createOrganization(orgData: { name: string; slug: string }) {
const org = await prismock.team.create({
data: {
name: orgData.name,
slug: orgData.slug,
},
});
return org;
}

// async function addPaymentsToDb(payments: Prisma.PaymentCreateInput[]) {
// await prismaMock.payment.createMany({
// data: payments,
Expand Down Expand Up @@ -722,6 +747,7 @@ export function getOrganizer({
}) {
return {
...TestData.users.example,
organizationId: null as null | number,
name,
email,
id,
Expand All @@ -733,24 +759,33 @@ export function getOrganizer({
};
}

export function getScenarioData({
organizer,
eventTypes,
usersApartFromOrganizer = [],
apps = [],
webhooks,
bookings,
}: // hosts = [],
{
organizer: ReturnType<typeof getOrganizer>;
eventTypes: ScenarioData["eventTypes"];
apps?: ScenarioData["apps"];
usersApartFromOrganizer?: ScenarioData["users"];
webhooks?: ScenarioData["webhooks"];
bookings?: ScenarioData["bookings"];
// hosts?: ScenarioData["hosts"];
}) {
export function getScenarioData(
{
organizer,
eventTypes,
usersApartFromOrganizer = [],
apps = [],
webhooks,
bookings,
}: // hosts = [],
{
organizer: ReturnType<typeof getOrganizer>;
eventTypes: ScenarioData["eventTypes"];
apps?: ScenarioData["apps"];
usersApartFromOrganizer?: ScenarioData["users"];
webhooks?: ScenarioData["webhooks"];
bookings?: ScenarioData["bookings"];
// hosts?: ScenarioData["hosts"];
},
org?: { id: number | null } | undefined | null
) {
const users = [organizer, ...usersApartFromOrganizer];
if (org) {
users.forEach((user) => {
user.organizationId = org.id;
});
}

eventTypes.forEach((eventType) => {
if (
eventType.users?.filter((eventTypeUser) => {
Expand Down Expand Up @@ -897,6 +932,7 @@ export function mockCalendar(
url: "https://UNUSED_URL",
});
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
deleteEvent: async (...rest: any[]) => {
log.silly("mockCalendar.deleteEvent", JSON.stringify({ rest }));
// eslint-disable-next-line prefer-rest-params
Expand Down Expand Up @@ -1021,6 +1057,7 @@ export function mockVideoApp({
...videoMeetingData,
});
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
deleteMeeting: async (...rest: any[]) => {
log.silly("MockVideoApiAdapter.deleteMeeting", JSON.stringify(rest));
deleteMeetingCalls.push({
Expand Down Expand Up @@ -1153,7 +1190,6 @@ export async function mockPaymentSuccessWebhookFromStripe({ externalId }: { exte
await handleStripePaymentSuccess(getMockedStripePaymentEvent({ paymentIntentId: externalId }));
} catch (e) {
log.silly("mockPaymentSuccessWebhookFromStripe:catch", JSON.stringify(e));

webhookResponse = e as HttpError;
}
return { webhookResponse };
Expand Down
Loading

1 comment on commit 31fc472

@vercel
Copy link

@vercel vercel bot commented on 31fc472 Oct 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

cal-demo – ./apps/web

cal-demo-git-main-cal.vercel.app
cal-demo-cal.vercel.app
cal-demo-gray.vercel.app

Please sign in to comment.