import { describe, it, expect, beforeEach, vi } from 'vitest'; import { screen, fireEvent, waitFor } from '@testing-library/react'; import { renderWithProviders } from '../test/utils'; const navigate = vi.fn(); vi.mock('react-router-dom', async (orig) => ({ ...(await orig()), useNavigate: () => navigate, })); vi.mock('../lib/api', () => ({ api: { get: vi.fn() }, ApiError: class extends Error {} })); import { api } from '../lib/api'; import MyPaymentsPage from './MyPaymentsPage'; const get = api.get as ReturnType; const ROWS = [ { patient_uuid: 'p1', patient_name: 'دنیا خلیلی', national_code: '1744023654', invoice_count: 2, paid_rials: 2350000, remaining_rials: 500000, status: 'unsettled' }, { patient_uuid: 'p2', patient_name: 'علی بدیعی', national_code: '2200112233', invoice_count: 1, paid_rials: 2000000, remaining_rials: 0, status: 'paid' }, ]; beforeEach(() => { navigate.mockReset(); get.mockReset(); get.mockResolvedValue({ success: true, data: ROWS, meta: { totalRecords: 2, totalPages: 1, currentPage: 1 } }); }); describe('MyPaymentsPage (لیست پرداخت‌ها)', () => { it('renders patient payment rows with derived status labels', async () => { renderWithProviders(, { route: '/admin/my-payments' }); expect(await screen.findByText('دنیا خلیلی')).toBeInTheDocument(); expect(screen.getByText('علی بدیعی')).toBeInTheDocument(); // status labels appear both as a filter