import assert from "node:assert/strict"; import { mkdtempSync, readFileSync, rmSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; import test from "node:test"; import { parseRawFacts } from "../../node_modules/@temple2/platform-sdk/core/rel-core.mjs"; import { startClaimipediaServer } from "./server.mjs"; const domainSource = readFileSync(new URL("./domain.rel", import.meta.url), "utf8"); const schemaSource = readFileSync(new URL("./schema.rel", import.meta.url), "utf8"); const routesSource = readFileSync(new URL("./routes.frontend.rel", import.meta.url), "utf8"); const appSource = readFileSync(new URL("./ui/app.js", import.meta.url), "utf8"); const styleSource = readFileSync(new URL("./ui/styles.css", import.meta.url), "utf8"); const serverSource = readFileSync(new URL("./server.mjs", import.meta.url), "utf8"); const facts = parseRawFacts(domainSource); const directory = JSON.parse(readFileSync(new URL("./kingdom-directory.json", import.meta.url), "utf8")); const directoryFacts = parseRawFacts(readFileSync(new URL("./kingdom-directory.facts.rel", import.meta.url), "utf8")); function hasFact(s, p, o) { return facts.some(fact => fact.s === s && fact.p === p && (o === undefined || fact.o === o)); } test("King–Way–Kingdom separates formation scale from influence order", () => { const architecture = "architecture.claimipedia.kingWayKingdom.v1"; assert.equal(hasFact(architecture, "scaleAxis", "axis.claimipedia.kingWayKingdom.scale"), true); assert.equal(hasFact(architecture, "influenceAxis", "axis.claimipedia.influenceOrder"), true); assert.equal(hasFact("axis.claimipedia.kingWayKingdom.scale", "isa", "FormationScaleAxis"), true); assert.equal(hasFact("axis.claimipedia.influenceOrder", "isa", "InfluenceOrderAxis"), true); for (const [movement, index, scale] of [ ["movement.claimipedia.kingWayKingdom.orientation", "1", "personal"], ["movement.claimipedia.kingWayKingdom.formation", "2", "relational"], ["movement.claimipedia.kingWayKingdom.communion", "3", "communal"], ]) { assert.equal(hasFact(movement, "movementIndex", index), true); assert.equal(hasFact(movement, "scale", scale), true); assert.equal(hasFact(movement, "order"), false, `${movement} must not overload influence order`); } }); test("all three movements are load-bearing claims and Kingdom has symmetric valences", () => { const claims = [ "claim.claimipedia.loadBearing.jesusIsKing", "claim.claimipedia.loadBearing.followMeThirdOrder", "claim.claimipedia.loadBearing.kingdom", ]; for (const claim of claims) assert.equal(hasFact(claim, "weight", "load-bearing"), true, claim); assert.equal(hasFact(claims[2], "route", "/claim/the-kingdom"), true); assert.equal(hasFact(claims[2], "proValence", "claim.claimipedia.loadBearing.kingdom.pro"), true); assert.equal(hasFact(claims[2], "conValence", "claim.claimipedia.loadBearing.kingdom.con"), true); assert.equal(hasFact("relationship.claimipedia.kingdom.pro", "relationType", "Supports"), true); assert.equal(hasFact("relationship.claimipedia.kingdom.con", "relationType", "Challenges"), true); }); test("the invitation claims keep stable breadcrumbs and five-axis hero language", () => { for (const [route, title] of [ ["claim/jesus-is-king", "Jesus is King"], ["claim/follow-me-third-order-influence", "Follow me"], ["claim/the-kingdom", "The Kingdom"], ]) assert.match(appSource, new RegExp(`"${route}":"${title}"`, "u")); assert.match(appSource, /href="\/#\/invitation">Invitation<\/a>