import { describe, it, expect } from 'vitest'
import { readFileSync } from 'node:fs'
import { resolve } from 'node:path'
import { entityDialogContentClasses } from '@/components/shared/entity-dialog-layout'

describe('entityDialogContentClasses', () => {
  it('bevat mobile-fullscreen classes (<640px)', () => {
    const cls = entityDialogContentClasses
    expect(cls).toContain('max-sm:w-screen')
    expect(cls).toContain('max-sm:h-screen')
    expect(cls).toContain('max-sm:max-w-none')
    expect(cls).toContain('max-sm:rounded-none')
  })

  it('behoudt desktop-classes (>=640px)', () => {
    const cls = entityDialogContentClasses
    expect(cls).toContain('sm:max-w-[90vw]')
    expect(cls).toContain('sm:max-h-[85vh]')
    expect(cls).toContain('lg:max-w-[50vw]')
  })
})

describe('alle entity-dialogen gebruiken entityDialogContentClasses', () => {
  // Regressie-vangnet: voorkomt dat een dialog zijn eigen className meegeeft en
  // daarmee de gedeelde mobile-fullscreen-classes ontwijkt.
  const files = [
    'app/_components/tasks/task-dialog.tsx',
    'components/solo/task-detail-dialog.tsx',
    'components/backlog/pbi-dialog.tsx',
    'components/backlog/story-dialog.tsx',
  ]
  for (const f of files) {
    it(`${f} importeert + gebruikt entityDialogContentClasses`, () => {
      const src = readFileSync(resolve(process.cwd(), f), 'utf-8')
      expect(src).toContain('entityDialogContentClasses')
    })
  }
})
