engine: nested ungroup test compares site counts and checks the selection

The test compared each shape's connection sites before and after through
zip, which stops at the shorter list, so a shape that lost sites would still
pass. It now checks the counts first. The case with three nested groups also
checks that the freed shapes are selected.
This commit is contained in:
Simon Koch-Sultan committed 2026-11-08 09:01:24 -05:00
1 parent 1c8b14edad
commit de5398cfc5
1 file changed
+3
+3
View File
@@ -932,6 +932,7 @@ fn ungrouping_a_nested_group_frees_its_shapes_into_the_outer_group() {
assert_eq!(order, [sid(a), sid(b), sid(c)], "case {n}");
for (id, was) in [a, b, c].into_iter().zip(before) {
let now = sites(&s, id);
assert_eq!(was.len(), now.len(), "case {n}: shape {id}");
assert!(was.iter().zip(&now).all(|(p, q)| (*p - *q).hypot() < 1e-6), "case {n}: shape {id} moved from {was:?} to {now:?}");
}
}
@@ -947,11 +948,13 @@ fn ungrouping_a_nested_group_frees_its_shapes_into_the_outer_group() {
let before = [a, b, c, d].map(|id| sites(&s, id));
let r = s.execute("arrange.ungroup", &json!({"ids": [inner, middle]})).unwrap();
assert_eq!(r["ids"], json!([a, b, c]));
assert_eq!(s.doc().unwrap().selection.shapes, [sid(a), sid(b), sid(c)]);
let st = s.doc().unwrap();
let order: Vec<ShapeId> = deckcraft_model::find_shape(st.shapes(), sid(outer)).unwrap().children().iter().map(|x| x.id).collect();
assert_eq!(order, [sid(a), sid(b), sid(c), sid(d)]);
for (id, was) in [a, b, c, d].into_iter().zip(before) {
let now = sites(&s, id);
assert_eq!(was.len(), now.len(), "shape {id}");
assert!(was.iter().zip(&now).all(|(p, q)| (*p - *q).hypot() < 1e-6), "shape {id} moved from {was:?} to {now:?}");
}
}