47 lines
2.1 KiB
JavaScript
47 lines
2.1 KiB
JavaScript
// Step 5 test — against an extracted graceful-handoff: no ../../README.md remains, plugin.json
|
|
// repository reconciled, and a second run is a no-op. Pattern: plugins/linkedin-studio/render/__tests__/*.test.mjs.
|
|
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { spawnSync } from 'node:child_process';
|
|
import { readFileSync } from 'node:fs';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
const SCRIPT = path.join(here, '30-fix-references.mjs');
|
|
const WORK = process.env.WORK || '/tmp/polyrepo-migration';
|
|
const DEST = path.join(WORK, 'graceful-handoff');
|
|
|
|
const fix = () => spawnSync(process.execPath, [SCRIPT, 'graceful-handoff'], { encoding: 'utf8', env: { ...process.env, WORK } });
|
|
|
|
// Ensure a fixed state (self-heals extract if needed).
|
|
{
|
|
const r = fix();
|
|
if (r.status !== 0) throw new Error(`fix-references failed: ${r.stdout}\n${r.stderr}`);
|
|
}
|
|
|
|
const grepRel = (needle) =>
|
|
spawnSync('grep', ['-rn', needle, DEST, '--include=*.md'], { encoding: 'utf8' });
|
|
|
|
test('no ../../README.md reference remains in any .md', () => {
|
|
const r = grepRel('../../README.md');
|
|
assert.equal(r.stdout.trim(), '', `unexpected ../../README.md references:\n${r.stdout}`);
|
|
});
|
|
|
|
test('plugin.json repository points at the standalone repo', () => {
|
|
const pj = JSON.parse(readFileSync(path.join(DEST, '.claude-plugin', 'plugin.json'), 'utf8'));
|
|
const url = typeof pj.repository === 'object' ? pj.repository.url : pj.repository;
|
|
assert.ok(url.endsWith('/open/graceful-handoff'), `repository is '${url}'`);
|
|
});
|
|
|
|
test('disclosure footnote is inlined (no dangling cross-repo anchor)', () => {
|
|
const readme = readFileSync(path.join(DEST, 'README.md'), 'utf8');
|
|
assert.ok(!readme.includes('#ai-generated-code-disclosure'), 'the dangling disclosure anchor must be gone');
|
|
assert.ok(readme.includes('AI-generated'), 'the disclosure statement itself is retained inline');
|
|
});
|
|
|
|
test('a second run rewrites zero files (idempotent)', () => {
|
|
const r = fix();
|
|
assert.equal(r.status, 0, r.stderr);
|
|
assert.match(r.stdout, /rewrote 0 file\(s\)/, `expected no-op, got:\n${r.stdout}`);
|
|
});
|