import { readdirSync, readFileSync } from 'node:fs'
import { join } from 'node:path'
import { describe, expect, it } from 'vitest'

function componentSources(root: string): string[] {
  return readdirSync(root, { withFileTypes: true })
    .filter(entry => entry.isFile() && entry.name.endsWith('.vue'))
    .map(entry => join(root, entry.name))
}

describe('existing component ownership boundary', () => {
  it('prevents existing components from regressing to adapter-owned rendering', () => {
    const root = join(process.cwd(), 'src', 'shared', 'ui', 'components')
    const forbidden = /useUiAdapter|adapter\.components/
    const violations = componentSources(root).filter(path => forbidden.test(readFileSync(path, 'utf8')))

    expect(violations).toEqual([])
  })
})
