feat: configure availability time picker interval by env variable (#12174)

This commit is contained in:
Ash Davis authored and GitHub committed 2023-11-09 09:50:42 -05:00
1 parent 26637cda08
commit 0d1b6ea5b2
7 files changed
+54 -2

No files matched your search

@@ -326,7 +326,7 @@ interface IOption {
* 23:45:00 (End of day with enough time for 15 min booking)
*/
/** Begin Time Increments For Select */
const INCREMENT = 15;
const INCREMENT = Number(process.env.NEXT_PUBLIC_AVAILABILITY_SCHEDULE_INTERVAL) || 15;
const useOptions = () => {
// Get user so we can determine 12/24 hour format preferences
const query = useMeQuery();
+43
View File
@@ -300,3 +300,46 @@ describe("Tests the slot logic", () => {
expect(slots[0].time.format()).toBe("2023-07-13T08:00:00+05:30");
});
});
describe("Tests the date-range slot logic with custom env variable", () => {
beforeAll(() => {
vi.stubEnv("NEXT_PUBLIC_AVAILABILITY_SCHEDULE_INTERVAL", "10");
});
it("can fit 11 10 minute slots within a 2 hour window using a 10 mintue availabilty option with a starting time of 10 past the hour", async () => {
expect(Number(process.env.NEXT_PUBLIC_AVAILABILITY_SCHEDULE_INTERVAL)).toBe(10);
expect(
getSlots({
inviteeDate: dayjs.utc().add(1, "day"),
frequency: 10,
minimumBookingNotice: 0,
workingHours: [
{
userId: 1,
days: Array.from(Array(7).keys()),
startTime: 10,
endTime: 120,
},
],
eventLength: 10,
offsetStart: 0,
organizerTimeZone: "America/Toronto",
})
).toHaveLength(11);
});
it("test buildSlotsWithDateRanges using a 10 mintue interval", async () => {
expect(Number(process.env.NEXT_PUBLIC_AVAILABILITY_SCHEDULE_INTERVAL)).toBe(10);
expect(
getSlots({
inviteeDate: dayjs.utc().add(1, "day"),
frequency: 10,
minimumBookingNotice: 0,
eventLength: 10,
offsetStart: 0,
organizerTimeZone: "America/Toronto",
dateRanges: [{ start: dayjs("2023-07-13T00:10:00.000Z"), end: dayjs("2023-07-13T02:00:00.000Z") }],
})
).toHaveLength(11);
});
});
+1 -1
View File
@@ -169,7 +169,7 @@ function buildSlotsWithDateRanges({
? range.start
: startTimeWithMinNotice;
let interval = 15;
let interval = Number(process.env.NEXT_PUBLIC_AVAILABILITY_SCHEDULE_INTERVAL) || 15;
const intervalsWithDefinedStartTimes = [60, 30, 20, 10];
+1
View File
@@ -11,6 +11,7 @@ declare namespace NodeJS {
/** @deprecated use `NEXT_PUBLIC_WEBSITE_URL` */
readonly NEXT_PUBLIC_APP_URL: string | undefined;
readonly NEXTAUTH_SECRET: string | undefined;
readonly NEXT_PUBLIC_AVAILABILITY_SCHEDULE_INTERVAL: string | undefined;
readonly MS_GRAPH_CLIENT_ID: string | undefined;
readonly MS_GRAPH_CLIENT_SECRET: string | undefined;
readonly ZOOM_CLIENT_ID: string | undefined;