Files
clinicpro/assets/admin/pages/PatientDetailPage.test.tsx
T
hamedandClaude Opus 4.8 7ac875a7a6 feat(patients): phase B1 — tabbed patient detail page
Add a standalone PatientDetailPage at /admin/patients/:uuid: a header + the
9-tab case-file bar (services, info, appointments, payments, wallet, messages,
call-center, attachments, medical-record). The info, services (sessions) and
appointments tabs are wired to existing endpoints; the remaining tabs render a
placeholder until their backends land (phases B2–B5). The list "مشاهده" action
now opens this detail page.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-13 15:08:53 +03:30

62 lines
2.4 KiB
TypeScript

import { describe, it, expect, beforeEach, vi } from 'vitest';
import { screen, fireEvent } 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 PatientDetailPage from './PatientDetailPage';
const get = api.get as ReturnType<typeof vi.fn>;
beforeEach(() => {
get.mockReset();
get.mockImplementation((url: string) => {
if (url === '/api/v1/patient/r1') return Promise.resolve({ success: true, data: {
uuid: 'r1', user_name: 'ساغر صابری', record_number: 'P-1001',
user_mobile: '09120000000', user_national_code: '1234567890',
profile: { gender: 'female', referral_source: 'اینستاگرام', address: 'یزد', description: 'یادداشت' },
} });
return Promise.resolve({ success: true, data: [] });
});
});
function renderDetail() {
return renderWithProviders(
<Routes>
<Route path="/admin/patients/:uuid" element={<PatientDetailPage />} />
</Routes>,
{ route: '/admin/patients/r1' },
);
}
describe('PatientDetailPage (پرونده تب‌دار)', () => {
it('renders the header and tab bar', async () => {
renderDetail();
expect(await screen.findByText('ساغر صابری')).toBeInTheDocument();
expect(screen.getByText('سرویس‌ها')).toBeInTheDocument();
expect(screen.getByText('اطلاعات پرونده')).toBeInTheDocument();
expect(screen.getByText('پرونده پزشکی')).toBeInTheDocument();
});
it('shows patient info on the info tab', async () => {
renderDetail();
await screen.findByText('ساغر صابری');
fireEvent.click(screen.getByText('اطلاعات پرونده'));
expect(screen.getByText('کد ملی')).toBeInTheDocument();
expect(screen.getByText('1234567890')).toBeInTheDocument();
expect(screen.getByText('اینستاگرام')).toBeInTheDocument();
});
it('shows a placeholder for not-yet-built tabs', async () => {
renderDetail();
await screen.findByText('ساغر صابری');
fireEvent.click(screen.getByText('پیام‌ها'));
expect(screen.getByText(/به‌زودی تکمیل می‌شود/)).toBeInTheDocument();
});
});