fix: validate optimize opening rehosts

Issue: #280
User-Visible: yes
This commit is contained in:
Sergey Matyunin
2026-08-24 10:33:05 +03:00
parent 93fad8cfb4
commit 38ea8a9b9e
10 changed files with 427 additions and 6 deletions
+9
View File
@@ -14,6 +14,10 @@ const fixture = JSON.parse(readFileSync(
new URL('./fixtures/276-coincident-partition.json', import.meta.url),
'utf8',
));
const backendCandidate = JSON.parse(readFileSync(
new URL('./fixtures/280-optimize-rehost-candidate.json', import.meta.url),
'utf8',
));
const clone = (value) => structuredClone(value);
const optimize = (config) => optimizePlans(config, {});
@@ -42,6 +46,11 @@ test('issue 276 reconciles the anonymized 5 cm offset fixture without moving its
assert.equal(intervals.length, 2);
assert.deepEqual(new Set(intervals.map((interval) => interval.cm)), new Set([20]));
assert.equal(checkOptimizeGeometry(result.config).ok, true);
assert.deepEqual(
result.config,
backendCandidate,
'the frontend result must stay identical to the candidate proved by Python',
);
const second = optimize(result.config);
assert.equal(second.changed, false);
+57
View File
@@ -0,0 +1,57 @@
{
"model_version": 7,
"spaces": [
{
"id": "offset-shared-wall",
"title": "Offset shared wall",
"view_box": [0, 0, 1, 1],
"cell_cm": 5,
"rooms": [
{
"id": "left",
"name": "Left",
"area": null,
"poly": [
[0, 0], [0.5, 0], [0.5, 0.004166667],
[0.504166667, 0.004166667], [0.504166667, 0.995833333],
[0.5, 0.995833333], [0.5, 1], [0, 1]
]
},
{
"id": "right",
"name": "Right",
"area": null,
"poly": [
[0.504166667, 0.004166667], [1, 0.004166667],
[1, 0.995833333], [0.504166667, 0.995833333]
]
}
],
"walls": [
{
"key": "0.504167,0.500000@1.5706",
"cm": 20,
"a": [0.504166667, 0.004166667],
"b": [0.504166667, 0.995833333]
}
],
"openings": [
{
"id": "hosted-door",
"type": "door",
"x": 0.504166667,
"y": 0.5,
"angle": -90,
"length": 0.2,
"contact": "binary_sensor.test_door",
"lock": "lock.test_door",
"invert": true,
"flip_h": true,
"future_field": { "keep": true }
}
]
}
],
"markers": [],
"settings": {}
}