import { execFileSync } from 'node:child_process' import { mkdtempSync, mkdirSync, writeFileSync } from 'node:fs' import { tmpdir } from 'node:os' import { join } from 'node:path' import { describe, expect, it } from 'vitest' const repositoryRoot = join(process.cwd(), '..') const validator = join(repositoryRoot, 'scripts', 'validate-ui-boundary.mjs') function fixture(source: string) { const root = mkdtempSync(join(tmpdir(), 'kbx-ui-boundary-')) mkdirSync(join(root, 'src', 'features', 'fixture'), { recursive: true }) writeFileSync(join(root, 'src', 'features', 'fixture', 'Example.vue'), source) return root } describe('KBX UI boundary gate', () => { it('passes feature code that uses KBX contracts and reports raw colors as debt warnings', () => { const root = fixture('') const output = execFileSync(process.execPath, [validator, '--root', root], { encoding: 'utf8' }) expect(output).toContain('failures=0') expect(output).toContain('raw color requires token-debt classification') }) it('fails direct vendor imports and supplier CSS leakage in feature code', () => { const root = fixture('') expect(() => execFileSync(process.execPath, [validator, '--root', root], { encoding: 'utf8' })).toThrow() }) })