import React from 'react';
import { describe, expect, it, vi } from 'vitest';
import { render, screen } from '@testing-library/react';

const articles = [
  { slug: 'faq-admin', title: 'FAQ: Event Admin', summary: 'Common issues.' },
  { slug: 'tenant-dashboard-overview', title: 'Dashboard overview', summary: 'Learn the dashboard.' },
];

vi.mock('@tanstack/react-query', () => ({
  useQuery: () => ({
    data: articles,
    isLoading: false,
    isError: false,
    refetch: vi.fn(),
  }),
}));

vi.mock('react-router-dom', () => ({
  useNavigate: () => vi.fn(),
}));

vi.mock('react-i18next', () => ({
  useTranslation: () => ({
    t: (_key: string, fallback?: string) => fallback ?? _key,
    i18n: { language: 'de' },
  }),
  initReactI18next: {
    type: '3rdParty',
    init: () => undefined,
  },
}));

vi.mock('../components/MobileShell', () => ({
  MobileShell: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));

vi.mock('../hooks/useBackNavigation', () => ({
  useBackNavigation: () => vi.fn(),
}));

vi.mock('../theme', () => ({
  useAdminTheme: () => ({
    textStrong: '#111827',
    muted: '#6b7280',
    border: '#e5e7eb',
    surfaceMuted: '#f3f4f6',
    shadow: 'rgba(0,0,0,0.12)',
  }),
}));

vi.mock('@tamagui/stacks', () => ({
  YStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
  XStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));

vi.mock('@tamagui/text', () => ({
  SizableText: ({ children }: { children: React.ReactNode }) => <span>{children}</span>,
}));

vi.mock('@tamagui/group', () => ({
  YGroup: Object.assign(({ children }: { children: React.ReactNode }) => <div>{children}</div>, {
    Item: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
  }),
}));

vi.mock('@tamagui/list-item', () => ({
  ListItem: ({ title, subTitle }: { title?: React.ReactNode; subTitle?: React.ReactNode }) => (
    <div>
      {title}
      {subTitle}
    </div>
  ),
}));

vi.mock('tamagui', () => ({
  Separator: ({ children }: { children?: React.ReactNode }) => <div>{children}</div>,
}));

vi.mock('../components/Primitives', () => ({
  MobileCard: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
  CTAButton: ({ label }: { label: string }) => <button type="button">{label}</button>,
  SkeletonCard: () => <div>Loading...</div>,
}));

import MobileHelpCenterPage from '../HelpCenterPage';

describe('MobileHelpCenterPage', () => {
  it('renders FAQ and guide articles', async () => {
    render(<MobileHelpCenterPage />);

    expect(screen.getByText('FAQ: Event Admin')).toBeInTheDocument();
    expect(screen.getByText('Dashboard overview')).toBeInTheDocument();
  });
});
