2022-09-22 17:23:43 +00:00
|
|
|
import { expect } from "@playwright/test";
|
|
|
|
|
|
|
|
import { test } from "./lib/fixtures";
|
|
|
|
import { createHttpServer, selectFirstAvailableTimeSlotNextMonth, waitFor } from "./lib/testUtils";
|
|
|
|
|
2023-03-01 20:18:51 +00:00
|
|
|
test.afterEach(({ users }) => users.deleteAll());
|
|
|
|
|
2022-09-22 17:23:43 +00:00
|
|
|
test("add webhook & test that creating an event triggers a webhook call", async ({
|
|
|
|
page,
|
|
|
|
users,
|
|
|
|
}, testInfo) => {
|
|
|
|
const webhookReceiver = createHttpServer();
|
|
|
|
const user = await users.create();
|
|
|
|
const [eventType] = user.eventTypes;
|
|
|
|
await user.login();
|
|
|
|
await page.goto(`/settings/developer/webhooks`);
|
|
|
|
|
|
|
|
// --- add webhook
|
|
|
|
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]"),
|
2023-05-02 16:58:39 +00:00
|
|
|
page.waitForURL((url) => url.pathname.endsWith("/settings/developer/webhooks")),
|
2022-09-22 17:23:43 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
// page contains the url
|
|
|
|
expect(page.locator(`text='${webhookReceiver.url}'`)).toBeDefined();
|
|
|
|
|
|
|
|
// --- Book the first available day next month in the pro user's "30min"-event
|
|
|
|
await page.goto(`/${user.username}/${eventType.slug}`);
|
|
|
|
await selectFirstAvailableTimeSlotNextMonth(page);
|
|
|
|
|
|
|
|
// --- fill form
|
|
|
|
await page.fill('[name="name"]', "Test Testson");
|
|
|
|
await page.fill('[name="email"]', "test@example.com");
|
|
|
|
await page.press('[name="email"]', "Enter");
|
|
|
|
|
|
|
|
// --- check that webhook was called
|
|
|
|
await waitFor(() => {
|
|
|
|
expect(webhookReceiver.requestList.length).toBe(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
const [request] = webhookReceiver.requestList;
|
|
|
|
const body = request.body as any;
|
|
|
|
|
|
|
|
// remove dynamic properties that differs depending on where you run the tests
|
|
|
|
const dynamic = "[redacted/dynamic]";
|
|
|
|
body.createdAt = dynamic;
|
|
|
|
body.payload.startTime = dynamic;
|
|
|
|
body.payload.endTime = dynamic;
|
|
|
|
body.payload.location = dynamic;
|
|
|
|
for (const attendee of body.payload.attendees) {
|
|
|
|
attendee.timeZone = dynamic;
|
|
|
|
attendee.language = dynamic;
|
|
|
|
}
|
2022-12-22 00:15:51 +00:00
|
|
|
body.payload.organizer.id = dynamic;
|
2022-09-22 17:23:43 +00:00
|
|
|
body.payload.organizer.email = dynamic;
|
|
|
|
body.payload.organizer.timeZone = dynamic;
|
|
|
|
body.payload.organizer.language = dynamic;
|
|
|
|
body.payload.uid = dynamic;
|
|
|
|
body.payload.bookingId = dynamic;
|
|
|
|
body.payload.additionalInformation = dynamic;
|
|
|
|
body.payload.requiresConfirmation = dynamic;
|
|
|
|
body.payload.eventTypeId = dynamic;
|
2022-12-01 15:20:01 +00:00
|
|
|
body.payload.videoCallData = dynamic;
|
|
|
|
body.payload.appsStatus = dynamic;
|
2022-12-15 21:43:07 +00:00
|
|
|
body.payload.metadata.videoCallUrl = dynamic;
|
2022-09-22 17:23:43 +00:00
|
|
|
|
2023-03-02 12:13:55 +00:00
|
|
|
expect(body).toMatchObject({
|
|
|
|
triggerEvent: "BOOKING_CREATED",
|
|
|
|
createdAt: "[redacted/dynamic]",
|
|
|
|
payload: {
|
|
|
|
type: "30 min",
|
|
|
|
title: "30 min between Nameless and Test Testson",
|
|
|
|
description: "",
|
|
|
|
additionalNotes: "",
|
|
|
|
customInputs: {},
|
|
|
|
startTime: "[redacted/dynamic]",
|
|
|
|
endTime: "[redacted/dynamic]",
|
|
|
|
organizer: {
|
|
|
|
id: "[redacted/dynamic]",
|
|
|
|
name: "Nameless",
|
|
|
|
email: "[redacted/dynamic]",
|
|
|
|
timeZone: "[redacted/dynamic]",
|
|
|
|
language: "[redacted/dynamic]",
|
|
|
|
},
|
2023-03-07 17:50:54 +00:00
|
|
|
responses: {
|
|
|
|
email: {
|
|
|
|
value: "test@example.com",
|
|
|
|
label: "email_address",
|
|
|
|
},
|
|
|
|
name: {
|
|
|
|
value: "Test Testson",
|
|
|
|
label: "your_name",
|
|
|
|
},
|
|
|
|
},
|
2023-03-02 18:15:28 +00:00
|
|
|
userFieldsResponses: {},
|
2023-03-02 12:13:55 +00:00
|
|
|
attendees: [
|
|
|
|
{
|
|
|
|
email: "test@example.com",
|
|
|
|
name: "Test Testson",
|
|
|
|
timeZone: "[redacted/dynamic]",
|
|
|
|
language: "[redacted/dynamic]",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
location: "[redacted/dynamic]",
|
|
|
|
destinationCalendar: null,
|
|
|
|
hideCalendarNotes: false,
|
|
|
|
requiresConfirmation: "[redacted/dynamic]",
|
|
|
|
eventTypeId: "[redacted/dynamic]",
|
|
|
|
seatsShowAttendees: true,
|
|
|
|
seatsPerTimeSlot: null,
|
|
|
|
uid: "[redacted/dynamic]",
|
|
|
|
eventTitle: "30 min",
|
|
|
|
eventDescription: null,
|
|
|
|
price: 0,
|
|
|
|
currency: "usd",
|
|
|
|
length: 30,
|
|
|
|
bookingId: "[redacted/dynamic]",
|
|
|
|
metadata: { videoCallUrl: "[redacted/dynamic]" },
|
|
|
|
status: "ACCEPTED",
|
|
|
|
additionalInformation: "[redacted/dynamic]",
|
|
|
|
},
|
|
|
|
});
|
2022-09-22 17:23:43 +00:00
|
|
|
|
|
|
|
webhookReceiver.close();
|
|
|
|
});
|