-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: booking no show webhook (#15502)
* WIP Signed-off-by: zomars <[email protected]> * WIP Signed-off-by: zomars <[email protected]> * WIP Signed-off-by: zomars <[email protected]> * Type fixes * Update webhook.e2e.ts * Update noShow.handler.ts * Log failed results * Updates tests * Show generic error on frontend. * test: add basic webhook service test * fix: webhook end to end test * fix: type error * fix: test --------- Signed-off-by: zomars <[email protected]> Co-authored-by: sean-brydon <[email protected]> Co-authored-by: Udit Takkar <[email protected]> Co-authored-by: Udit Takkar <[email protected]>
- Loading branch information
1 parent
fc42447
commit b26d296
Showing
14 changed files
with
371 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,7 +63,7 @@ test.describe("Bookings", () => { | |
}); | ||
}); | ||
test.describe("Past bookings", () => { | ||
test("Mark first guest as no-show", async ({ page, users, bookings }) => { | ||
test("Mark first guest as no-show", async ({ page, users, bookings, webhooks }) => { | ||
const firstUser = await users.create(); | ||
const secondUser = await users.create(); | ||
|
||
|
@@ -81,8 +81,8 @@ test.describe("Bookings", () => { | |
], | ||
}); | ||
const bookingWhereFirstUserIsOrganizer = await bookingWhereFirstUserIsOrganizerFixture.self(); | ||
|
||
await firstUser.apiLogin(); | ||
const webhookReceiver = await webhooks.createReceiver(); | ||
await page.goto(`/bookings/past`); | ||
const pastBookings = page.locator('[data-testid="past-bookings"]'); | ||
const firstPastBooking = pastBookings.locator('[data-testid="booking-item"]').nth(0); | ||
|
@@ -95,6 +95,23 @@ test.describe("Bookings", () => { | |
await firstGuest.click(); | ||
await expect(titleAndAttendees.locator('[data-testid="unmark-no-show"]')).toBeVisible(); | ||
await expect(titleAndAttendees.locator('[data-testid="mark-no-show"]')).toBeHidden(); | ||
await webhookReceiver.waitForRequestCount(1); | ||
const [request] = webhookReceiver.requestList; | ||
const body = request.body; | ||
// remove dynamic properties that differs depending on where you run the tests | ||
const dynamic = "[redacted/dynamic]"; | ||
// @ts-expect-error we are modifying the object | ||
body.createdAt = dynamic; | ||
expect(body).toMatchObject({ | ||
triggerEvent: "BOOKING_NO_SHOW_UPDATED", | ||
createdAt: "[redacted/dynamic]", | ||
payload: { | ||
message: "[email protected] marked as no-show", | ||
attendees: [{ email: "[email protected]", noShow: true, utcOffset: null }], | ||
bookingUid: bookingWhereFirstUserIsOrganizer?.uid, | ||
}, | ||
}); | ||
webhookReceiver.close(); | ||
}); | ||
test("Mark 3rd attendee as no-show", async ({ page, users, bookings }) => { | ||
const firstUser = await users.create(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { expect, type Page } from "@playwright/test"; | ||
|
||
import { createHttpServer } from "../lib/testUtils"; | ||
|
||
export function createWebhookPageFixture(page: Page) { | ||
return { | ||
createTeamReceiver: async () => { | ||
const webhookReceiver = createHttpServer(); | ||
await page.goto(`/settings/developer/webhooks`); | ||
await page.click('[data-testid="new_webhook"]'); | ||
await page.click('[data-testid="option-team-1"]'); | ||
await page.waitForURL((u) => u.pathname === "/settings/developer/webhooks/new"); | ||
const url = page.url(); | ||
const teamId = Number(new URL(url).searchParams.get("teamId")) as number; | ||
await page.click('[data-testid="new_webhook"]'); | ||
await page.fill('[name="subscriberUrl"]', webhookReceiver.url); | ||
await page.fill('[name="secret"]', "secret"); | ||
await Promise.all([ | ||
page.click("[type=submit]"), | ||
page.waitForURL((url) => url.pathname.endsWith("/settings/developer/webhooks")), | ||
]); | ||
expect(page.locator(`text='${webhookReceiver.url}'`)).toBeDefined(); | ||
return { webhookReceiver, teamId }; | ||
}, | ||
createReceiver: async () => { | ||
const webhookReceiver = createHttpServer(); | ||
await page.goto(`/settings/developer/webhooks`); | ||
await page.click('[data-testid="new_webhook"]'); | ||
await page.fill('[name="subscriberUrl"]', webhookReceiver.url); | ||
await page.fill('[name="secret"]', "secret"); | ||
await Promise.all([ | ||
page.click("[type=submit]"), | ||
page.waitForURL((url) => url.pathname.endsWith("/settings/developer/webhooks")), | ||
]); | ||
expect(page.locator(`text='${webhookReceiver.url}'`)).toBeDefined(); | ||
return webhookReceiver; | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.