Files
houseplan-card/test/houseplan-runtime-contract.test.mjs
T
Matysh 9e74051652 Release v1.62.0-beta.8 candidate
Issue: #75
Issue: #76
Issue: #95
User-Visible: yes
2026-08-12 19:18:54 +03:00

33 lines
1.6 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
const cardSource = readFileSync(new URL('../src/houseplan-card.ts', import.meta.url), 'utf8');
const secondarySource = readFileSync(new URL('../src/editor-secondary.ts', import.meta.url), 'utf8');
test('split commit materialises the old wall profile before replacing room outlines', () => {
const materialiseAt = cardSource.indexOf('const splitWalls = wasSplit');
const mutateAt = cardSource.indexOf('main.poly = this._pendingSplit.mainPoly');
const normaliseAt = cardSource.indexOf('this._normalizeWalls(splitWalls');
assert.ok(materialiseAt >= 0 && mutateAt > materialiseAt && normaliseAt > mutateAt);
assert.match(cardSource.slice(materialiseAt, mutateAt), /materializeWallIntervals\([\s\S]*pendingSplit/);
});
test('spatial glow rejects both wall masonry and independent physical bodies', () => {
assert.match(
cardSource,
/pointInOpaquePlanBody\(sourcePoint, masonryGeometry, physical\)/,
);
});
test('late editor permission is adopted through the mode state machine', () => {
assert.doesNotMatch(cardSource, /this\._mode\s*=\s*this\._pendingNavMode/);
assert.match(cardSource, /this\._pendingNavMode = null;\s*this\._setMode\(pendingMode, false\)/);
});
test('editor navigation stays actionable while transient editor surfaces dismiss', () => {
assert.match(cardSource, /data-editor-navigation="view"/);
assert.match(secondarySource, /hasAttribute\('data-editor-navigation'\)/);
assert.match(secondarySource, /if \(onNavigation\)[\s\S]*return false;/);
});