fix: No available users found (#13738)
* fix: No available users found * Update getUserAvailability.ts * Update getUserAvailability.ts * Update handleNewBooking.ts * Reusing the parsed dates throughout the full stack * Fixed typo * Added unit tests for stringToDayjs * Fixing types * Reverted the getSchedule utc change since that endpoint takes in UTC formatted dates but with a given timezone * chore: Add test replicating 'no available users' error * Test is passing * Name clarifications * Test clean up * Update packages/features/bookings/lib/handleNewBooking.ts Co-authored-by: Omar López <[email protected]> * Update handleNewBooking.ts * Fixed issue where date overrides ending at midnight don't allow bookings * Removed comment --------- Co-authored-by: Omar López <[email protected]>
This commit is contained in:
1 parent
008e0e43a2
commit
71574488c5
4 files changed
+459
-13
No files matched your search
@@ -0,0 +1,50 @@
|
||||
import { describe, expect, it, beforeAll, vi } from "vitest";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { stringToDayjs } from "@calcom/prisma/zod-utils";
|
||||
|
||||
beforeAll(() => {
|
||||
vi.setSystemTime(dayjs.utc("2021-06-20T11:59:59Z").toDate());
|
||||
});
|
||||
|
||||
describe("Tests the parsing logic", () => {
|
||||
it("when supplied with no timezone data", async () => {
|
||||
const date = stringToDayjs("2024-02-27T17:00:00");
|
||||
expect(date.toISOString()).toBe("2024-02-27T17:00:00.000Z");
|
||||
});
|
||||
|
||||
it("when supplied with UTC", async () => {
|
||||
const date = stringToDayjs("2024-02-27T17:00:00Z");
|
||||
expect(date.year()).toBe(2024);
|
||||
expect(date.month()).toBe(1);
|
||||
expect(date.date()).toBe(27);
|
||||
expect(date.hour()).toBe(17);
|
||||
expect(date.minute()).toBe(0);
|
||||
expect(date.second()).toBe(0);
|
||||
expect(date.utcOffset()).toBe(0);
|
||||
});
|
||||
|
||||
it("when supplied with UTC- timezone", async () => {
|
||||
const date = stringToDayjs("2024-02-27T17:00:00-05:00");
|
||||
expect(date.year()).toBe(2024);
|
||||
expect(date.month()).toBe(1);
|
||||
expect(date.date()).toBe(27);
|
||||
expect(date.hour()).toBe(17);
|
||||
expect(date.minute()).toBe(0);
|
||||
expect(date.second()).toBe(0);
|
||||
expect(date.utcOffset()).toBe(-300);
|
||||
expect(date.toISOString()).toBe("2024-02-27T22:00:00.000Z");
|
||||
});
|
||||
|
||||
it("when supplied with UTC+ timezone", async () => {
|
||||
const date = stringToDayjs("2024-02-27T17:00:00+05:00");
|
||||
expect(date.year()).toBe(2024);
|
||||
expect(date.month()).toBe(1);
|
||||
expect(date.date()).toBe(27);
|
||||
expect(date.hour()).toBe(17);
|
||||
expect(date.minute()).toBe(0);
|
||||
expect(date.second()).toBe(0);
|
||||
expect(date.utcOffset()).toBe(300);
|
||||
expect(date.toISOString()).toBe("2024-02-27T12:00:00.000Z");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user