// plugin-manifest.test.mjs — verify plugin.json schema + CHANGELOG for v3.0. import { test } from 'node:test'; import { strict as assert } from 'node:assert'; import { readFileSync } from 'node:fs'; import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; const __dirname = dirname(fileURLToPath(import.meta.url)); const MANIFEST = join(__dirname, '..', '.claude-plugin', 'plugin.json'); const CHANGELOG = join(__dirname, '..', 'CHANGELOG.md'); test('plugin.json version is 3.1.0', () => { const m = JSON.parse(readFileSync(MANIFEST, 'utf-8')); assert.equal(m.version, '3.1.0'); }); test('plugin.json description mentions STATE.md', () => { const m = JSON.parse(readFileSync(MANIFEST, 'utf-8')); assert.match(m.description, /STATE\.md/); }); test('plugin.json does NOT include auto_discover (not in documented schema)', () => { const m = JSON.parse(readFileSync(MANIFEST, 'utf-8')); assert.ok(!('auto_discover' in m), 'auto_discover field should be removed'); }); test('CHANGELOG has [3.0.0] entry with BREAKING section mentioning STATE.md', () => { const c = readFileSync(CHANGELOG, 'utf-8'); const match = c.match(/## \[3\.0\.0\][\s\S]*?(?=## \[2\.1\.0\]|$)/); assert.ok(match, '[3.0.0] section missing'); assert.match(match[0], /### BREAKING/); assert.match(match[0], /STATE\.md/); }); test('CHANGELOG preserves [2.1.0] and [2.0.0] history', () => { const c = readFileSync(CHANGELOG, 'utf-8'); assert.match(c, /## \[2\.1\.0\]/); assert.match(c, /## \[2\.0\.0\]/); const v20 = c.match(/## \[2\.0\.0\][\s\S]*?(?=## \[1\.0\.0\]|$)/); assert.ok(v20 && /### BREAKING/.test(v20[0]), '[2.0.0] BREAKING section should remain'); }); test('No source files reference version 1.0.0 / 2.x as current', () => { const raw = readFileSync(MANIFEST, 'utf-8'); assert.doesNotMatch(raw, /"version":\s*"[12]\./); });