import { describe, it, expect } from 'vitest'
import { buildAgendaWorkbook } from '../export-excel'
import { buildExportModel } from '../export-model'
import { fixtureAgenda, fixtureCtx, ONE_PX_PNG } from './fixtures'

describe('buildAgendaWorkbook', () => {
  it('produces a non-empty xlsx blob without any logos', async () => {
    const model = buildExportModel(fixtureAgenda(), fixtureCtx())
    const blob = await buildAgendaWorkbook(model)
    expect(blob.size).toBeGreaterThan(0)
    expect(blob.type).toContain('spreadsheetml')
  })

  it('embeds host logo plus up to two supplier logos (extra logos ignored)', async () => {
    const model = buildExportModel(fixtureAgenda(), fixtureCtx())
    const blob = await buildAgendaWorkbook(model, {
      hostLogoPng: ONE_PX_PNG,
      supplierLogoPngs: [ONE_PX_PNG, ONE_PX_PNG, ONE_PX_PNG],
    })
    expect(blob.size).toBeGreaterThan(0)
  })

  it('works with a single supplier logo', async () => {
    const model = buildExportModel(fixtureAgenda(), fixtureCtx())
    const blob = await buildAgendaWorkbook(model, { hostLogoPng: ONE_PX_PNG, supplierLogoPngs: [ONE_PX_PNG] })
    expect(blob.size).toBeGreaterThan(0)
  })

  it('works with empty days and no participants', async () => {
    const model = buildExportModel(fixtureAgenda({ participants: [], days: [] }), fixtureCtx())
    const blob = await buildAgendaWorkbook(model)
    expect(blob.size).toBeGreaterThan(0)
  })
})
