import { describe, it, expect, vi } from 'vitest';
import { render, screen, waitFor } from '@testing-library/react';
import { BrowserRouter } from 'react-router-dom';
import OAuthClientList from './OAuthClientList';

vi.mock('../../api/health/oauthClients', () => ({
  oauthClientApi: {
    list: vi.fn().mockResolvedValue([]),
    create: vi.fn(),
    update: vi.fn(),
    delete: vi.fn(),
    regenerateSecret: vi.fn(),
  },
  FHIR_SCOPE_OPTIONS: [
    { value: 'Patient.read', label: 'Patient.read' },
  ],
}));

vi.mock('../../components/PageContainer', () => ({
  PageContainer: ({ children, title, actions }: { children: React.ReactNode; title: string; actions?: React.ReactNode }) => (
    <div><h1>{title}</h1>{actions}{children}</div>
  ),
}));

describe('OAuthClientList', () => {
  it('renders page title', async () => {
    render(
      <BrowserRouter>
        <OAuthClientList />
      </BrowserRouter>,
    );
    await waitFor(() => {
      expect(screen.getByText('FHIR API 合作方管理')).toBeDefined();
    });
  });
});
