// Step 2 test — --source parity (SC5), --check pass/fail, in-repo default fallback. // Pattern: plugins/voyage/tests/scripts/*.test.mjs (node:test, zero deps). // All vendoring is done into throwaway --target dirs so the repo's own vendored trees are never touched. import { test, after } from 'node:test'; import assert from 'node:assert/strict'; import { spawnSync } from 'node:child_process'; import { mkdtempSync, rmSync, cpSync, readFileSync, appendFileSync, mkdirSync } from 'node:fs'; import os from 'node:os'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; const here = path.dirname(fileURLToPath(import.meta.url)); const REPO_ROOT = path.resolve(here, '..'); const SCRIPT = path.join(REPO_ROOT, 'scripts', 'sync-design-system.mjs'); const IN_REPO_DS = path.join(REPO_ROOT, 'shared', 'playground-design-system'); const VENDOR_REL = path.join('playground', 'vendor', 'playground-design-system'); const tmp = mkdtempSync(path.join(os.tmpdir(), 'ds-sync-')); after(() => rmSync(tmp, { recursive: true, force: true })); const run = (args) => spawnSync(process.execPath, [SCRIPT, ...args], { encoding: 'utf8' }); const manifestOf = (pluginRoot) => JSON.parse(readFileSync(path.join(pluginRoot, VENDOR_REL, 'MANIFEST.json'), 'utf8')); const pluginA = path.join(tmp, 'pluginA'); const pluginB = path.join(tmp, 'pluginB'); const dsCopy = path.join(tmp, 'ds-copy'); test('default (no --source) vendors from the in-repo design system', () => { mkdirSync(pluginA, { recursive: true }); const r = run(['dummy', '--target', pluginA]); assert.equal(r.status, 0, r.stderr); const m = manifestOf(pluginA); assert.equal(m.source, 'shared/playground-design-system/'); assert.ok(m.file_count > 0, 'expected vendored files'); }); test('--source