import { mount } from '@vue/test-utils'
import { describe, expect, it } from 'vitest'
import StepWizardPage from '../v2/StepWizardPage.vue'
import { nativeUiAdapter } from '../../adapter/native'
import { uiAdapterKey } from '../../adapter/contracts'

const global = { provide: { [uiAdapterKey as unknown as string]: nativeUiAdapter } }

describe('StepWizardPage T06 contract', () => {
  it('renders progress, evidence version, and forwards navigation events', async () => {
    const wrapper = mount(StepWizardPage, { global, props: { title: '설정', state: 'READY', currentStep: 1, totalSteps: 2, evidence: { version: 'wizard-v1' } } })
    expect(wrapper.find('.ks-page__meta').text()).toContain('Version: wizard-v1')
    expect(wrapper.get('progress').attributes('value')).toBe('1')
    await wrapper.get('button').trigger('click')
    await wrapper.findAll('button')[1].trigger('click')
    expect(wrapper.emitted('next')).toHaveLength(1)
  })

  it('hides wizard actions while readonly/error/processing state blocks action', () => {
    for (const state of ['READONLY', 'ERROR', 'PROCESSING'] as const) {
      const wrapper = mount(StepWizardPage, { global, props: { title: '설정', state, currentStep: 1, totalSteps: 2 } })
      expect(wrapper.find('.ks-page__footer').exists()).toBe(false)
    }
  })
})
