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

// Mock react-i18next
vi.mock('react-i18next', () => ({
  useTranslation: () => ({
    t: (key: string) => key,
  }),
}));

// Mock PlatformEmailAddressManager component
vi.mock('../../../components/PlatformEmailAddressManager', () => ({
  default: () => <div data-testid="email-manager">Email Address Manager</div>,
}));

describe('PlatformEmailAddresses', () => {
  it('renders the page title', () => {
    render(<PlatformEmailAddresses />);
    expect(screen.getByText('Platform Email Addresses')).toBeInTheDocument();
  });

  it('renders the page description', () => {
    render(<PlatformEmailAddresses />);
    expect(screen.getByText(/Manage platform-wide email addresses/)).toBeInTheDocument();
  });

  it('renders the email manager component', () => {
    render(<PlatformEmailAddresses />);
    expect(screen.getByTestId('email-manager')).toBeInTheDocument();
  });

  it('mentions mail server in description', () => {
    render(<PlatformEmailAddresses />);
    expect(screen.getByText(/mail.talova.net/)).toBeInTheDocument();
  });

  it('mentions automatic sync in description', () => {
    render(<PlatformEmailAddresses />);
    expect(screen.getByText(/automatically synced/)).toBeInTheDocument();
  });
});
