test: the clean-floor total is timed on a real floor, not just counted

The injected-counter test proves "one geometry pass per space" but not
that its result reaches innerContourForRoom — without the shared
arguments that function rebuilds the masonry per room, and the only
observable difference is time (176 ms per room, S2). One large-house
floor: ~0.6 s with the shared pass, ~3.7 s without, so a 2.5 s threshold
is coarse enough not to flake.

Issue: #509
User-Visible: no
This commit is contained in:
Codex
2026-09-10 11:26:29 +03:00
parent 398281a93f
commit e2bb1e5390
+19
View File
@@ -1,5 +1,7 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { makeLargeHouseFixture } from '../demo/fixtures/large-house.mjs';
import { spaceModels } from '../test-build/space-geometry.js';
import { readFileSync } from 'node:fs';
import {
@@ -386,3 +388,20 @@ test('#509 AC3: площадь считает геометрию стен оди
assert.equal(withSpy, totalCleanFloorAreaM2(config, model), 'общая геометрия не меняет результат');
assert.equal(withSpy, 4.32);
});
test('#509 AC3: один этаж большого дома считается без пересборки кладки на каждой комнате', () => {
// Синтетический счётчик выше доказывает «один вызов на пространство», но не
// то, что результат этого вызова ДОШЁЛ до innerContourForRoom: без
// shared-аргументов та объединяет кладку заново для каждой комнаты, и
// единственный наблюдаемый признак — время (S2: 176 мс на комнату).
// Разрыв семикратный, поэтому порог грубый и не флейкует.
const fixture = makeLargeHouseFixture();
const config = { ...fixture.config, spaces: fixture.config.spaces.slice(0, 1) };
const model = spaceModels(config);
assert.equal(model[0].rooms.length, 20, 'фикстура даёт этаж из 20 комнат');
const started = Date.now();
const area = totalCleanFloorAreaM2(config, model);
const elapsed = Date.now() - started;
assert.ok(area > 0, String(area));
assert.ok(elapsed < 2500, `этаж из 20 комнат посчитан за ${elapsed} мс — кладка собирается заново на каждой комнате (#509)`);
});