Files
calendar/packages/features/webhooks/lib/factory/base/BaseOOOPayloadBuilder.test.ts
T
Syed Ali ShahbazandGitHub 056922b6ee feat: add webhook versioning (#23861)
* 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
2025-12-18 09:36:22 +02:00

38 lines
1.1 KiB
TypeScript

import { describe, it, expect } from "vitest";
import { WebhookTriggerEvents } from "@calcom/prisma/enums";
import type { OOOCreatedDTO } from "../../dto/types";
import { OOOPayloadBuilder } from "../versioned/v2021-10-20/OOOPayloadBuilder";
describe("OOOPayloadBuilder (v2021-10-20)", () => {
const builder = new OOOPayloadBuilder();
describe("OOO_CREATED", () => {
it("should build payload with OOO entry", () => {
const dto: OOOCreatedDTO = {
triggerEvent: WebhookTriggerEvents.OOO_CREATED,
createdAt: "2024-01-15T10:00:00Z",
oooEntry: {
id: 1,
userId: 1,
start: "2024-01-20T00:00:00Z",
end: "2024-01-25T00:00:00Z",
reason: "Vacation",
},
};
const payload = builder.build(dto);
expect(payload.triggerEvent).toBe(WebhookTriggerEvents.OOO_CREATED);
expect(payload.createdAt).toBe("2024-01-15T10:00:00Z");
expect(payload.payload.oooEntry).toEqual({
id: 1,
userId: 1,
start: "2024-01-20T00:00:00Z",
end: "2024-01-25T00:00:00Z",
reason: "Vacation",
});
});
});
});