feat: Implement resource-based appointment booking flow
- Updated DoctorPage component to accept bookingResources prop for appointment list. - Added serviceQuery function to serialize service item UUIDs for API requests. - Introduced new API endpoints for fetching booking resources and resource slots. - Enhanced tests for new resource-based booking functionality, including resource selection and service availability. - Created ResourceSelect component for selecting appointment types, including doctor and resource options. - Updated appointment submission logic to include resource_uuid in payload when applicable. - Ensured UI reflects changes in booking flow without disrupting existing doctor-centric experience.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { bookingState } from './bookingState';
|
||||
|
||||
const LOCATION = { next_available_at: null };
|
||||
const RESOURCE = { uuid: 'r1', name: 'کندلا2021' };
|
||||
|
||||
describe('bookingState', () => {
|
||||
it('محل دارد → فعال', () => {
|
||||
expect(bookingState({ active: true }, [LOCATION]).enabled).toBe(true);
|
||||
});
|
||||
|
||||
it('نه محل و نه منبع و نه free_turn → غیرفعال', () => {
|
||||
const state = bookingState({ active: true, free_turn: null }, [], []);
|
||||
|
||||
expect(state.enabled).toBe(false);
|
||||
expect(state.label).toBe('نوبتدهی غیرفعال است');
|
||||
});
|
||||
|
||||
it('بدون محل ولی با منبع → فعال', () => {
|
||||
const state = bookingState({ active: true, free_turn: null }, [], [RESOURCE]);
|
||||
|
||||
expect(state.enabled).toBe(true);
|
||||
expect(state.label).toBe('رزرو نوبت دستگاه و خدمات');
|
||||
});
|
||||
|
||||
it('پزشکِ غیرفعال ولی دارای منبعِ قابل رزرو → همچنان فعال', () => {
|
||||
// منبع تقویم خودش را دارد؛ پرچم قدیمیِ پزشک آن را خاموش نمیکند.
|
||||
expect(bookingState({ active: false, free_turn: null }, [], [RESOURCE]).enabled).toBe(true);
|
||||
});
|
||||
|
||||
it('محل مقدم بر منبع است — برچسبِ زودترین نوبت حفظ میشود', () => {
|
||||
const state = bookingState({ active: true }, [{ next_available_at: null }], [RESOURCE]);
|
||||
|
||||
expect(state.label).toBe('فعلاً نوبت خالی ندارد');
|
||||
});
|
||||
|
||||
it('بدون محل و بدون منبع ولی با free_turn → همان رفتار قبلی', () => {
|
||||
const state = bookingState({ active: true, free_turn: 'فردا ۱۰:۰۰' }, [], []);
|
||||
|
||||
expect(state.enabled).toBe(true);
|
||||
expect(state.label).toBe('اولین نوبت آزاد: فردا ۱۰:۰۰');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user