@wix/headless-bookings 0.0.97 → 0.0.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/cjs/dist/__mocks__/booking/booking-client-service.d.ts +9 -0
  2. package/cjs/dist/__mocks__/booking/booking-client-service.js +55 -0
  3. package/cjs/dist/__mocks__/booking/booking-mocks.d.ts +20 -0
  4. package/cjs/dist/__mocks__/booking/booking-mocks.js +76 -0
  5. package/{dist/__mocks__/services.d.ts → cjs/dist/__mocks__/services/services-mocks.d.ts} +5 -17
  6. package/cjs/dist/__mocks__/{services.js → services/services-mocks.js} +1 -27
  7. package/cjs/dist/__mocks__/time-slots/time-slots-client-service.d.ts +79 -0
  8. package/cjs/dist/__mocks__/time-slots/time-slots-client-service.js +120 -0
  9. package/{dist/__mocks__/time-slots.d.ts → cjs/dist/__mocks__/time-slots/time-slots-core.d.ts} +1 -28
  10. package/cjs/dist/__mocks__/{time-slots.js → time-slots/time-slots-core.js} +1 -115
  11. package/cjs/dist/__mocks__/time-slots/time-slots-mocks.d.ts +14 -0
  12. package/cjs/dist/__mocks__/time-slots/time-slots-mocks.js +50 -0
  13. package/cjs/dist/services/booking/booking.js +2 -1
  14. package/cjs/dist/services/constants.d.ts +12 -0
  15. package/cjs/dist/services/constants.js +11 -0
  16. package/cjs/dist/services/service-list/service-list.js +1 -0
  17. package/cjs/dist/services/time-slot-list/time-slot-list.def.js +2 -1
  18. package/cjs/dist/services/time-slot-list/time-slot.js +2 -1
  19. package/dist/__mocks__/booking/booking-client-service.d.ts +9 -0
  20. package/dist/__mocks__/booking/booking-client-service.js +55 -0
  21. package/dist/__mocks__/booking/booking-mocks.d.ts +20 -0
  22. package/dist/__mocks__/booking/booking-mocks.js +76 -0
  23. package/{cjs/dist/__mocks__/services.d.ts → dist/__mocks__/services/services-mocks.d.ts} +5 -17
  24. package/dist/__mocks__/{services.js → services/services-mocks.js} +1 -27
  25. package/dist/__mocks__/time-slots/time-slots-client-service.d.ts +79 -0
  26. package/dist/__mocks__/time-slots/time-slots-client-service.js +120 -0
  27. package/{cjs/dist/__mocks__/time-slots.d.ts → dist/__mocks__/time-slots/time-slots-core.d.ts} +1 -28
  28. package/dist/__mocks__/{time-slots.js → time-slots/time-slots-core.js} +1 -115
  29. package/dist/__mocks__/time-slots/time-slots-mocks.d.ts +14 -0
  30. package/dist/__mocks__/time-slots/time-slots-mocks.js +50 -0
  31. package/dist/services/booking/booking.js +2 -1
  32. package/dist/services/constants.d.ts +12 -0
  33. package/dist/services/constants.js +11 -0
  34. package/dist/services/service-list/service-list.js +1 -0
  35. package/dist/services/time-slot-list/time-slot-list.def.js +2 -1
  36. package/dist/services/time-slot-list/time-slot.js +2 -1
  37. package/package.json +2 -2
  38. package/cjs/dist/__mocks__/booking.d.ts +0 -87
  39. package/cjs/dist/__mocks__/booking.js +0 -229
  40. package/dist/__mocks__/booking.d.ts +0 -87
  41. package/dist/__mocks__/booking.js +0 -229
  42. /package/cjs/dist/__mocks__/{payment.d.ts → payment/payment-mocks.d.ts} +0 -0
  43. /package/cjs/dist/__mocks__/{payment.js → payment/payment-mocks.js} +0 -0
  44. /package/dist/__mocks__/{payment.d.ts → payment/payment-mocks.d.ts} +0 -0
  45. /package/dist/__mocks__/{payment.js → payment/payment-mocks.js} +0 -0
