From d01efe29e27f04d6692046e56ad994a5f1dfa566 Mon Sep 17 00:00:00 2001 From: sax3l Date: Tue, 22 Sep 2026 21:23:38 +0200 Subject: [PATCH] =?UTF-8?q?test(GOV-06):=20mutation-fixturerna=20bygger=20?= =?UTF-8?q?p=C3=A5=20den=20historiska=20down+402/404-posten=20SYNTEISKT=20?= =?UTF-8?q?=E2=80=94=20inte=20repots=20nuvarande=20evidens=20(som=20med=20?= =?UTF-8?q?r=C3=A4tta=20=C3=A4r=20running+200=20sedan=20flottan-cutovern;?= =?UTF-8?q?=20testerna=20ska=20aldrig=20flippa=20n=C3=A4r=20verkligheten?= =?UTF-8?q?=20flippar)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/repo/siax-doctor.test.ts | 40 +++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/tests/repo/siax-doctor.test.ts b/tests/repo/siax-doctor.test.ts index 122c00b..026d092 100644 --- a/tests/repo/siax-doctor.test.ts +++ b/tests/repo/siax-doctor.test.ts @@ -55,6 +55,20 @@ const REAL_EVIDENCE = JSON.parse( readFileSync(path.join(REPO_ROOT, "evidence", "operational-state.json"), "utf8"), ); +// FIXTURE-BAS: den HISTORISKA, dokumenterade lögner-paret (down + 402/404) +// som en SYNTETISK post — mutationstesterna nedan muterar denna bas, inte +// repots NUVARande evidens (som med rätta är running + 200 sedan flottan- +// cutovern: testerna ska aldrig flippa när verkligheten flippar). +const HISTORIC_EVIDENCE = { + ...REAL_EVIDENCE, + operationalState: "down", + checkedAt: "2026-09-07T00:00:00Z", + probes: [ + { fqdn: "0pt.app", env: "prod", url: "https://0pt.app/api/health", httpStatus: 402, ok: false, note: "server: Vercel (historisk proba, fixture)" }, + { fqdn: "api.0pt.app", env: "prod", url: "https://api.0pt.app/api/health", httpStatus: 404, ok: false, note: "server: Vercel (historisk proba, fixture)" }, + ], +}; + /** The GOV-06 failure detail for a fixture, or null when GOV-06 passed. */ function gov06Failure(root: string): string | null { const { report } = runDoctor(root); @@ -96,12 +110,12 @@ describe("GOV-06: a FALSE operationalState is detected (the historical defect)", for (const d of dirs) rmSync(d, { recursive: true, force: true }); }); - it("accepts the repo's real, honest pairing (down + 402/404) as the control", () => { - expect(gov06Failure(track(fixture(REAL_REPO, REAL_EVIDENCE)))).toBeNull(); + it("accepts the honest pairing (down + 402/404, den historiska lögner-posten) as the control", () => { + expect(gov06Failure(track(fixture({ ...REAL_REPO, operationalState: "down" }, HISTORIC_EVIDENCE)))).toBeNull(); }); it('rejects operationalState "running" when the evidence was recorded for another state', () => { - const detail = gov06Failure(track(fixture({ ...REAL_REPO, operationalState: "running" }, REAL_EVIDENCE))); + const detail = gov06Failure(track(fixture({ ...REAL_REPO, operationalState: "running" }, HISTORIC_EVIDENCE))); expect(detail).toMatch(/running/); expect(detail).toMatch(/operational-state\.json/); }); @@ -111,7 +125,7 @@ describe("GOV-06: a FALSE operationalState is detected (the historical defect)", track( fixture( { ...REAL_REPO, operationalState: "running" }, - { ...REAL_EVIDENCE, operationalState: "running" }, + { ...HISTORIC_EVIDENCE, operationalState: "running" }, ), ), ); @@ -125,9 +139,9 @@ describe("GOV-06: a FALSE operationalState is detected (the historical defect)", fixture( { ...REAL_REPO, operationalState: "running" }, { - ...REAL_EVIDENCE, + ...HISTORIC_EVIDENCE, operationalState: "running", - probes: (REAL_EVIDENCE.probes as { ok: boolean }[]).map((p) => ({ ...p, ok: true })), + probes: (HISTORIC_EVIDENCE.probes as { ok: boolean }[]).map((p) => ({ ...p, ok: true })), }, ), ), @@ -138,9 +152,9 @@ describe("GOV-06: a FALSE operationalState is detected (the historical defect)", it('rejects operationalState "down" when a prod host is recorded as answering', () => { const detail = gov06Failure( track( - fixture(REAL_REPO, { - ...REAL_EVIDENCE, - probes: (REAL_EVIDENCE.probes as { httpStatus: number; ok: boolean }[]).map((p) => ({ + fixture({ ...REAL_REPO, operationalState: "down" }, { + ...HISTORIC_EVIDENCE, + probes: (HISTORIC_EVIDENCE.probes as { httpStatus: number; ok: boolean }[]).map((p) => ({ ...p, httpStatus: 200, ok: true, @@ -158,10 +172,10 @@ describe("GOV-06: a FALSE operationalState is detected (the historical defect)", fixture( { ...REAL_REPO, operationalState: "running" }, { - ...REAL_EVIDENCE, + ...HISTORIC_EVIDENCE, operationalState: "running", checkedAt: stale, - probes: (REAL_EVIDENCE.probes as { httpStatus: number; ok: boolean }[]).map((p) => ({ + probes: (HISTORIC_EVIDENCE.probes as { httpStatus: number; ok: boolean }[]).map((p) => ({ ...p, httpStatus: 200, ok: true, @@ -184,7 +198,7 @@ describe("GOV-06: a FALSE operationalState is detected (the historical defect)", { fqdn: "invented.0pt.app", env: "prod", purpose: "x", registrar: "x" }, ], }, - REAL_EVIDENCE, + HISTORIC_EVIDENCE, ), ), ); @@ -199,7 +213,7 @@ describe("GOV-06: a FALSE operationalState is detected (the historical defect)", ...REAL_REPO, domains: [{ fqdn: "https://0pt.app/health", env: "prod", purpose: "x", registrar: "x" }], }, - REAL_EVIDENCE, + HISTORIC_EVIDENCE, ), ), );