test: keep edit walk behind optimize preflight

Issue: #322
User-Visible: no
This commit is contained in:
Matysh
2026-08-27 15:10:46 +03:00
parent 780b7a6c7a
commit 9b7a700fd6
+13 -2
View File
@@ -37,6 +37,7 @@ execFileSync(process.execPath, [resolve(root, 'scripts/fix-test-build.mjs')], {
cwd: root, stdio: 'inherit',
});
const { optimizePlans } = await import('../test-build/plan-optimizer.js');
const { checkOptimizeGeometry } = await import('../test-build/plan-geometry-preflight.js');
const { WallSegmentModelError } = await import('../test-build/wall-segment-model.js');
const {
checkHiddenObstacles, checkMixedRoleRecords, checkWallKeys, checkReferences,
@@ -266,8 +267,18 @@ for (const plan of PLANS) {
const before = await currentConfig();
try {
const result = optimizePlans(before, {}, {}, {});
await install(result.config);
action = `оптимизация (изменений: ${result.report.total})`;
// The product shows the preview but refuses to apply a candidate
// rejected by the exact geometry preflight. The walk must exercise
// that same transaction boundary rather than installing the pure
// optimizer's intermediate result behind the card's back.
const preflight = result.changed ? checkOptimizeGeometry(result.config) : null;
if (preflight && !preflight.ok) {
const reasons = [...new Set(preflight.failures.map((failure) => failure.reason))];
action = `оптимизация безопасно заблокирована (${reasons.join(', ')})`;
} else {
await install(result.config);
action = `оптимизация (изменений: ${result.report.total})`;
}
} catch (error) {
if (!(error instanceof WallSegmentModelError)) throw error;
action = `оптимизация безопасно заблокирована (${error.reason})`;