feat(web): render canonical living hedge maze walls
This commit is contained in:
@@ -6,6 +6,8 @@ const zlib = require("node:zlib");
|
||||
|
||||
const samplePath = path.join(__dirname, "..", "..", "docs", "hedge-sample-library.svg");
|
||||
const sample = fs.readFileSync(samplePath, "utf8");
|
||||
const runtimePath = path.join(__dirname, "..", "..", "web", "hedges.svg");
|
||||
const runtime = fs.readFileSync(runtimePath, "utf8");
|
||||
|
||||
test("hedge review sheet is local editable SVG with complete stable symbols", () => {
|
||||
assert.match(sample, /^<svg xmlns="http:\/\/www\.w3\.org\/2000\/svg"/);
|
||||
@@ -25,3 +27,19 @@ test("hedge review sheet is local editable SVG with complete stable symbols", ()
|
||||
assert.ok((sample.match(/<use href=/g) || []).length >= 20);
|
||||
assert.ok(zlib.gzipSync(sample, {level: 9}).length < sample.length);
|
||||
});
|
||||
|
||||
test("runtime hedge sprite remains local and contains approved runtime symbols", () => {
|
||||
assert.match(runtime, /^<svg xmlns="http:\/\/www\.w3\.org\/2000\/svg"/);
|
||||
assert.doesNotMatch(runtime, /<(?:script|image|foreignObject|metadata)\b/i);
|
||||
assert.doesNotMatch(runtime, /(?:href="https?:|url\(|data:|@import|<style\b)/i);
|
||||
for (const identifier of [
|
||||
"hedge-intact-1", "hedge-intact-2", "hedge-intact-3", "hedge-intact-4",
|
||||
"hedge-intact-5", "hedge-intact-6", "hedge-impact-1", "hedge-impact-2",
|
||||
"hedge-impact-3", "hedge-impact-4", "hedge-breakthrough", "hedge-breach-1",
|
||||
"hedge-breach-2", "hedge-breach-3"
|
||||
]) {
|
||||
assert.match(runtime, new RegExp(`id="${identifier}"`));
|
||||
assert.match(sample, new RegExp(`id="${identifier}"`));
|
||||
}
|
||||
assert.ok(zlib.gzipSync(runtime, {level: 9}).length < 4096);
|
||||
});
|
||||
|
||||
@@ -167,7 +167,15 @@ test("playful feedback uses bounded maze-only effects and a top message rail", (
|
||||
assert.match(script, /moveDirections: new Map\(\)/);
|
||||
assert.match(script, /if \(message\.payload\.code === "blocked"\) \{ showImpact\(direction, message\.payload\.breakthroughHits\); feedback\(false\); return; \}/);
|
||||
assert.match(css, /\.cell\.bush-impact/);
|
||||
assert.match(css, /\.cell\.trampled-n::before/);
|
||||
assert.match(css, /\.hedge-layer/);
|
||||
assert.match(css, /\.hedge-edge \{[^}]*height: calc\(var\(--cell\) \* \.2\)/);
|
||||
assert.match(css, /\.hedge-edge\.hedge-vertical \{[^}]*left: calc\(var\(--hedge-x\) \* var\(--cell\) - var\(--cell\) \* \.5\);[^}]*top: calc\(var\(--hedge-y\) \* var\(--cell\) \+ var\(--cell\) \* \.4\)/);
|
||||
assert.match(css, /\.observer-maze \.hedge-edge\.hedge-vertical \{[^}]*top: calc\(var\(--hedge-y\) \* var\(--cell\) \+ var\(--cell\) \* \.5 - 1px\)/);
|
||||
assert.match(css, /\.cell::after \{[^}]*background: #1c1b27;[^}]*opacity: \.55/);
|
||||
assert.match(script, /projectedHedgeEdges/);
|
||||
assert.match(script, /svg\.setAttribute\("viewBox", "0 0 160 40"\)/);
|
||||
assert.match(script, /svg\.setAttribute\("preserveAspectRatio", "none"\)/);
|
||||
assert.match(script, /\/hedges\.svg#/);
|
||||
assert.match(script, /if \(message\.payload\.code === "rate_limited"\) \{ showRateLimit\(\); feedback\(false\); return; \}/);
|
||||
assert.doesNotMatch(script, /Там стена\. Очень убедительная\.|Слишком быстро! Сервер просит немного меньше турбо\./);
|
||||
});
|
||||
@@ -260,6 +268,19 @@ test("chunk assembly replaces projection cells without explored-map memory", ()
|
||||
assert.equal(player.snapshotIsValid({width: 32, height: 33, cells: [], objects: []}), false);
|
||||
});
|
||||
|
||||
test("hedge edges are canonical, bounded, and deterministic", () => {
|
||||
const cells = [[0, 0, 0], [1, 0, 0], [2, 0, 0], [3, 0, 0]];
|
||||
const first = player.projectedHedgeEdges(cells, 2);
|
||||
const second = player.projectedHedgeEdges(cells, 2);
|
||||
assert.deepEqual(first, second);
|
||||
assert.equal(new Set(first.map(edge => edge.key)).size, first.length);
|
||||
assert.ok(first.length <= cells.length * 2 + 2 * 2);
|
||||
assert.equal(player.hedgeVariant(first[0], 6), player.hedgeVariant(first[0], 6));
|
||||
const opened = player.projectedHedgeEdges([[0, 0, 2], [1, 0, 8]], 2);
|
||||
assert.equal(opened.filter(edge => edge.opened).length, 1);
|
||||
assert.equal(player.hedgeKeyForMove(0, 2, "east"), "v:1:0");
|
||||
});
|
||||
|
||||
test("refresh contract restores only the token and waits for server projection", () => {
|
||||
const restore = player.createEnvelope("restore", 1, "restore-1", {token: "0123456789abcdef0123456789abcdef"});
|
||||
assert.deepEqual(Object.keys(restore.payload), ["token"]);
|
||||
|
||||
Reference in New Issue
Block a user