Scheduling infrastructure for absolutely everyone.
fix: preserve seatsPerTimeSlot during partial event type updates (#25450)
Morgand15281160fdd
diff --git a/apps/api/v2/src/ee/event-types/event-types_2024_06_14/services/input-event-types.service.ts b/apps/api/v2/src/ee/event-types/event-types_2024_06_14/services/input-event-types.service.tsindex c904901e890..879ba789a3a 100644--- a/apps/api/v2/src/ee/event-types/event-types_2024_06_14/services/input-event-types.service.ts+++ b/apps/api/v2/src/ee/event-types/event-types_2024_06_14/services/input-event-types.service.ts@@ -252,7 +252,7 @@ export class InputEventTypesService_2024_06_14 {requiresConfirmationWillBlockSlot:confirmationPolicyTransformed?.requiresConfirmationWillBlockSlot ?? undefined,eventTypeColor: this.transformInputEventTypeColor(color),- ...this.transformInputSeatOptions(seats),+ ...(seats ? this.transformInputSeatOptions(seats) : { seatsPerTimeSlot: undefined }),eventName: customName,useEventTypeDestinationCalendarEmail: useDestinationCalendarEmail,...maxActiveBookingsPerBooker,diff --git a/apps/api/v2/src/modules/organizations/event-types/organizations-member-team-admin-event-types.e2e-spec.ts b/apps/api/v2/src/modules/organizations/event-types/organizations-member-team-admin-event-types.e2e-spec.tsindex db232ff21f1..5558717d14d 100644--- a/apps/api/v2/src/modules/organizations/event-types/organizations-member-team-admin-event-types.e2e-spec.ts+++ b/apps/api/v2/src/modules/organizations/event-types/organizations-member-team-admin-event-types.e2e-spec.ts@@ -1230,6 +1230,70 @@ describe("Organizations Event Types Endpoints", () => {});});+ it("should preserve seatsPerTimeSlot when doing partial update", async () => {+ const createBody: CreateTeamEventTypeInput_2024_06_14 = {+ title: "Coding consultation with seats",+ slug: `organizations-event-types-seats-${randomString()}`,+ description: "Our team will review your codebase.",+ lengthInMinutes: 60,+ locations: [+ {+ type: "integration",+ integration: "cal-video",+ },+ ],+ schedulingType: "COLLECTIVE",+ hosts: [+ {+ userId: teammate1.id,+ },+ ],+ seats: {+ seatsPerTimeSlot: 5,+ showAttendeeInfo: true,+ showAvailabilityCount: true,+ },+ };++ const createResponse = await request(app.getHttpServer())+ .post(`/v2/organizations/${org.id}/teams/${team.id}/event-types`)+ .send(createBody)+ .expect(201);++ const createdEventType: TeamEventTypeOutput_2024_06_14 = createResponse.body.data;+ const createdSeats = createdEventType.seats;+ expect(createdSeats).toBeDefined();+ expect(createdSeats && "seatsPerTimeSlot" in createdSeats).toBe(true);+ if (createdSeats && "seatsPerTimeSlot" in createdSeats) {+ expect(createdSeats.seatsPerTimeSlot).toEqual(5);+ expect(createdSeats.showAttendeeInfo).toEqual(true);+ expect(createdSeats.showAvailabilityCount).toEqual(true);+ }++ // Now do a partial update that only changes a different field (not seats)+ const updateBody: UpdateTeamEventTypeInput_2024_06_14 = {+ bookingRequiresAuthentication: false,+ };++ const updateResponse = await request(app.getHttpServer())+ .patch(`/v2/organizations/${org.id}/teams/${team.id}/event-types/${createdEventType.id}`)+ .send(updateBody)+ .expect(200);++ const updatedEventType: TeamEventTypeOutput_2024_06_14 = updateResponse.body.data;++ // Verify that seatsPerTimeSlot is preserved and not reset to null+ const updatedSeats = updatedEventType.seats;+ expect(updatedSeats).toBeDefined();+ expect(updatedSeats && "seatsPerTimeSlot" in updatedSeats).toBe(true);+ if (updatedSeats && "seatsPerTimeSlot" in updatedSeats) {+ expect(updatedSeats.seatsPerTimeSlot).toEqual(5);+ expect(updatedSeats.showAttendeeInfo).toEqual(true);+ expect(updatedSeats.showAvailabilityCount).toEqual(true);+ }+ expect(updatedEventType.bookingRequiresAuthentication).toEqual(false);+ });+function evaluateHost(expected: Host, received: Host | undefined) {expect(expected.userId).toEqual(received?.userId);expect(expected.mandatory).toEqual(received?.mandatory);