import { mount } from '@vue/test-utils'
import { describe, expect, it } from 'vitest'
import AppShellLayout from '../AppShellLayout.vue'
import PageLayout from '../PageLayout.vue'

describe('shared layout contracts', () => {
  it('provides skip navigation, structural landmarks, and the automation boundary by default', () => {
    const wrapper = mount(AppShellLayout, { slots: { navigation: '<a href="/ops">운영</a>', default: '<p>화면 내용</p>' } })
    expect(wrapper.get('.ks-skip').attributes('href')).toBe('#ks-main')
    expect(wrapper.get('aside').attributes('aria-label')).toBe('주요 메뉴')
    expect(wrapper.get('main').attributes('tabindex')).toBe('-1')
    expect(wrapper.get('[role="status"]').text()).toContain('자동주문/KIS 제출 OFF')
  })

  it('keeps page evidence and optional content regions structurally separate', () => {
    const wrapper = mount(PageLayout, {
      props: { title: '데이터 수집', status: 'READONLY', asOf: '2026-08-09T00:00:00Z', version: 'v4' },
      slots: { filters: '<form>조건</form>', default: '<article>본문</article>', aside: '<section>증거</section>', footer: '<button>닫기</button>' }
    })
    expect(wrapper.get('h1').text()).toBe('데이터 수집')
    expect(wrapper.text()).toContain('As-of: 2026-08-09T00:00:00Z')
    expect(wrapper.get('.ks-page__workspace').classes()).toContain('has-aside')
    expect(wrapper.get('.ks-page__footer').get('button').text()).toBe('닫기')
  })
})
