import { describe, it, expect, vi } from 'vitest';
import { screen, waitFor } from '@testing-library/react';
import { renderWithProviders } from '../../test/utils/renderWithProviders';

// Mock useThemeMode
vi.mock('../../hooks/useThemeMode', () => ({
  useThemeMode: () => false,
}));

import AiUsageDashboard from './AiUsageDashboard';

describe('AiUsageDashboard', () => {
  it('renders page title', async () => {
    vi.setConfig({ testTimeout: 15000 });
    renderWithProviders(<AiUsageDashboard />);
    await waitFor(() => {
      expect(screen.getByText('AI 用量统计')).toBeInTheDocument();
    });
  });

  it('shows statistics cards', async () => {
    renderWithProviders(<AiUsageDashboard />);
    await waitFor(() => {
      expect(screen.getByText('总分析次数')).toBeInTheDocument();
    });
    expect(screen.getByText('分析类型数')).toBeInTheDocument();
    expect(screen.getByText('本月分析')).toBeInTheDocument();
  });

  it('shows analysis type distribution section', async () => {
    renderWithProviders(<AiUsageDashboard />);
    await waitFor(() => {
      expect(screen.getByText('分析类型分布')).toBeInTheDocument();
    });
  });

  it('renders type distribution labels', async () => {
    renderWithProviders(<AiUsageDashboard />);
    await waitFor(() => {
      expect(screen.getByText('化验单解读')).toBeInTheDocument();
    });
    expect(screen.getByText('趋势分析')).toBeInTheDocument();
    expect(screen.getByText('体检方案')).toBeInTheDocument();
    expect(screen.getByText('报告摘要')).toBeInTheDocument();
  });
});
