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

vi.mock('../../api/health/alerts', () => ({
  alertApi: {
    list: vi.fn().mockResolvedValue({ data: [], total: 0 }),
  },
}));

vi.mock('../../hooks/useVitalSSE', () => ({
  useVitalSSE: vi.fn().mockReturnValue({
    connected: true,
    patientVitals: new Map(),
    lastUpdate: null,
  }),
}));

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

describe('RealtimeMonitor', () => {
  it('renders page title', async () => {
    render(
      <BrowserRouter>
        <RealtimeMonitor />
      </BrowserRouter>,
    );
    await waitFor(() => {
      expect(screen.getByText('实时体征监控')).toBeDefined();
    });
  });
});
