import { cleanup, render, screen } from '@testing-library/react';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { HelpDialog } from '../../../src/components/HelpDialog';

afterEach(cleanup);

describe('HelpDialog', () => {
  it('exposes bundled engine, licence, source and privacy context', () => {
    render(<HelpDialog open={false} onClose={vi.fn()} />);

    expect(
      screen.getByRole('heading', {
        name: 'About & licences',
        hidden: true,
      })
    ).toBeInTheDocument();
    expect(screen.getByText('n5.1.4')).toBeInTheDocument();
    expect(screen.getByText('0.12.15')).toBeInTheDocument();
    expect(
      screen.getByText('0.12.10-reviewed-stack5m.1 · ST & MT')
    ).toBeInTheDocument();
    expect(
      screen.getByText(/copyright © 2026 Albrecht Degering/i)
    ).toBeInTheDocument();
    expect(
      screen.getByRole('link', { name: 'Application GPL', hidden: true })
    ).toHaveAttribute('href', expect.stringContaining('LICENSE'));
    expect(
      screen.getByRole('link', { name: 'MIT text', hidden: true })
    ).toHaveAttribute('href', expect.stringContaining('ffmpeg.wasm-MIT'));
    expect(
      screen.getByRole('link', { name: 'GPL text', hidden: true })
    ).toHaveAttribute('href', expect.stringContaining('GPL-2.0-or-later'));
    expect(
      screen.getByRole('link', { name: 'Font licence', hidden: true })
    ).toHaveAttribute('href', expect.stringContaining('DEJAVU_FONTS'));
    expect(
      screen.getByRole('link', {
        name: 'Complete inventory',
        hidden: true,
      })
    ).toHaveAttribute('href', expect.stringContaining('THIRD_PARTY_NOTICES'));
    expect(
      screen.getByRole('link', {
        name: 'Source & reproducibility record',
        hidden: true,
      })
    ).toHaveAttribute('href', expect.stringContaining('SOURCE'));
    expect(
      screen.getByText(/source files stay inside the browser session/i)
    ).toBeInTheDocument();
  });
});
