import { describe, it, expect, vi } from 'vitest'; import { render, screen } from '@testing-library/react'; import '@testing-library/jest-dom'; import { TestWrapper } from '../../../../src/client/__test_utils__/test-render'; import { UsersPage } from '../../../../src/client/admin/pages/Users'; import { userClient } from '../../../../src/client/api'; // Mock the API client vi.mock('../../../../src/client/api', () => ({ userClient: { $get: vi.fn(), $post: vi.fn(), ':id': { $put: vi.fn(), $delete: vi.fn() } } })); describe('Debug Test', () => { it('should mock the API client', async () => { // Mock the API call (userClient.$get as any).mockResolvedValue({ status: 200, ok: true, json: async () => ({ data: [ { id: 1, username: 'testuser', nickname: '测试用户', email: 'test@example.com', phone: '13800138000', name: '测试用户', isDisabled: 0, createdAt: '2024-01-01T00:00:00.000Z', roles: [{ id: 1, name: 'admin' }] } ], pagination: { total: 1, current: 1, pageSize: 10 } }) }); render( ); // Check if the mock was called expect(userClient.$get).toHaveBeenCalled(); // Wait for data to load await screen.findByText('testuser'); expect(screen.getByText('testuser')).toBeInTheDocument(); }); });