Files
houseplan-card/test/furniture-assets.test.mjs
T
Codex 9b4e1efb1d feat: арт мебели в ленивый чанк — стартовый граф 299 658 → 289 727 Б
Каталог (id, группа, размеры) остаётся eager; SVG-пути 44 дизайнерских
символов — отдельный чанк за FurnitureArtRuntime (ready|pending|fallback,
нонс на повторе, отпечаток сборки, осевший отказ). Запуск при приёме плана,
бут-вуаль ждёт арт в пределах BOOT_MAX_MS, редактор отдаёт арт рантайму
синхронно (adopt при загрузке чанка). Магнит проверяет каталог, не арт.
Потолок initial View 300 500 → 290 500. Семь свидетелей, смок
smoke_furniture_lazy_art, golden-harness требует все предметы после бута.
Ядро −2 строки.

Issue: #474
User-Visible: no
2026-09-06 16:10:46 +03:00

60 lines
3.1 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import { spawnSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';
import { GENERATED_FURNITURE_CATALOG } from '../test-build/furniture-plan-catalog.generated.js';
import { GENERATED_FURNITURE_ART } from '../test-build/furniture-plan-art.generated.js';
import { FURNITURE } from '../test-build/furniture.js';
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const MANIFEST = JSON.parse(fs.readFileSync(
path.join(ROOT, 'assets', 'furniture', 'houseplan-0.3.0', 'pack.json'), 'utf8'));
test('the vendored designer pack and generated modules stay in sync', () => {
const result = spawnSync(process.execPath, ['scripts/generate-furniture-assets.mjs', '--check'], {
cwd: ROOT,
encoding: 'utf8',
});
assert.equal(result.status, 0, result.stderr || result.stdout);
assert.match(result.stdout, /44 plan symbols, 33 menu icons/);
});
test('the designer pack has the reviewed cardinality and operations', () => {
assert.equal(GENERATED_FURNITURE_CATALOG.length, 44);
// #474: catalogue ids and lazy artwork keys are the same set.
assert.deepEqual(Object.keys(GENERATED_FURNITURE_ART).sort(), GENERATED_FURNITURE_CATALOG.map((s) => s.id).sort());
assert.equal(MANIFEST.menu_icons.length, 33);
assert.equal(MANIFEST.symbols.filter((s) => s.operation === 'replace').length, 18);
assert.equal(MANIFEST.symbols.filter((s) => s.operation === 'add').length, 26);
assert.equal(FURNITURE.length, 56);
});
test('menu-only artwork never becomes an empty user-facing category', () => {
const categories = new Set(FURNITURE.map((symbol) => symbol.category));
for (const id of ['computer', 'oven', 'hood', 'exercise']) assert.equal(categories.has(id), false);
for (const id of ['coffee_table', 'bed', 'kitchen_cabinet', 'toilet']) assert.equal(categories.has(id), true);
});
test('front-view menu artwork is reachable only through the lazy editor graph', () => {
const card = fs.readFileSync(path.join(ROOT, 'src', 'houseplan-card.ts'), 'utf8');
const furniture = fs.readFileSync(path.join(ROOT, 'src', 'furniture.ts'), 'utf8');
const runtime = fs.readFileSync(path.join(ROOT, 'src', 'houseplan-editor-runtime.ts'), 'utf8');
const decorImageEditor = fs.readFileSync(path.join(ROOT, 'src', 'decor-image-editor.ts'), 'utf8');
assert.doesNotMatch(card, /furniture-menu-art\.generated/);
assert.doesNotMatch(furniture, /furniture-menu-art\.generated/);
assert.match(runtime, /from '\.\/decor-image-editor'/);
assert.match(decorImageEditor, /from '\.\/furniture-menu-art\.generated'/);
});
test('release provenance is normalized to the repository MIT grant', () => {
assert.equal(MANIFEST.author, 'Sergey Matyunin (Matysh)');
assert.equal(MANIFEST.license, 'MIT');
const readme = fs.readFileSync(
path.join(ROOT, 'assets', 'furniture', 'houseplan-0.3.0', 'README.md'), 'utf8');
assert.match(readme, /issuecomment-5454085168/);
assert.match(readme, /issuecomment-5449707137/);
assert.match(readme, /9E969016EE3B4B4E3DB776FEC53C8B387B91368B118EB5E39911483DEF1B0953/);
});