@@ -6,6 +6,7 @@
6
6
  import { defineService, implementService } from '@wix/services-definitions';
7
7
  import { SignalsServiceDefinition, } from '@wix/services-definitions/core-services/signals';
8
8
  import { executeBookAction } from './book-action/bookAction.js';
9
+ import { ClientServiceIds } from '../constants.js';
9
10
  // ============================================================================
10
11
  // Constants
11
12
  // ============================================================================
@@ -29,7 +30,7 @@ function getClientTimezone() {
29
30
  /**
30
31
  * Service definition for Booking
31
32
  */
32
- export const BookingServiceDefinition = defineService('booking');
33
+ export const BookingServiceDefinition = defineService(ClientServiceIds.booking);
33
34
  // ============================================================================
34
35
  // Service Implementation
35
36
  // ============================================================================
@@ -7,3 +7,15 @@
7
7
  export declare const BOOKING_APP_ID = "13d21c63-b5ec-5912-8397-c3a5ddb27a97";
8
8
  /** Resource type ID for staff members */
9
9
  export declare const STAFF_MEMBER_RESOURCE_TYPE_ID = "1cd44cf8-756f-41c3-bd90-3e2ffcaf1155";
10
+ export declare const ClientServiceIds: {
11
+ readonly booking: "booking";
12
+ readonly bookingForm: "bookingForm";
13
+ readonly timeSlot: "time-slot";
14
+ readonly timeSlotList: "time-slot-list";
15
+ readonly service: "service";
16
+ readonly serviceList: "service-list";
17
+ readonly payment: "payment";
18
+ readonly staffMemberList: "staff-member-list";
19
+ readonly locationList: "location-list";
20
+ };
21
+ export type ClientServiceId = (typeof ClientServiceIds)[keyof typeof ClientServiceIds];
@@ -7,3 +7,14 @@
7
7
  export const BOOKING_APP_ID = '13d21c63-b5ec-5912-8397-c3a5ddb27a97';
8
8
  /** Resource type ID for staff members */
9
9
  export const STAFF_MEMBER_RESOURCE_TYPE_ID = '1cd44cf8-756f-41c3-bd90-3e2ffcaf1155';
10
+ export const ClientServiceIds = {
11
+ booking: 'booking',
12
+ bookingForm: 'bookingForm',
13
+ timeSlot: 'time-slot',
14
+ timeSlotList: 'time-slot-list',
15
+ service: 'service',
16
+ serviceList: 'service-list',
17
+ payment: 'payment',
18
+ staffMemberList: 'staff-member-list',
19
+ locationList: 'location-list',
20
+ };
@@ -223,6 +223,7 @@ export const ServiceListService = implementService.withConfig()(ServiceListServi
223
223
  const currentPaging = pagingMetadataSignal.peek();
224
224
  try {
225
225
  isLoadingSignal.set(true);
226
+ servicesSignal.set([]);
226
227
  errorSignal.set(null);
227
228
  const result = await queryServices({
228
229
  appId: queryOptions.appId,
@@ -3,6 +3,7 @@
3
3
  * Defines interfaces and service contract for time slot management
4
4
  */
5
5
  import { defineService } from '@wix/services-definitions';
6
+ import { ClientServiceIds } from '../constants.js';
6
7
  // ============================================================================
7
8
  // Enums
8
9
  // ============================================================================
@@ -14,4 +15,4 @@ export var ViewMode;
14
15
  // ============================================================================
15
16
  // Service Definition
16
17
  // ============================================================================
17
- export const TimeSlotListServiceDefinition = defineService('time-slot-list');
18
+ export const TimeSlotListServiceDefinition = defineService(ClientServiceIds.timeSlotList);
@@ -4,10 +4,11 @@
4
4
  */
5
5
  import { defineService, implementService } from '@wix/services-definitions';
6
6
  import { SignalsServiceDefinition, } from '@wix/services-definitions/core-services/signals';
7
+ import { ClientServiceIds } from '../constants.js';
7
8
  /**
8
9
  * Service definition for TimeSlot
9
10
  */
10
- export const TimeSlotServiceDefinition = defineService('time-slot');
11
+ export const TimeSlotServiceDefinition = defineService(ClientServiceIds.timeSlot);
11
12
  /**
12
13
  * Implementation of TimeSlotService
13
14
  */
@@ -0,0 +1,9 @@
1
+ import type { Signal } from '@wix/services-definitions/core-services/signals';
2
+ import type { BookingServiceConfig, BookingService } from '../../services/booking/booking.js';
3
+ export declare function mockSignal<T>(initialValue: T): Signal<T>;
4
+ export declare function createMockSignalsService(): {
5
+ signal: typeof mockSignal;
6
+ computed: <T>(fn: () => T) => Signal<T>;
7
+ effect: (fn: () => void) => void;
8
+ };
9
+ export declare function createMockBookingService(config?: Partial<BookingServiceConfig>): BookingService;
@@ -0,0 +1,55 @@
1
+ import { vi } from 'vitest';
2
+ export function mockSignal(initialValue) {
3
+ let value = initialValue;
4
+ return {
5
+ get: () => value,
6
+ peek: () => value,
7
+ set: (newValue) => {
8
+ value = newValue;
9
+ },
10
+ };
11
+ }
12
+ export function createMockSignalsService() {
13
+ return {
14
+ signal: mockSignal,
15
+ // Re-evaluate the computed function on every get/peek (like real computed signals)
16
+ computed: (fn) => ({
17
+ get: () => fn(),
18
+ peek: () => fn(),
19
+ set: () => { }, // no-op for computed
20
+ }),
21
+ effect: vi.fn((fn) => {
22
+ fn();
23
+ }),
24
+ };
25
+ }
26
+ export function createMockBookingService(config = {}) {
27
+ const { serviceSelections = [], location = null, timezone = 'UTC', formSubmission = null, } = config;
28
+ const serviceSelectionsSignal = mockSignal(serviceSelections);
29
+ const locationSignal = mockSignal(location);
30
+ const timezoneSignal = mockSignal(timezone);
31
+ const formSubmissionSignal = mockSignal(formSubmission);
32
+ return {
33
+ serviceSelections: serviceSelectionsSignal,
34
+ location: locationSignal,
35
+ timezone: timezoneSignal,
36
+ formSubmission: formSubmissionSignal,
37
+ actions: {
38
+ updateItem: vi.fn(),
39
+ setItem: vi.fn(),
40
+ addItem: vi.fn(),
41
+ removeItem: vi.fn(),
42
+ clearItems: vi.fn(),
43
+ setResource: vi.fn(),
44
+ getResourceByType: vi.fn(),
45
+ clearResourceByType: vi.fn(),
46
+ setLocation: vi.fn(),
47
+ clearLocation: vi.fn(),
48
+ setTimezone: vi.fn(),
49
+ setFormSubmission: vi.fn(),
50
+ clearFormSubmission: vi.fn(),
51
+ clearAll: vi.fn(),
52
+ book: vi.fn(),
53
+ },
54
+ };
55
+ }
@@ -0,0 +1,20 @@
1
+ import type { FormValues } from '@wix/form-public';
2
+ import type { Location } from '@wix/auto_sdk_bookings_services';
3
+ import type { ServiceSelection, ServiceSelectionTimeSlot, ExtendedResource } from '../../services/booking/booking.js';
4
+ export declare function createMockResource(overrides?: Partial<ExtendedResource>): ExtendedResource;
5
+ export declare function createMockLocation(overrides?: Partial<Location>): Location;
6
+ export declare const mockResource: ExtendedResource;
7
+ export declare const mockResourceTwo: ExtendedResource;
8
+ export declare const mockLocation: Location;
9
+ export declare const mockLocationTwo: Location;
10
+ export declare const mockTimezone = "America/New_York";
11
+ export declare const mockTimeSlot: ServiceSelectionTimeSlot;
12
+ export declare function createMockServiceSelectionTimeSlot(overrides?: Partial<ServiceSelectionTimeSlot>): ServiceSelectionTimeSlot;
13
+ /**
14
+ * Creates a mock ServiceSelection with sensible defaults
15
+ */
16
+ export declare function createMockServiceSelection(overrides?: Partial<ServiceSelection>): ServiceSelection;
17
+ export declare const mockServiceSelection: ServiceSelection;
18
+ export declare const mockServiceSelectionWithoutTimeSlot: ServiceSelection;
19
+ export declare function createMockFormSubmission(overrides?: Partial<FormValues>): FormValues;
20
+ export declare const mockFormSubmission: FormValues;
@@ -0,0 +1,76 @@
1
+ import { mockService } from '../services/services-mocks.js';
2
+ export function createMockResource(overrides = {}) {
3
+ return {
4
+ _id: 'resource-1',
5
+ name: 'John Doe',
6
+ type: 'staff',
7
+ ...overrides,
8
+ };
9
+ }
10
+ export function createMockLocation(overrides = {}) {
11
+ return {
12
+ _id: 'location-1',
13
+ type: 'BUSINESS',
14
+ business: {
15
+ _id: 'location-1',
16
+ name: 'Main Office',
17
+ },
18
+ ...overrides,
19
+ };
20
+ }
21
+ export const mockResource = createMockResource();
22
+ export const mockResourceTwo = createMockResource({
23
+ _id: 'resource-2',
24
+ name: 'Jane Smith',
25
+ });
26
+ export const mockLocation = createMockLocation();
27
+ export const mockLocationTwo = createMockLocation({
28
+ _id: 'location-2',
29
+ business: {
30
+ _id: 'location-2',
31
+ name: 'Downtown Branch',
32
+ },
33
+ });
34
+ export const mockTimezone = 'America/New_York';
35
+ export const mockTimeSlot = createMockServiceSelectionTimeSlot();
36
+ export function createMockServiceSelectionTimeSlot(overrides = {}) {
37
+ return {
38
+ startDate: '2024-03-15T10:00:00Z',
39
+ endDate: '2024-03-15T11:00:00Z',
40
+ totalCapacity: 10,
41
+ remainingCapacity: 5,
42
+ scheduleId: 'schedule-123',
43
+ resources: [mockResource],
44
+ location: mockLocation,
45
+ ...overrides,
46
+ };
47
+ }
48
+ /**
49
+ * Creates a mock ServiceSelection with sensible defaults
50
+ */
51
+ export function createMockServiceSelection(overrides = {}) {
52
+ return {
53
+ instanceId: 'instance-1',
54
+ service: mockService,
55
+ resources: [mockResource],
56
+ timeSlot: mockTimeSlot,
57
+ totalParticipants: 1,
58
+ ...overrides,
59
+ };
60
+ }
61
+ export const mockServiceSelection = createMockServiceSelection();
62
+ export const mockServiceSelectionWithoutTimeSlot = createMockServiceSelection({
63
+ instanceId: 'instance-2',
64
+ resources: [],
65
+ timeSlot: undefined,
66
+ });
67
+ export function createMockFormSubmission(overrides = {}) {
68
+ return {
69
+ firstName: 'John',
70
+ lastName: 'Doe',
71
+ email: 'john.doe@example.com',
72
+ phone: '+1234567890',
73
+ ...overrides,
74
+ };
75
+ }
76
+ export const mockFormSubmission = createMockFormSubmission();
@@ -2,11 +2,11 @@
2
2
  * Shared mock data for booking service tests
3
3
  */
4
4
  import type { Service, StaffMember } from '@wix/auto_sdk_bookings_services';
5
- import type { ServiceServiceConfig } from '../services/service/service.js';
6
- import type { ServiceListServiceConfig } from '../services/service-list/service-list.js';
7
- import type { StaffMemberListServiceConfig } from '../services/staff-member-list/staff-member-list.js';
8
- import type { PagingMetadata } from '../api/query-services/index.js';
9
- import type { Category } from '../api/query-categories/index.js';
5
+ import type { ServiceServiceConfig } from '../../services/service/service.js';
6
+ import type { ServiceListServiceConfig } from '../../services/service-list/service-list.js';
7
+ import type { StaffMemberListServiceConfig } from '../../services/staff-member-list/staff-member-list.js';
8
+ import type { PagingMetadata } from '../../api/query-services/index.js';
9
+ import type { Category } from '../../api/query-categories/index.js';
10
10
  /**
11
11
  * Base mock service with all fields populated (APPOINTMENT type, FIXED pricing)
12
12
  */
@@ -75,22 +75,10 @@ export declare function createLargeServiceList(count: number): Service[];
75
75
  * Mock categories for filter tests
76
76
  */
77
77
  export declare const mockCategories: Category[];
78
- /**
79
- * Empty categories array
80
- */
81
- export declare const mockEmptyCategories: Category[];
82
78
  /**
83
79
  * Service list config with categories for filter testing
84
80
  */
85
81
  export declare const mockServiceListConfigWithCategories: ServiceListServiceConfig;
86
- /**
87
- * Service list config with categories and hasNext for pagination + filter testing
88
- */
89
- export declare const mockServiceListConfigWithCategoriesAndMore: ServiceListServiceConfig;
90
- /**
91
- * Empty service list config with categories
92
- */
93
- export declare const mockEmptyServiceListConfigWithCategories: ServiceListServiceConfig;
94
82
  /**
95
83
  * Base mock staff member with all fields
96
84
  */
@@ -2,7 +2,7 @@
2
2
  * Shared mock data for booking service tests
3
3
  */
4
4
  import { RateType, ServiceType } from '@wix/auto_sdk_bookings_services';
5
- import { BOOKING_APP_ID } from '../services/constants.js';
5
+ import { BOOKING_APP_ID } from '../../services/constants.js';
6
6
  /**
7
7
  * Base mock service with all fields populated (APPOINTMENT type, FIXED pricing)
8
8
  */
@@ -320,10 +320,6 @@ export const mockCategories = [
320
320
  name: 'Beauty',
321
321
  },
322
322
  ];
323
- /**
324
- * Empty categories array
325
- */
326
- export const mockEmptyCategories = [];
327
323
  /**
328
324
  * Service list config with categories for filter testing
329
325
  */
@@ -335,28 +331,6 @@ export const mockServiceListConfigWithCategories = {
335
331
  pagingMetadata: mockPagingMetadata,
336
332
  },
337
333
  };
338
- /**
339
- * Service list config with categories and hasNext for pagination + filter testing
340
- */
341
- export const mockServiceListConfigWithCategoriesAndMore = {
342
- services: mockServices,
343
- categories: mockCategories,
344
- options: {
345
- appId: BOOKING_APP_ID,
346
- pagingMetadata: mockPagingMetadataWithMore,
347
- },
348
- };
349
- /**
350
- * Empty service list config with categories
351
- */
352
- export const mockEmptyServiceListConfigWithCategories = {
353
- services: [],
354
- categories: mockCategories,
355
- options: {
356
- appId: BOOKING_APP_ID,
357
- pagingMetadata: mockPagingMetadataEmpty,
358
- },
359
- };
360
334
  // ============================================================================
361
335
  // Staff Member Mocks
362
336
  // ============================================================================
@@ -0,0 +1,79 @@
1
+ import { vi } from 'vitest';
2
+ import type { TimeSlot } from '@wix/auto_sdk_bookings_availability-time-slots';
3
+ import type { TimeSlotListServiceAPI, TimeSlotListServiceConfig } from '../../services/time-slot-list/time-slot-list.def.js';
4
+ import type { BookingService, BookingServiceConfig } from '../../services/booking/booking.js';
5
+ import { Signal } from '@wix/services-definitions/core-services/signals';
6
+ export type UnwrapSignal<T> = T extends Signal<infer U> ? U : T;
7
+ export type UnwrapSignals<T> = {
8
+ [K in keyof T]: UnwrapSignal<T[K]>;
9
+ };
10
+ type TimeSlotListState = UnwrapSignals<Omit<TimeSlotListServiceAPI, 'actions'>>;
11
+ /**
12
+ * Creates a mock TimeSlotListService
13
+ */
14
+ export declare function createMockTimeSlotListService(options?: Partial<TimeSlotListState>): {
15
+ timeSlots: Signal<TimeSlot[]>;
16
+ hasMore: Signal<boolean>;
17
+ isLoading: Signal<boolean>;
18
+ error: Signal<string | null>;
19
+ dateRange: Signal<import("../../services/time-slot-list/time-slot-list.def.js").DateRange>;
20
+ actions: {
21
+ loadMore: import("vitest").Mock<(...args: any[]) => any>;
22
+ setDateRange: import("vitest").Mock<(...args: any[]) => any>;
23
+ selectSlot: import("vitest").Mock<(...args: any[]) => any>;
24
+ selectStaffMember: import("vitest").Mock<(...args: any[]) => any>;
25
+ clearStaffSelection: import("vitest").Mock<(...args: any[]) => any>;
26
+ };
27
+ };
28
+ export declare function createTimeSlotListService(overrides?: Partial<TimeSlotListServiceConfig>): {
29
+ service: TimeSlotListServiceAPI;
30
+ bookingService: BookingService;
31
+ };
32
+ /**
33
+ * Setup client service mocks for TimeSlot core component tests
34
+ * @param options - Optional configuration (timeSlot state + booking state)
35
+ */
36
+ export declare function setupTimeSlotClientServiceMocks(options: Partial<{
37
+ timeSlot: TimeSlot;
38
+ } & BookingServiceConfig> | undefined, mockUseService: ReturnType<typeof vi.fn>): {
39
+ timeSlotService: {
40
+ timeSlotSignal: Signal<TimeSlot>;
41
+ };
42
+ timeSlotListService: {
43
+ timeSlots: Signal<TimeSlot[]>;
44
+ hasMore: Signal<boolean>;
45
+ isLoading: Signal<boolean>;
46
+ error: Signal<string | null>;
47
+ dateRange: Signal<import("../../services/time-slot-list/time-slot-list.def.js").DateRange>;
48
+ actions: {
49
+ loadMore: import("vitest").Mock<(...args: any[]) => any>;
50
+ setDateRange: import("vitest").Mock<(...args: any[]) => any>;
51
+ selectSlot: import("vitest").Mock<(...args: any[]) => any>;
52
+ selectStaffMember: import("vitest").Mock<(...args: any[]) => any>;
53
+ clearStaffSelection: import("vitest").Mock<(...args: any[]) => any>;
54
+ };
55
+ };
56
+ bookingService: BookingService;
57
+ };
58
+ /**
59
+ * Setup client service mocks for TimeSlotList core component tests
60
+ * @param options - Optional configuration for the mock state (TimeSlotList + Booking)
61
+ */
62
+ export declare function setupTimeSlotListClientServiceMocks(options: Partial<TimeSlotListState & BookingServiceConfig> | undefined, mockUseService: ReturnType<typeof vi.fn>): {
63
+ timeSlotListService: {
64
+ timeSlots: Signal<TimeSlot[]>;
65
+ hasMore: Signal<boolean>;
66
+ isLoading: Signal<boolean>;
67
+ error: Signal<string | null>;
68
+ dateRange: Signal<import("../../services/time-slot-list/time-slot-list.def.js").DateRange>;
69
+ actions: {
70
+ loadMore: import("vitest").Mock<(...args: any[]) => any>;
71
+ setDateRange: import("vitest").Mock<(...args: any[]) => any>;
72
+ selectSlot: import("vitest").Mock<(...args: any[]) => any>;
73
+ selectStaffMember: import("vitest").Mock<(...args: any[]) => any>;
74
+ clearStaffSelection: import("vitest").Mock<(...args: any[]) => any>;
75
+ };
76
+ };
77
+ bookingService: BookingService;
78
+ };
79
+ export {};
@@ -0,0 +1,120 @@
1
+ import { vi } from 'vitest';
2
+ import { mockSignal, createMockBookingService, createMockSignalsService, } from '../booking/booking-client-service.js';
3
+ import { mockTimeSlot as defaultTimeSlot, mockTimeSlots as defaultTimeSlots, createTimeSlotListConfig, } from './time-slots-mocks.js';
4
+ import { ClientServiceIds } from '../../services/constants.js';
5
+ import { TimeSlotListService } from '../../services/time-slot-list/time-slot-list.js';
6
+ /**
7
+ * Creates a mock TimeSlotListService
8
+ */
9
+ export function createMockTimeSlotListService(options = {}) {
10
+ const { timeSlots = defaultTimeSlots, hasMore = false, isLoading = false, error = null, dateRange = {
11
+ start: new Date('2024-01-15'),
12
+ end: new Date('2024-01-22'),
13
+ }, } = options;
14
+ const actions = {
15
+ loadMore: vi.fn(),
16
+ setDateRange: vi.fn(),
17
+ selectSlot: vi.fn(),
18
+ selectStaffMember: vi.fn(),
19
+ clearStaffSelection: vi.fn(),
20
+ };
21
+ return {
22
+ timeSlots: mockSignal(timeSlots),
23
+ hasMore: mockSignal(hasMore),
24
+ isLoading: mockSignal(isLoading),
25
+ error: mockSignal(error),
26
+ dateRange: mockSignal(dateRange),
27
+ actions,
28
+ };
29
+ }
30
+ export function createTimeSlotListService(overrides = {}) {
31
+ const config = createTimeSlotListConfig(overrides);
32
+ const mockBookingService = createMockBookingService();
33
+ const mockSignalsService = createMockSignalsService();
34
+ const getService = (definition) => {
35
+ const def = definition;
36
+ if (def.name === 'signals') {
37
+ return mockSignalsService;
38
+ }
39
+ if (def.name === 'booking') {
40
+ return mockBookingService;
41
+ }
42
+ throw new Error(`Unknown service: ${def.name}`);
43
+ };
44
+ const service = TimeSlotListService({
45
+ getService,
46
+ config,
47
+ });
48
+ return {
49
+ service,
50
+ bookingService: mockBookingService,
51
+ };
52
+ }
53
+ /**
54
+ * Setup client service mocks for TimeSlot core component tests
55
+ * @param options - Optional configuration (timeSlot state + booking state)
56
+ */
57
+ export function setupTimeSlotClientServiceMocks(options = {}, mockUseService) {
58
+ const { timeSlot = defaultTimeSlot, ...bookingOptions } = options;
59
+ const timeSlotService = { timeSlotSignal: mockSignal(timeSlot) };
60
+ const timeSlotListService = createMockTimeSlotListService();
61
+ const bookingService = createMockBookingService(bookingOptions);
62
+ mockUseService.mockImplementation((def) => {
63
+ switch (def.id) {
64
+ case ClientServiceIds.timeSlot:
65
+ return timeSlotService;
66
+ case ClientServiceIds.timeSlotList:
67
+ return timeSlotListService;
68
+ case ClientServiceIds.booking:
69
+ return bookingService;
70
+ default:
71
+ return {};
72
+ }
73
+ });
74
+ return {
75
+ timeSlotService,
76
+ timeSlotListService,
77
+ bookingService,
78
+ };
79
+ }
80
+ // ============================================================================
81
+ // TimeSlotList Client Service Mocks Setup
82
+ // ============================================================================
83
+ /**
84
+ * Setup client service mocks for TimeSlotList core component tests
85
+ * @param options - Optional configuration for the mock state (TimeSlotList + Booking)
86
+ */
87
+ export function setupTimeSlotListClientServiceMocks(options = {}, mockUseService) {
88
+ const {
89
+ // TimeSlotList state
90
+ timeSlots, hasMore, isLoading, error, dateRange,
91
+ // Booking state
92
+ serviceSelections, location, timezone, formSubmission, } = options;
93
+ const timeSlotListService = createMockTimeSlotListService({
94
+ timeSlots,
95
+ hasMore,
96
+ isLoading,
97
+ error,
98
+ dateRange,
99
+ });
100
+ const bookingService = createMockBookingService({
101
+ serviceSelections,
102
+ location,
103
+ timezone,
104
+ formSubmission,
105
+ });
106
+ mockUseService.mockImplementation((def) => {
107
+ switch (def.id) {
108
+ case ClientServiceIds.timeSlotList:
109
+ return timeSlotListService;
110
+ case ClientServiceIds.booking:
111
+ return bookingService;
112
+ default:
113
+ return {};
114
+ }
115
+ });
116
+ return {
117
+ timeSlotListService,
118
+ bookingService,
119
+ };
120
+ }
@@ -1,34 +1,7 @@
1
1
  import { vi } from 'vitest';
2
2
  import React from 'react';
3
3
  import type { TimeSlot } from '@wix/auto_sdk_bookings_availability-time-slots';
4
- import type { TimeSlotListServiceConfig, TimeSlotListServiceAPI } from '../services/time-slot-list/time-slot-list.def.js';
5
- import type { BookingService } from '../services/booking/booking.js';
6
- import type { StaffMemberData } from '../react/time-slot-list/TimeSlot.js';
7
- export declare function createTimeSlotListService(overrides?: Partial<TimeSlotListServiceConfig>): {
8
- service: TimeSlotListServiceAPI;
9
- bookingService: BookingService;
10
- };
11
- export declare function createTimeSlot(overrides?: Partial<TimeSlot>): TimeSlot;
12
- export declare function createTimeSlots(count: number): TimeSlot[];
13
- export declare function createTimeSlotListConfig(overrides?: Partial<TimeSlotListServiceConfig>): TimeSlotListServiceConfig;
14
- export declare const mockTimeSlot: TimeSlot;
15
- export declare const mockTimeSlotMultipleStaff: TimeSlot;
16
- export declare const mockTimeSlotNotBookable: TimeSlot;
17
- export declare const mockTimeSlots: TimeSlot[];
18
- export declare const mockStartDate: Date;
19
- export declare const mockEndDate: Date;
20
- export declare const mockTimezone = "America/New_York";
21
- export declare const mockTimeSlotListConfig: TimeSlotListServiceConfig;
22
- export declare const mockEmptyTimeSlotListConfig: TimeSlotListServiceConfig;
23
- export declare const mockCursorPagingMetadataWithMore: {
24
- cursors: {
25
- next: string;
26
- };
27
- };
28
- export declare const mockCursorPagingMetadataNoMore: {
29
- cursors: {};
30
- };
31
- export declare function createMockTimeSlotListService(config?: Partial<TimeSlotListServiceConfig>): TimeSlotListServiceAPI;
4
+ import type { StaffMemberData } from '../../react/time-slot-list/TimeSlot.js';
32
5
  export interface CoreTimeSlotMockConfig {
33
6
  timeSlot: TimeSlot;
34
7
  staffMembers: StaffMemberData[];