fix: Filter invalid keys and handle disabled states during booking limit transformation, with added tests (#28035)
Co-authored-by: Sahitya Chandra <[email protected]>
This commit is contained in:
1 parent
8caa062ae1
commit
4b247640a8
2 files changed
+31
-3
No files matched your search
+26
-1
@@ -22,7 +22,6 @@ import type {
|
|||||||
SeatOptionsDisabledSchema,
|
SeatOptionsDisabledSchema,
|
||||||
SeatOptionsTransformedSchema,
|
SeatOptionsTransformedSchema,
|
||||||
} from "@calcom/platform-types";
|
} from "@calcom/platform-types";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
type CustomField,
|
type CustomField,
|
||||||
type SystemField,
|
type SystemField,
|
||||||
@@ -689,6 +688,32 @@ describe("transformIntervalLimitsApiToInternal", () => {
|
|||||||
|
|
||||||
expect(result).toEqual(expectedOutput);
|
expect(result).toEqual(expectedOutput);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should handle bookingLimitsCount with disabled: false and valid counts", () => {
|
||||||
|
const input: BookingLimitsCount_2024_06_14 = {
|
||||||
|
day: 5,
|
||||||
|
disabled: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
const expectedOutput = {
|
||||||
|
PER_DAY: 5,
|
||||||
|
};
|
||||||
|
const result = transformIntervalLimitsApiToInternal(input);
|
||||||
|
|
||||||
|
expect(result).toEqual(expectedOutput);
|
||||||
|
expect(result).not.toHaveProperty("undefined");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle bookingLimitsCount with disabled: true", () => {
|
||||||
|
const input: BookingLimitsCount_2024_06_14 = {
|
||||||
|
disabled: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
const expectedOutput = {};
|
||||||
|
const result = transformIntervalLimitsApiToInternal(input);
|
||||||
|
|
||||||
|
expect(result).toEqual(expectedOutput);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("transformFutureBookingLimitsApiToInternal", () => {
|
describe("transformFutureBookingLimitsApiToInternal", () => {
|
||||||
|
|||||||
+5
-2
@@ -1,7 +1,7 @@
|
|||||||
import { BookingLimitsEnum_2024_06_14 } from "@calcom/platform-enums";
|
import { BookingLimitsEnum_2024_06_14 } from "@calcom/platform-enums";
|
||||||
import {
|
import {
|
||||||
type CreateEventTypeInput_2024_06_14,
|
|
||||||
type BookingLimitsKeyOutputType_2024_06_14,
|
type BookingLimitsKeyOutputType_2024_06_14,
|
||||||
|
type CreateEventTypeInput_2024_06_14,
|
||||||
type TransformBookingLimitsSchema_2024_06_14,
|
type TransformBookingLimitsSchema_2024_06_14,
|
||||||
} from "@calcom/platform-types";
|
} from "@calcom/platform-types";
|
||||||
|
|
||||||
@@ -13,7 +13,10 @@ export function transformIntervalLimitsApiToInternal(
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
inputBookingLimits &&
|
inputBookingLimits &&
|
||||||
Object.entries(inputBookingLimits).map(([key, value]) => {
|
Object.entries(inputBookingLimits).forEach(([key, value]) => {
|
||||||
|
if (!(key in BookingLimitsEnum_2024_06_14)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const outputKey: BookingLimitsKeyOutputType_2024_06_14 = BookingLimitsEnum_2024_06_14[
|
const outputKey: BookingLimitsKeyOutputType_2024_06_14 = BookingLimitsEnum_2024_06_14[
|
||||||
key as keyof typeof BookingLimitsEnum_2024_06_14
|
key as keyof typeof BookingLimitsEnum_2024_06_14
|
||||||
] satisfies BookingLimitsKeyOutputType_2024_06_14;
|
] satisfies BookingLimitsKeyOutputType_2024_06_14;
|
||||||
|
|||||||
Reference in new issue
Block a user