- Adjusted the calculation of payable amounts in PaymentStep to align with server logic, ensuring overpayments are handled correctly. - Enhanced DetailsStep to include consumables in the itemized cost breakdown, ensuring consistency with patient share calculations. - Updated tests for SessionPaymentPage to validate new behavior regarding overpayments and consumable listings. - Modified PatientController to register SessionPayment correctly when settling sessions via wallet, preventing double charges. - Refactored WalletService to remove outdated methods and ensure wallet transactions reflect the correct amounts after discounts. - Improved accessibility in SearchableSelect component by adding aria labels and ensuring proper role attributes for screen readers. - Updated styles to ensure minimum touch targets meet WCAG guidelines for mobile usability.
51 lines
1.9 KiB
TypeScript
51 lines
1.9 KiB
TypeScript
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
|
import { screen, waitFor } from '@testing-library/react';
|
|
import { Routes, Route } from 'react-router-dom';
|
|
import { renderWithProviders } from '../test/utils';
|
|
|
|
vi.mock('../lib/api', () => ({
|
|
api: { get: vi.fn(), post: vi.fn(), patch: vi.fn(), put: vi.fn(), delete: vi.fn() },
|
|
ApiError: class extends Error {},
|
|
}));
|
|
|
|
import { api } from '../lib/api';
|
|
import AppointmentDetailPage from './AppointmentDetailPage';
|
|
|
|
const get = api.get as ReturnType<typeof vi.fn>;
|
|
// 2024-06-01 12:00 محلی
|
|
const slotStart = Math.floor(new Date('2024-06-01T12:00:00').getTime() / 1000);
|
|
|
|
beforeEach(() => {
|
|
get.mockReset();
|
|
// mock باید به URL حساس باشد: /events یک لیست برمیگرداند نه آبجکت نوبت
|
|
get.mockImplementation((url: string) =>
|
|
Promise.resolve(
|
|
String(url).endsWith('/events')
|
|
? { success: true, data: [] }
|
|
: {
|
|
success: true,
|
|
data: {
|
|
uuid: 'ap1', patient_name: 'ساغر', patient_mobile: '09120000000',
|
|
slot_start: slotStart, slot_end: slotStart + 1800, status: 'confirmed', version: 1, created_at: slotStart,
|
|
},
|
|
},
|
|
),
|
|
);
|
|
});
|
|
|
|
describe('AppointmentDetailPage — بازگشت به همان روز', () => {
|
|
it('the «نوبتها» breadcrumb points back to the appointment day', async () => {
|
|
renderWithProviders(
|
|
<Routes>
|
|
<Route path="/admin/appointments/:uuid" element={<AppointmentDetailPage />} />
|
|
</Routes>,
|
|
{ route: '/admin/appointments/ap1' },
|
|
);
|
|
// پس از بارگذاری نوبت، لینک «نوبتها» باید به روزِ نوبت اشاره کند
|
|
await waitFor(() => {
|
|
const link = screen.getByText('نوبتها').closest('a');
|
|
expect(link?.getAttribute('href')).toContain('date=2024-06-01');
|
|
});
|
|
});
|
|
});
|