feat: OOO webhook and zapier (#15434)

* zapier and webhook

* instructions for zapier

* Fix types

* fix types

* revert adding zap template

* Update packages/app-store/zapier/README.md

Co-authored-by: Carina Wollendorfer <[email protected]>

* Update packages/app-store/zapier/README.md

Co-authored-by: Carina Wollendorfer <[email protected]>

* Update packages/app-store/zapier/README.md

Co-authored-by: Carina Wollendorfer <[email protected]>

* Update packages/features/webhooks/lib/scheduleTrigger.ts

Co-authored-by: Carina Wollendorfer <[email protected]>

* wip

* Fixes from comments, no more sendPayloadNoBooking

* fix subscriberOptions teamIds param type

* types

* Update packages/features/webhooks/lib/sendPayload.ts

* Re add zapierPayload to don't break old zaps

* instead of metadata use oooEntry inside webhookPayload

* undo comment message

* Types

* reset changes on yarn.lock

* review changes

* fix types

* fix types

* tentative fix for types in webhook

* type improvements

* fix description + clean up

* revert yarn.lock changes

* allow custom template for ooo entry

* type fixes

* type fix

* fix donwloadLinks in payload

* simplify some types

* allow array or number for teamId

* same payload for test trigger

* code clean up

* fix no show e2e test

* translate text for webhook payload and fix conditional

* add test for ooo_created webhooks

* reset files

* merge fix

* fix test data test id

* remove unused variable

* only trigger for accepted memberships

* remove unused variable

---------

Co-authored-by: Carina Wollendorfer <[email protected]>
Co-authored-by: CarinaWolli <[email protected]>
Co-authored-by: Udit Takkar <[email protected]>
Co-authored-by: Keith Williams <[email protected]>
Co-authored-by: Omar López <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-09-06 15:48:05 -04:00
1 parent 105e7d3e28
commit f5c16f0d6b
27 files changed
+606 -126

No files matched your search

+1 -1
View File
@@ -107,7 +107,7 @@ test.describe("Bookings", () => {
createdAt: "[redacted/dynamic]",
payload: {
message: "[email protected] marked as no-show",
attendees: [{ email: "[email protected]", noShow: true, utcOffset: null }],
attendees: [{ email: "[email protected]", noShow: true }],
bookingUid: bookingWhereFirstUserIsOrganizer?.uid,
bookingId: bookingWhereFirstUserIsOrganizer?.id,
},
+136
View File
@@ -741,3 +741,139 @@ test.describe("FORM_SUBMITTED", async () => {
webhookReceiver.close();
});
});
test.describe("OOO_CREATED", async () => {
test("on creating an OOO, triggers OOO webhook", async ({ page, users, webhooks }) => {
const user = await users.create();
await user.apiLogin();
const webhookReceiver = await webhooks.createReceiver();
await page.goto("/settings/my-account/out-of-office");
await page.getByTestId("add_entry_ooo").click();
await page.getByTestId("reason_select").click();
await page.getByTestId("select-option-4").click();
await page.getByTestId("notes_input").click();
await page.getByTestId("notes_input").fill("Demo notes");
await page.getByTestId("create-or-edit-entry-ooo-redirect").click();
await expect(page.locator(`data-testid=table-redirect-n-a`)).toBeVisible();
await webhookReceiver.waitForRequestCount(1);
const [request] = webhookReceiver.requestList;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const body = request.body as any;
body.createdAt = dynamic;
body.payload.oooEntry.createdAt = dynamic;
body.payload.oooEntry.updatedAt = dynamic;
body.payload.oooEntry.end = dynamic;
body.payload.oooEntry.id = dynamic;
body.payload.oooEntry.start = dynamic;
body.payload.oooEntry.updatedAt = dynamic;
body.payload.oooEntry.user.id = dynamic;
body.payload.oooEntry.user.email = dynamic;
body.payload.oooEntry.user.username = dynamic;
body.payload.oooEntry.uuid = dynamic;
expect(body).toEqual({
createdAt: "[redacted/dynamic]",
payload: {
oooEntry: {
createdAt: "[redacted/dynamic]",
end: "[redacted/dynamic]",
id: "[redacted/dynamic]",
notes: "Demo notes",
reason: {
emoji: "🤒",
reason: "ooo_reasons_sick_leave",
},
reasonId: 4,
start: "[redacted/dynamic]",
toUser: null,
updatedAt: "[redacted/dynamic]",
user: {
id: "[redacted/dynamic]",
email: "[redacted/dynamic]",
name: null,
timeZone: "Europe/London",
username: "[redacted/dynamic]",
},
uuid: "[redacted/dynamic]",
},
},
triggerEvent: "OOO_CREATED",
});
webhookReceiver.close();
});
test("on creating an OOO inside a team, triggers OOO webhook", async ({ page, users, webhooks }) => {
const user = await users.create(null, {
hasTeam: true,
});
await user.apiLogin();
const { webhookReceiver, teamId } = await webhooks.createTeamReceiver();
await page.goto("/settings/my-account/out-of-office");
await page.getByTestId("add_entry_ooo").click();
await page.getByTestId("reason_select").click();
await page.getByTestId("select-option-4").click();
await page.getByTestId("notes_input").click();
await page.getByTestId("notes_input").fill("Demo notes");
await page.getByTestId("create-or-edit-entry-ooo-redirect").click();
await expect(page.locator(`data-testid=table-redirect-n-a`)).toBeVisible();
await webhookReceiver.waitForRequestCount(1);
const [request] = webhookReceiver.requestList;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const body = request.body as any;
body.createdAt = dynamic;
body.payload.oooEntry.createdAt = dynamic;
body.payload.oooEntry.updatedAt = dynamic;
body.payload.oooEntry.end = dynamic;
body.payload.oooEntry.id = dynamic;
body.payload.oooEntry.start = dynamic;
body.payload.oooEntry.updatedAt = dynamic;
body.payload.oooEntry.user.id = dynamic;
body.payload.oooEntry.user.email = dynamic;
body.payload.oooEntry.user.username = dynamic;
body.payload.oooEntry.uuid = dynamic;
expect(body).toEqual({
triggerEvent: "OOO_CREATED",
createdAt: "[redacted/dynamic]",
payload: {
oooEntry: {
createdAt: "[redacted/dynamic]",
end: "[redacted/dynamic]",
id: "[redacted/dynamic]",
notes: "Demo notes",
reason: {
emoji: "🤒",
reason: "ooo_reasons_sick_leave",
},
reasonId: 4,
start: "[redacted/dynamic]",
toUser: null,
updatedAt: "[redacted/dynamic]",
user: {
id: "[redacted/dynamic]",
email: "[redacted/dynamic]",
name: null,
timeZone: "Europe/London",
username: "[redacted/dynamic]",
},
uuid: "[redacted/dynamic]",
},
},
});
webhookReceiver.close();
});
});