fix: hide cal branding on platform workflows (#27385)

* fix: hide cal branding on platform workflows

* refactor: rely on existing with platform variables code

* revert: comment

* fix e2e

* chore: remove unit results
This commit is contained in:
Lauris Skraucis
2026-02-09 13:46:52 -03:00
committed by GitHub
parent f66fffd13b
commit edf9cd70dd
9 changed files with 90 additions and 32 deletions
@@ -611,6 +611,10 @@ export class BookingsController_2024_04_15 {
...clone.body,
noEmail: oAuthParams === undefined ? false : !oAuthParams.arePlatformEmailsEnabled,
creationSource: CreationSource.API_V2,
metadata: {
...(clone.body.metadata || {}),
...(oAuthClientId && { platformClientId: oAuthClientId }),
},
};
if (oAuthClientId) {
await this.setPlatformAttendeesEmails(clone.body, oAuthClientId);
@@ -515,7 +515,7 @@ describe("Bookings Endpoints 2024-08-13", () => {
expect(updatedAtDate?.getTime()).toBeGreaterThanOrEqual(beforeCreate.getTime());
expect(updatedAtDate?.getTime()).toBeLessThanOrEqual(afterCreate.getTime());
expect(data.metadata).toEqual(body.metadata);
expect(data.metadata).toEqual({...body.metadata, platformClientId: oAuthClient.id});
createdBooking = data;
} else {
throw new Error(
@@ -2115,7 +2115,7 @@ describe("Bookings Endpoints 2024-08-13", () => {
expect(updatedAtDate?.getTime()).toBeGreaterThanOrEqual(beforeCreate.getTime());
expect(updatedAtDate?.getTime()).toBeLessThanOrEqual(afterCreate.getTime());
expect(data.metadata).toEqual(body.metadata);
expect(data.metadata).toEqual({...body.metadata, platformClientId: oAuthClient.id});
createdBooking = data;
} else {
throw new Error(
@@ -2662,16 +2662,22 @@ describe("Bookings Endpoints 2024-08-13", () => {
});
describe("calendar events", () => {
// Type assertion to access private methods for test spying
const eventManagerProto = EventManager.prototype as unknown as Record<
"createAllCalendarEvents" | "createAllCRMEvents",
(...args: unknown[]) => Promise<unknown[]>
>;
beforeEach(() => {
jest.restoreAllMocks();
jest
.spyOn(EventManager.prototype, "create")
.mockImplementation(() => Promise.resolve({ results: [], referencesToCreate: [] }));
jest
.spyOn(EventManager.prototype, "createAllCalendarEvents")
.spyOn(eventManagerProto, "createAllCalendarEvents")
.mockImplementation(() => Promise.resolve([]));
jest
.spyOn(EventManager.prototype, "createAllCRMEvents")
.spyOn(eventManagerProto, "createAllCRMEvents")
.mockImplementation(() => Promise.resolve([]));
});
@@ -2843,8 +2849,8 @@ describe("Bookings Endpoints 2024-08-13", () => {
const data: BookingOutput_2024_08_13 = responseBody.data;
expect(data.id).toBeDefined();
expect(data.uid).toBeDefined();
expect(EventManager.prototype.createAllCalendarEvents).toHaveBeenCalledTimes(0);
expect(EventManager.prototype.createAllCRMEvents).toHaveBeenCalledTimes(0);
expect(eventManagerProto.createAllCalendarEvents).toHaveBeenCalledTimes(0);
expect(eventManagerProto.createAllCRMEvents).toHaveBeenCalledTimes(0);
} else {
throw new Error(
"Invalid response data - expected booking but received array of possibly recurring bookings"
@@ -2874,8 +2880,8 @@ describe("Bookings Endpoints 2024-08-13", () => {
const responseBody: CreateBookingOutput_2024_08_13 = response.body;
expect(responseBody.status).toEqual(SUCCESS_STATUS);
expect(responseBody.data).toBeDefined();
expect(EventManager.prototype.createAllCalendarEvents).toHaveBeenCalledTimes(0);
expect(EventManager.prototype.createAllCRMEvents).toHaveBeenCalledTimes(0);
expect(eventManagerProto.createAllCalendarEvents).toHaveBeenCalledTimes(0);
expect(eventManagerProto.createAllCRMEvents).toHaveBeenCalledTimes(0);
});
});
@@ -2909,8 +2915,8 @@ describe("Bookings Endpoints 2024-08-13", () => {
const data: BookingOutput_2024_08_13 = responseBody.data;
expect(data.id).toBeDefined();
expect(data.uid).toBeDefined();
expect(EventManager.prototype.createAllCalendarEvents).toHaveBeenCalledTimes(0);
expect(EventManager.prototype.createAllCRMEvents).toHaveBeenCalledTimes(0);
expect(eventManagerProto.createAllCalendarEvents).toHaveBeenCalledTimes(0);
expect(eventManagerProto.createAllCRMEvents).toHaveBeenCalledTimes(0);
bookingThatRequiresConfirmationUid = data.uid;
} else {
throw new Error(
@@ -2935,8 +2941,8 @@ describe("Bookings Endpoints 2024-08-13", () => {
const data: BookingOutput_2024_08_13 = responseBody.data;
expect(data.id).toBeDefined();
expect(data.uid).toBeDefined();
expect(EventManager.prototype.createAllCalendarEvents).toHaveBeenCalledTimes(0);
expect(EventManager.prototype.createAllCRMEvents).toHaveBeenCalledTimes(0);
expect(eventManagerProto.createAllCalendarEvents).toHaveBeenCalledTimes(0);
expect(eventManagerProto.createAllCRMEvents).toHaveBeenCalledTimes(0);
} else {
throw new Error(
"Invalid response data - expected booking but received array of possibly recurring bookings"
@@ -190,7 +190,10 @@ export class InputBookingsService_2024_08_13 {
eventTypeId: inputBooking.eventTypeId,
timeZone: inputBooking.attendee.timeZone,
language: inputBooking.attendee.language || "en",
metadata: inputBooking.metadata || {},
metadata: {
...(inputBooking.metadata || {}),
...(platformClientId && { platformClientId }),
},
hasHashedBookingLink: false,
guests,
verificationCode: inputBooking.emailVerificationCode,