ms-ai-architect/tests/kb-update/test-fixtures-playground-frist-lint.test.mjs

69 lines
3.1 KiB
JavaScript

// tests/kb-update/test-fixtures-playground-frist-lint.test.mjs
// TDD for RX-REG-KB «fixtures-halen» (STATE next-action #2): the AI Act test
// fixtures and the playground demo reports carried pre-Omnibus (and in fact
// pre-existing-error) deadline strings. This lint is the *preventive mechanism*
// (gap-disiplin): once the surgical fixes land, the stale literals must never
// re-enter the fixtures or the demo corpus.
//
// Ground truth (scripts/kb-update/data/ai-act-deadlines.json, verified 2026-07-15):
// - 2026-08-02 = Transparens (Art. 50): merking av syntetisk innhold.
// NOT «GPAI-krav + Annex III høyrisiko» (GPAI applied 2025-08-02).
// - Annex III frittstående høyrisiko full compliance = 2027-12-02
// (deferred from 2026-08-02 via Digital Omnibus).
// - «2027-08-02» is NOT an AI Act deadline at all — it was wrong even
// pre-Omnibus (pre-Omnibus Annex III applied 2026-08-02; 2027-08-02 was
// the Annex I embedded date). The fixtures/playground fabricated it as an
// «Annex III full compliance» date.
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
const pluginRoot = new URL('../../', import.meta.url);
const read = (rel) => readFileSync(new URL(rel, pluginRoot), 'utf8');
const FIXTURES = [
'tests/fixtures/ai-act/fixture.md',
'tests/fixtures/ai-act/fixture-high-risk.md',
];
const PLAYGROUND = 'playground/ms-ai-architect-playground.html';
// --- 1. No phantom «2027-08-02» AI Act deadline in fixtures ---
for (const rel of FIXTURES) {
test(`${rel}: no phantom 2027-08-02 AI Act deadline`, () => {
const md = read(rel);
assert.ok(!md.includes('2027-08-02'),
'2027-08-02 is not an AI Act deadline; Annex III full compliance = 2027-12-02');
});
test(`${rel}: no stale «GPAI-krav + Annex III høyrisiko» on 2026-08-02`, () => {
const md = read(rel);
assert.ok(!/2026-08-02\s*\|\s*GPAI-krav \+ Annex III høyrisiko/.test(md),
'2026-08-02 = Transparens (Art. 50); GPAI applied 2025-08-02, Annex III deferred to 2027-12-02');
});
test(`${rel}: carries corrected Annex III date 2027-12-02`, () => {
const md = read(rel);
assert.ok(md.includes('2027-12-02'),
'Annex III frittstående høyrisiko full compliance = 2027-12-02 (Omnibus)');
});
}
// --- 2. Playground demo reports: no phantom 2027-08-02 Annex III deadline ---
test('playground: no phantom 2027-08-02 AI Act deadline in demo reports', () => {
const html = read(PLAYGROUND);
assert.ok(!html.includes('2027-08-02'),
'demo reports must not present 2027-08-02 as an Annex III compliance deadline');
});
test('playground: no stale «GPAI-krav + Annex III høyrisiko» on 2026-08-02', () => {
const html = read(PLAYGROUND);
assert.ok(!/2026-08-02\s*\|\s*GPAI-krav \+ Annex III høyrisiko/.test(html),
'2026-08-02 = Transparens (Art. 50) in the deadline table');
});
test('playground: demo reports carry corrected Annex III date 2027-12-02', () => {
const html = read(PLAYGROUND);
assert.ok(html.includes('2027-12-02'),
'Annex III full-compliance references must use 2027-12-02 (Omnibus)');
});