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

// Mock react-i18next
vi.mock('react-i18next', () => ({
  useTranslation: () => ({
    t: (key: string, options?: { returnObjects?: boolean }) => {
      if (options?.returnObjects) {
        return ['Item 1', 'Item 2', 'Item 3'];
      }
      return key;
    },
  }),
}));

const renderPrivacyPolicyPage = () => {
  return render(
    <BrowserRouter>
      <PrivacyPolicyPage />
    </BrowserRouter>
  );
};

describe('PrivacyPolicyPage', () => {
  it('renders the page title', () => {
    renderPrivacyPolicyPage();
    expect(screen.getByText('marketing.privacyPolicy.title')).toBeInTheDocument();
  });

  it('renders the last updated date', () => {
    renderPrivacyPolicyPage();
    expect(screen.getByText('marketing.privacyPolicy.lastUpdated')).toBeInTheDocument();
  });

  it('renders section 1', () => {
    renderPrivacyPolicyPage();
    expect(screen.getByText('marketing.privacyPolicy.section1.title')).toBeInTheDocument();
    expect(screen.getByText('marketing.privacyPolicy.section1.content')).toBeInTheDocument();
  });

  it('renders section 2', () => {
    renderPrivacyPolicyPage();
    expect(screen.getByText('marketing.privacyPolicy.section2.title')).toBeInTheDocument();
    expect(screen.getByText('marketing.privacyPolicy.section2.subsection1.title')).toBeInTheDocument();
    expect(screen.getByText('marketing.privacyPolicy.section2.subsection2.title')).toBeInTheDocument();
  });

  it('renders section 3', () => {
    renderPrivacyPolicyPage();
    expect(screen.getByText('marketing.privacyPolicy.section3.title')).toBeInTheDocument();
    expect(screen.getByText('marketing.privacyPolicy.section3.intro')).toBeInTheDocument();
  });

  it('renders section 4', () => {
    renderPrivacyPolicyPage();
    expect(screen.getByText('marketing.privacyPolicy.section4.title')).toBeInTheDocument();
    expect(screen.getByText('marketing.privacyPolicy.section4.subsection1.title')).toBeInTheDocument();
    expect(screen.getByText('marketing.privacyPolicy.section4.subsection2.title')).toBeInTheDocument();
  });

  it('renders section 5', () => {
    renderPrivacyPolicyPage();
    expect(screen.getByText('marketing.privacyPolicy.section5.title')).toBeInTheDocument();
    expect(screen.getByText('marketing.privacyPolicy.section5.intro')).toBeInTheDocument();
    expect(screen.getByText('marketing.privacyPolicy.section5.disclaimer')).toBeInTheDocument();
  });

  it('renders section 6', () => {
    renderPrivacyPolicyPage();
    expect(screen.getByText('marketing.privacyPolicy.section6.title')).toBeInTheDocument();
    expect(screen.getByText('marketing.privacyPolicy.section6.content')).toBeInTheDocument();
  });

  it('renders section 7', () => {
    renderPrivacyPolicyPage();
    expect(screen.getByText('marketing.privacyPolicy.section7.title')).toBeInTheDocument();
    expect(screen.getByText('marketing.privacyPolicy.section7.intro')).toBeInTheDocument();
    expect(screen.getByText('marketing.privacyPolicy.section7.contact')).toBeInTheDocument();
  });

  it('renders section 8', () => {
    renderPrivacyPolicyPage();
    expect(screen.getByText('marketing.privacyPolicy.section8.title')).toBeInTheDocument();
    expect(screen.getByText('marketing.privacyPolicy.section8.intro')).toBeInTheDocument();
    expect(screen.getByText('marketing.privacyPolicy.section8.disclaimer')).toBeInTheDocument();
  });

  it('renders sections 9-14', () => {
    renderPrivacyPolicyPage();
    expect(screen.getByText('marketing.privacyPolicy.section9.title')).toBeInTheDocument();
    expect(screen.getByText('marketing.privacyPolicy.section10.title')).toBeInTheDocument();
    expect(screen.getByText('marketing.privacyPolicy.section11.title')).toBeInTheDocument();
    expect(screen.getByText('marketing.privacyPolicy.section12.title')).toBeInTheDocument();
    expect(screen.getByText('marketing.privacyPolicy.section13.title')).toBeInTheDocument();
    expect(screen.getByText('marketing.privacyPolicy.section14.title')).toBeInTheDocument();
  });

  it('renders section 15 contact info', () => {
    renderPrivacyPolicyPage();
    expect(screen.getByText('marketing.privacyPolicy.section15.title')).toBeInTheDocument();
    expect(screen.getByText('marketing.privacyPolicy.section15.intro')).toBeInTheDocument();
    expect(screen.getByText('marketing.privacyPolicy.section15.emailLabel')).toBeInTheDocument();
    expect(screen.getByText('marketing.privacyPolicy.section15.dpoLabel')).toBeInTheDocument();
    expect(screen.getByText('marketing.privacyPolicy.section15.websiteLabel')).toBeInTheDocument();
  });

  it('renders list items from translations', () => {
    renderPrivacyPolicyPage();
    // The mock returns 'Item 1', 'Item 2', 'Item 3' for array translations
    const listItems = screen.getAllByText('Item 1');
    expect(listItems.length).toBeGreaterThan(0);
  });
});
