Skip to content

Commit

Permalink
fix: Booking Cancelled Webhook - Organiser webhook payload is missing…
Browse files Browse the repository at this point in the history
… id. #14697 (#14745)

* fix: include id information to be consistent with create/reschedule flows

* fix: include username as well

* function expectBookingCancelledWebhookToHaveBeenFired created

* chore: undo yarn.lock

---------

Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
Co-authored-by: Udit Takkar <udit222001@gmail.com>
  • Loading branch information
3 people committed May 6, 2024
1 parent 3a0c766 commit 8deedfd
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
38 changes: 38 additions & 0 deletions apps/web/test/utils/bookingScenario/expects.ts
Expand Up @@ -975,6 +975,44 @@ export function expectBookingRescheduledWebhookToHaveBeenFired({
});
}

export function expectBookingCancelledWebhookToHaveBeenFired({
booker,
location,
subscriberUrl,
payload,
}: {
organizer: { email: string; name: string };
booker: { email: string; name: string };
subscriberUrl: string;
location: string;
payload?: Record<string, unknown>;
}) {
expectWebhookToHaveBeenCalledWith(subscriberUrl, {
triggerEvent: "BOOKING_CANCELLED",
payload: {
...payload,
metadata: null,
responses: {
booker: {
label: "your_name",
value: booker.name,
isHidden: false,
},
email: {
label: "email_address",
value: booker.email,
isHidden: false,
},
location: {
label: "location",
value: { optionValue: "", value: location },
isHidden: false,
},
},
},
});
}

export function expectBookingPaymentIntiatedWebhookToHaveBeenFired({
booker,
location,
Expand Down
8 changes: 6 additions & 2 deletions packages/features/bookings/lib/handleCancelBooking.ts
Expand Up @@ -200,6 +200,8 @@ async function handler(req: CustomRequest) {
id: bookingToDelete.userId,
},
select: {
id: true,
username:true,
name: true,
email: true,
timeZone: true,
Expand Down Expand Up @@ -255,6 +257,8 @@ async function handler(req: CustomRequest) {
startTime: bookingToDelete?.startTime ? dayjs(bookingToDelete.startTime).format() : "",
endTime: bookingToDelete?.endTime ? dayjs(bookingToDelete.endTime).format() : "",
organizer: {
id: organizer.id,
username: organizer.username || undefined,
email: bookingToDelete?.userPrimaryEmail ?? organizer.email,
name: organizer.name ?? "Nameless",
timeZone: organizer.timeZone,
Expand All @@ -272,8 +276,8 @@ async function handler(req: CustomRequest) {
destinationCalendar: bookingToDelete?.destinationCalendar
? [bookingToDelete?.destinationCalendar]
: bookingToDelete?.user.destinationCalendar
? [bookingToDelete?.user.destinationCalendar]
: [],
? [bookingToDelete?.user.destinationCalendar]
: [],
cancellationReason: cancellationReason,
...(teamMembers && {
team: { name: bookingToDelete?.eventType?.team?.name || "Nameless", members: teamMembers, id: teamId! },
Expand Down

0 comments on commit 8deedfd

Please sign in to comment.