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

import { ReleaseValidationSummary } from '../components/ui/ReleaseValidationSummary'

describe('ReleaseValidationSummary', () => {
  it('shows both the pre-package editor-build truth and the package-helper build mode when both are known', () => {
    render(
      <ReleaseValidationSummary
        platform={{
          platform_key: 'windows',
          platform: 'Windows',
          subtitle: 'Primary shipping lane',
          details: 'Current packaged validation is strongest on the Windows Unreal lane.',
          configured: true,
          channel: 'candidate',
          version: '1.0.0',
          build_id: 'win64-1000',
          published_at: '2026-06-30T22:07:38.3738154Z',
          file_name: 'HyperTwist-Windows.zip',
          file_size_bytes: 1048576,
          checksum_sha256: 'abc123',
          download_url: 'https://downloads.hypertwist.app/windows.zip',
          download_available: true,
          validation_summary: {
            lane: 'Windows Unreal packaged validation',
            result: 'passed',
            generated_at: '2026-06-30T22:07:38.3738154Z',
            configuration: 'Development',
            skip_build: true,
            pre_package_editor_build: {
              lane: 'Windows Unreal editor build',
              performed: true,
              result: 'passed',
            },
            smoke_map_count: 2,
            smoke_maps: [
              {
                map_url: '/Game/HyperTwistTraining/Maps/L_HyperTwist_Magic120CellTraining',
                label: 'Magic120Cell dedicated-family training map',
                result: 'passed',
              },
              {
                map_url: '/Game/HyperTwistTraining/Maps/L_HyperTwist_MagicCube5DTraining',
                label: 'MagicCube5D dedicated-family training map',
                result: 'passed',
              },
            ],
          },
        }}
      />,
    )

    expect(screen.getByText(/Pre-package editor build in same proof packet: passed on the windows unreal editor build lane/i)).toBeTruthy()
    expect(screen.getByText(/Package helper build mode: reused the existing packaged-game target receipt/i)).toBeTruthy()
  })
})
