* feat: Don't allow unavailable slot's booking form to be visible - Send back to slots listing * Improvements * feat: Add env variables and strategies to prevent booking failures - Added new environment variables for configuring slot reservation and availability checks - Implemented strategies to handle concurrent bookings and slot availability - Updated Booker component and related files to support new reservation and slot checking mechanisms - Added README with detailed explanation of booking prevention strategies - Configured dynamic intervals for slot and reservation queries * docs: Update Booker README with detailed slot reservation and availability explanation - Clarified slot reservation behavior when multiple users access the same booking page - Added details about `getSchedule` refetching strategies and timing - Explained how slot availability is detected and communicated to users * Support for skip confirmation form flow * feat: Enhance slot availability and reservation mechanism - Refactored slot availability checking to support multiple slots - Added tentative selected timeslots to improve booking UX - Updated trpc handler to check availability for multiple slots - Introduced new store methods for managing tentative slot selections - Improved slot reservation and availability status tracking * refactor: Improve slot availability quick check mechanism - Renamed and restructured slot availability check parameters - Extracted quick availability checks into a separate hook - Updated type definitions for slot status and availability checks - Simplified slot availability logic in Booker and related components - Maintained cached state for quick availability checks * Support minimu booking check too * change data-testid * Rneame * Fix race condition with uid cookie not set * fix tests * Remove unsded variable --------- Co-authored-by: Hariom Balhara <hariombalhara@gmgmail.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
48 lines
1.9 KiB
TypeScript
48 lines
1.9 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { isSlotEquivalent } from "../../utils/isSlotEquivalent";
|
|
|
|
describe("isSlotEquivalent", () => {
|
|
it("should return true for exactly matching slots", () => {
|
|
const slotTimeInIso = "2024-02-08T10:30:00.000Z";
|
|
const slotToCheckInIso = "2024-02-08T10:30:00.000Z";
|
|
expect(isSlotEquivalent({ slotTimeInIso, slotToCheckInIso })).toBe(true);
|
|
});
|
|
|
|
it("should return true when only seconds differ", () => {
|
|
const slotTimeInIso = "2024-02-08T10:30:00.000Z";
|
|
const slotToCheckInIso = "2024-02-08T10:30:45.000Z";
|
|
expect(isSlotEquivalent({ slotTimeInIso, slotToCheckInIso })).toBe(true);
|
|
});
|
|
|
|
it("should return false for different minutes", () => {
|
|
const slotTimeInIso = "2024-02-08T10:30:00.000Z";
|
|
const slotToCheckInIso = "2024-02-08T10:31:00.000Z";
|
|
expect(isSlotEquivalent({ slotTimeInIso, slotToCheckInIso })).toBe(false);
|
|
});
|
|
|
|
it("should return false for different hours", () => {
|
|
const slotTimeInIso = "2024-02-08T10:30:00.000Z";
|
|
const slotToCheckInIso = "2024-02-08T11:30:00.000Z";
|
|
expect(isSlotEquivalent({ slotTimeInIso, slotToCheckInIso })).toBe(false);
|
|
});
|
|
|
|
it("should return false for different dates", () => {
|
|
const slotTimeInIso = "2024-02-08T10:30:00.000Z";
|
|
const slotToCheckInIso = "2024-02-09T10:30:00.000Z";
|
|
expect(isSlotEquivalent({ slotTimeInIso, slotToCheckInIso })).toBe(false);
|
|
});
|
|
|
|
it("should return true for invalid ISO string formats", () => {
|
|
const slotTimeInIso = "2024-2-8T10:30:00.000Z";
|
|
const slotToCheckInIso = "2024-02-08T10:30:00.000Z";
|
|
expect(isSlotEquivalent({ slotTimeInIso, slotToCheckInIso })).toBe(true);
|
|
});
|
|
|
|
it("should return true when both inputs are invalid", () => {
|
|
const slotTimeInIso = "invalid-date-1";
|
|
const slotToCheckInIso = "invalid-date-2";
|
|
expect(isSlotEquivalent({ slotTimeInIso, slotToCheckInIso })).toBe(true);
|
|
});
|
|
});
|