// @vitest-environment jsdom
//
// FB-36 (P0 compliance, composition profile — ADR 013): the work_mode
// ("Arbeitsort") bulk-edit select must be hideable via the `workModeCapture`
// profile flag. Before this flag existed the select always rendered
// unconditionally, so "hidden when false" below is a genuine regression
// test — against the pre-flag component it fails (3 comboboxes would be
// found, not 2).
//
// FIXTURE-DATEN-REGEL: every id/name below is FREE INVENTION.

import { afterEach, describe, expect, it } from 'vitest'
import { cleanup, render, screen } from '@testing-library/react'
import BulkEditModal from '@/components/planning/bulk-edit-modal'
import type { AppointmentType } from '@/lib/planning-types'

afterEach(() => {
  cleanup()
})

const appointmentTypes: AppointmentType[] = [
  { id: '22222222-2222-2222-2222-222222222222', code: 'visit', label: 'Besuch', color: '#037493', sort_order: 1 },
]

function renderModal(workModeCapture: boolean) {
  return render(
    <BulkEditModal
      selectedIds={new Set(['11111111-1111-1111-1111-111111111111'])}
      appointmentTypes={appointmentTypes}
      onClose={() => {}}
      onSaved={() => {}}
      workModeCapture={workModeCapture}
    />,
  )
}

describe('BulkEditModal — workModeCapture flag (FB-36)', () => {
  it('hides the Arbeitsort select when the flag is false', () => {
    renderModal(false)
    expect(screen.queryByText('Arbeitsort')).toBeNull()
    // Auftragsart + Status only.
    expect(screen.getAllByRole('combobox')).toHaveLength(2)
  })

  it('shows the Arbeitsort select when the flag is true', () => {
    renderModal(true)
    expect(screen.getByText('Arbeitsort')).toBeTruthy()
    // Auftragsart + Status + Arbeitsort.
    expect(screen.getAllByRole('combobox')).toHaveLength(3)
  })
})
