test: Add tests for Booker component (#19051)
* 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 * Add tests booker * Support minimu booking check too * change data-testid * Rneame * Fix race condition with uid cookie not set * fix tests * Remove unsded variable * fixup! Merge branch 'main' into dont-allow-booking-form-with-unavaialble-slot * Fix the unavailability bug when only seconds differ * Handle column view that doesnt have selected date and also add tests for isTimeSlotAavailable * Fi ts and unit tests --------- Co-authored-by: Hariom Balhara <[email protected]> Co-authored-by: Udit Takkar <[email protected]> Co-authored-by: Morgan <[email protected]> Co-authored-by: Morgan Vernay <[email protected]>
This commit is contained in:
20 files changed
+508
-7
No files matched your search
@@ -6,6 +6,20 @@ const mockedConstants = {
|
||||
IS_PRODUCTION: false,
|
||||
IS_TEAM_BILLING_ENABLED: false,
|
||||
WEBSITE_URL: "",
|
||||
PUBLIC_INVALIDATE_AVAILABLE_SLOTS_ON_BOOKING_FORM: true,
|
||||
CLOUDFLARE_SITE_ID: "test-site-id",
|
||||
CLOUDFLARE_USE_TURNSTILE_IN_BOOKER: "1",
|
||||
DEFAULT_LIGHT_BRAND_COLOR: "#292929",
|
||||
DEFAULT_DARK_BRAND_COLOR: "#fafafa",
|
||||
CALCOM_VERSION: "0.0.0",
|
||||
IS_SELF_HOSTED: false,
|
||||
SEO_IMG_DEFAULT: "https://cal.com/og-image.png",
|
||||
SEO_IMG_OGIMG: "https://cal.com/og-image-wide.png",
|
||||
SEO_IMG_LOGO: "https://cal.com/logo.png",
|
||||
CURRENT_TIMEZONE: "Europe/London",
|
||||
APP_NAME: "Cal.com",
|
||||
BOOKER_NUMBER_OF_DAYS_TO_LOAD: 14,
|
||||
PUBLIC_QUICK_AVAILABILITY_ROLLOUT: 100,
|
||||
} as typeof constants;
|
||||
|
||||
vi.mock("@calcom/lib/constants", () => {
|
||||
@@ -31,4 +45,11 @@ export const constantsScenarios = {
|
||||
// @ts-ignore
|
||||
mockedConstants.WEBSITE_URL = url;
|
||||
},
|
||||
set: (envVariables: Record<string, string>) => {
|
||||
Object.entries(envVariables).forEach(([key, value]) => {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
mockedConstants[key] = value;
|
||||
});
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
import { vi } from "vitest";
|
||||
|
||||
const mockLogger = {
|
||||
debug: vi.fn(),
|
||||
error: vi.fn(),
|
||||
info: vi.fn(),
|
||||
log: vi.fn(),
|
||||
warn: vi.fn(),
|
||||
getSubLogger: vi.fn(),
|
||||
};
|
||||
|
||||
vi.mock("@calcom/lib/logger", () => ({
|
||||
default: mockLogger,
|
||||
}));
|
||||
|
||||
export default mockLogger;
|
||||
@@ -0,0 +1,17 @@
|
||||
vi.mock("@calcom/lib/next-seo.config", () => ({
|
||||
default: {
|
||||
headSeo: {
|
||||
siteName: "Cal.com",
|
||||
},
|
||||
defaultNextSeo: {
|
||||
title: "Cal.com",
|
||||
description: "Scheduling infrastructure for everyone.",
|
||||
},
|
||||
},
|
||||
seoConfig: {
|
||||
headSeo: {
|
||||
siteName: "Cal.com",
|
||||
},
|
||||
},
|
||||
buildSeoMeta: vi.fn().mockReturnValue({}),
|
||||
}));
|
||||
Reference in new issue
Block a user