mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-12 08:51:11 +00:00
Selection: Escape tests for a top-level layer, several layers and the focused frame (#2107 review)
One Escape selects nothing for a top-level frame, a top-level layer, two layers in one group, layers in different parents, and a nested layer with a top-level one. With the focused frame itself selected, one Escape leaves the focus view. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Model-Effort: Opus 5.5 drove and wrote
This commit is contained in:
1 parent
bceb5476e0
commit
92cf984902
2 files changed
+20
No files matched your search
@@ -92,6 +92,12 @@ fn only_the_focused_frame_is_hit_and_escape_leaves() {
|
||||
assert_eq!(focused(&s), None, "Escape with nothing selected leaves");
|
||||
click(&mut s, 350.0, 100.0);
|
||||
assert_eq!(s.selection(), vec![b], "everything is hit again");
|
||||
// With the focused frame itself selected, one Escape leaves the focus view.
|
||||
ex(&mut s, "dev.focus", json!({"id": a}));
|
||||
ex(&mut s, "select.set", json!({"ids": [a]}));
|
||||
assert_eq!(focused(&s), Some(a));
|
||||
s.escape().unwrap();
|
||||
assert_eq!(focused(&s), None, "Escape with the focused frame selected leaves at once");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -277,6 +277,20 @@ fn keyboard_selection() {
|
||||
assert_eq!(s.selection(), Vec::<NodeId>::new(), "Esc from a nested layer selects nothing, not the parent");
|
||||
s.escape().unwrap();
|
||||
assert_eq!(s.selection(), Vec::<NodeId>::new());
|
||||
// A top-level layer, and several layers, nested or not: one Esc selects nothing.
|
||||
let cases: Vec<(Vec<NodeId>, &str)> = vec![
|
||||
(vec![k.f], "a top-level frame"),
|
||||
(vec![k.r], "a top-level layer"),
|
||||
(vec![k.a, k.b], "two layers in one group (not their group)"),
|
||||
(vec![k.a, k.d], "layers in different parents (not the parents)"),
|
||||
(vec![k.a, k.r], "a nested layer and a top-level one"),
|
||||
];
|
||||
for (ids, why) in cases {
|
||||
ex(&mut s, "select.set", json!({"ids": ids}));
|
||||
assert_eq!(sorted(s.selection()), sorted(ids.clone()), "{why}: selected");
|
||||
s.escape().unwrap();
|
||||
assert_eq!(s.selection(), Vec::<NodeId>::new(), "Esc on {why} selects nothing");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user