mirror of
https://github.com/Matysh/houseplan-card
synced 2026-09-29 03:09:36 +00:00
52 lines
2.4 KiB
JavaScript
52 lines
2.4 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
|
|
const card = fs.readFileSync(new URL('../src/houseplan-card.ts', import.meta.url), 'utf8');
|
|
const styles = fs.readFileSync(new URL('../src/styles.ts', import.meta.url), 'utf8');
|
|
const en = JSON.parse(fs.readFileSync(new URL('../src/i18n/en.json', import.meta.url), 'utf8'));
|
|
const ru = JSON.parse(fs.readFileSync(new URL('../src/i18n/ru.json', import.meta.url), 'utf8'));
|
|
|
|
test('#277 production controller reaches only fixed-topology Resize', () => {
|
|
for (const removed of [
|
|
'planEdgeDrag', 'applyEdgeDrag', 'clampEdgeDrag',
|
|
'applyRoomScale', 'clampRoomScale', '_rszCornerDown', '_rszScaleLabels',
|
|
'simplifyPoly(',
|
|
]) assert.equal(card.includes(removed), false, `${removed} remains reachable in the card`);
|
|
for (const required of ['resolveSafeResize', 'applySafeResize', 'clampSafeResize', 'validateSafeResize']) {
|
|
assert.equal(card.includes(required), true, `${required} is missing from the controller`);
|
|
}
|
|
});
|
|
|
|
test('#277 corner scale visuals are removed and disabled handles stay accessible', () => {
|
|
for (const removed of ['.rszcorner', '.rszknob', '.rszframe']) {
|
|
assert.equal(styles.includes(removed), false, `${removed} remains in product styles`);
|
|
}
|
|
assert.match(card, /aria-disabled=/);
|
|
assert.match(card, /tabindex="0"/);
|
|
assert.match(card, /_rszDisabledKey/);
|
|
assert.match(styles, /cursor: not-allowed/);
|
|
});
|
|
|
|
test('#277 every stable disabled reason and commit failure is localized RU/EN', () => {
|
|
for (const reason of [
|
|
'diagonal', 'side-angle', 'duplicate-physical-wall', 'partial-shared',
|
|
'unequal-shared', 'multiple-rooms', 'thickness-conflict',
|
|
'opening-conflict', 'invalid-geometry',
|
|
]) {
|
|
const key = `resize.disabled.${reason}`;
|
|
assert.equal(typeof en[key], 'string', `missing EN ${key}`);
|
|
assert.equal(typeof ru[key], 'string', `missing RU ${key}`);
|
|
assert.ok(en[key].trim() && ru[key].trim());
|
|
}
|
|
assert.ok(en['resize.commit_failed']);
|
|
assert.ok(ru['resize.commit_failed']);
|
|
});
|
|
|
|
test('#277 a lossy persistence rekey stops at the last complete preview', () => {
|
|
assert.match(card, /JSON\.stringify\(beforeWallCms\) !== JSON\.stringify\(afterWallCms\)/);
|
|
assert.match(card, /if \(!this\._rszApplyPreview\(res\.polys, res\.openings\)\)/);
|
|
assert.match(card, /this\._rszPreview = previousPreview/);
|
|
assert.match(card, /g\.d = previousD/);
|
|
});
|