import arHomepage from '@/content/locales/ar/homepage.json';
import arShell from '@/content/locales/ar/shell.json';
import enHomepage from '@/content/locales/en/homepage.json';
import enShell from '@/content/locales/en/shell.json';
import frHomepage from '@/content/locales/fr/homepage.json';
import frShell from '@/content/locales/fr/shell.json';
import { buildHomepageContent } from '@/content/homepage-model';
import { describe, expect, it } from 'vitest';

describe('homepage content model', () => {
  it.each([
    ['en', enHomepage, enShell],
    ['fr', frHomepage, frShell],
    ['ar', arHomepage, arShell],
  ] as const)('builds complete %s route content', (_locale, homepage, shell) => {
    const content = buildHomepageContent(homepage, shell, _locale);

    expect(content.hero.title).toBeTruthy();
    expect(content.trust.items).toHaveLength(4);
    expect(content.workflow.steps).toHaveLength(4);
    expect(content.modules.items).toHaveLength(6);
    expect(content.faq.items).toHaveLength(6);
    expect(content.pricing.fleetBands).toHaveLength(4);
    expect(content.pricing.plans).toHaveLength(3);
    expect(content.hero.preview.rows).toHaveLength(2);
  });

  it('keeps unresolved conversion destinations disabled', () => {
    const content = buildHomepageContent(enHomepage, enShell);

    expect(content.hero.primary.href).toBe('/dashboard/sign-up?lang=en');
    expect(content.hero.primary.disabledReason).toBeUndefined();
    expect(content.final.primary.href).toBe('/dashboard/sign-up?lang=en');
    expect(content.final.primary.disabledReason).toBeUndefined();
    expect(content.pricing.actionDisabledReason).toBe(enShell.states.pendingBody);
    expect(content.final.secondary.disabledReason).toBe(enShell.states.pendingBody);
  });

  it('keeps preview identifiers isolated from translated prose', () => {
    const content = buildHomepageContent(arHomepage, arShell);

    expect(content.hero.preview.rows.map((row) => row.secondary)).toEqual([
      arHomepage.preview.plate1,
      arHomepage.preview.plate2,
    ]);
  });
});
