Files
houseplan-card/test/furniture-stroke-contract.test.mjs
T
Codex 2e32cbcb38 fix: small honesty batch from the beta.4 audit (#376)
(а) title: null gets the same compact frame as title: '' — YAML 'title:'
with no value parses as null, the owner's decision makes them synonyms.
(б) the guides state that room labels are inert in the Background editor.
(г) furniture strokes skip the flat-camera compensation in the labs iso
projection, tracking ordinary decor there.
(д) TESTING.md notes the light_pools opt-in for static room cards.
(е) the space-card dispose gate mirrors the strict === true render gate.

User-Visible: yes
Issue: #376
2026-08-29 21:54:29 +03:00

50 lines
2.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
const card = readFileSync(new URL('../src/houseplan-card.ts', import.meta.url), 'utf8');
test('#361 saved furniture and placement preview share the physical screen resolver', () => {
const preview = card.slice(
card.indexOf('private _renderFurniturePlacementPreview('),
card.indexOf('private _renderDecorLayer('),
);
const layer = card.slice(
card.indexOf('private _renderDecorLayer('),
card.indexOf('// ================= shared editor secondary surface'),
);
assert.match(preview, /furnitureStrokePx\([\s\S]*decorCmToUnits\([\s\S]*furnitureScreenScale/);
assert.match(preview, /stroke-width=\$\{strokeWidth\}/);
assert.doesNotMatch(
preview,
/stroke-width=\$\{decorCmToUnits/,
'preview must not bypass the camera-aware furniture resolver',
);
// #376(г): the compensation models the flat camera; the labs iso projection
// must fall back to 1 so furniture strokes track ordinary decor there.
assert.match(layer,
/const furnitureScreenScale = this\._renderProjection === 'iso' \? 1 : furniturePlanScreenScale\(/);
assert.match(layer, /stroke-width="\$\{furnitureStrokePx\(strokeWidth, furnitureScreenScale\)\}"/);
assert.match(layer, /_renderFurniturePlacementPreview\(furnitureScreenScale\)/);
assert.equal(
(layer.match(/furniturePlanScreenScale\(/g) || []).length,
1,
'the viewport scale is resolved once for the whole decor layer',
);
});
test('#361 keeps local anisotropic protection and screen-oriented erase hit separate', () => {
const layer = card.slice(
card.indexOf('private _renderDecorLayer('),
card.indexOf('// ================= shared editor secondary surface'),
);
assert.ok(
(layer.match(/vector-effect="non-scaling-stroke"/g) || []).length >= 2,
'saved and erase paths must keep rejecting the local artwork scale',
);
assert.match(layer, /class="dshape derasehit"[\s\S]*vector-effect="non-scaling-stroke"/);
assert.match(layer, /data-hp="decor"[\s\S]*data-kind="\$\{sh\.kind\}"[\s\S]*data-symbol="\$\{sh\.symbol\}"/);
});