* add webhook version schema * version the code * update version from numeric to date val * migration * update schema and build factory * update string * move version picker * tooltip instead of infobadge * -- * fix type * -- * fix type * fix type * -- * fix messed up merge * improvements to payloadfactory * extract version off of DB and instead keep it in IWebhookRepository * fix webhookform * fix type safety and routing ambiguity * scalable with easier factory extensions and base definition * fix types * -- * -- * clean up prisma/client type imports * fix * type fix * type fix * cleanup * add tests and registry changes * unintended file inclusion * type-fix * select in repo * -- * explicit return type * -- * fix type * fixes * feedback 1 * feedback 2 * use enum instead of string * fixes
52 lines
1.7 KiB
TypeScript
52 lines
1.7 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { WebhookTriggerEvents } from "@calcom/prisma/enums";
|
|
|
|
import type { MeetingStartedDTO, MeetingEndedDTO } from "../../dto/types";
|
|
import { MeetingPayloadBuilder } from "../versioned/v2021-10-20/MeetingPayloadBuilder";
|
|
|
|
describe("MeetingPayloadBuilder (v2021-10-20)", () => {
|
|
const builder = new MeetingPayloadBuilder();
|
|
|
|
const mockBookingData = {
|
|
id: 1,
|
|
uid: "booking-uid-123",
|
|
title: "Test Meeting",
|
|
startTime: "2024-01-15T10:00:00Z",
|
|
endTime: "2024-01-15T10:30:00Z",
|
|
};
|
|
|
|
describe("MEETING_STARTED", () => {
|
|
it("should build payload with booking data", () => {
|
|
const dto: MeetingStartedDTO = {
|
|
triggerEvent: WebhookTriggerEvents.MEETING_STARTED,
|
|
createdAt: "2024-01-15T10:00:00Z",
|
|
booking: mockBookingData,
|
|
};
|
|
|
|
const payload = builder.build(dto);
|
|
|
|
expect(payload.triggerEvent).toBe(WebhookTriggerEvents.MEETING_STARTED);
|
|
expect(payload.createdAt).toBe("2024-01-15T10:00:00Z");
|
|
expect(payload.payload.id).toBe(1);
|
|
expect(payload.payload.uid).toBe("booking-uid-123");
|
|
expect(payload.payload.title).toBe("Test Meeting");
|
|
});
|
|
});
|
|
|
|
describe("MEETING_ENDED", () => {
|
|
it("should build payload with booking data", () => {
|
|
const dto: MeetingEndedDTO = {
|
|
triggerEvent: WebhookTriggerEvents.MEETING_ENDED,
|
|
createdAt: "2024-01-15T10:30:00Z",
|
|
booking: mockBookingData,
|
|
};
|
|
|
|
const payload = builder.build(dto);
|
|
|
|
expect(payload.triggerEvent).toBe(WebhookTriggerEvents.MEETING_ENDED);
|
|
expect(payload.createdAt).toBe("2024-01-15T10:30:00Z");
|
|
expect(payload.payload).toEqual(mockBookingData);
|
|
});
|
|
});
|
|
});
|