From 92cf9849027aff7dc4a2aee82ecdc1bd1d7a0cd1 Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Sun, 8 Nov 2026 17:38:13 -0500 Subject: [PATCH] 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 Model-Effort: Opus 5.5 drove and wrote --- crates/engine/src/devfocus_tests.rs | 6 ++++++ crates/engine/src/selection_behaviour_tests.rs | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/crates/engine/src/devfocus_tests.rs b/crates/engine/src/devfocus_tests.rs index f36af7ee6..b7a4f9341 100644 --- a/crates/engine/src/devfocus_tests.rs +++ b/crates/engine/src/devfocus_tests.rs @@ -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] diff --git a/crates/engine/src/selection_behaviour_tests.rs b/crates/engine/src/selection_behaviour_tests.rs index b3289c6c3..6498b8cb5 100644 --- a/crates/engine/src/selection_behaviour_tests.rs +++ b/crates/engine/src/selection_behaviour_tests.rs @@ -277,6 +277,20 @@ fn keyboard_selection() { assert_eq!(s.selection(), Vec::::new(), "Esc from a nested layer selects nothing, not the parent"); s.escape().unwrap(); assert_eq!(s.selection(), Vec::::new()); + // A top-level layer, and several layers, nested or not: one Esc selects nothing. + let cases: Vec<(Vec, &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::::new(), "Esc on {why} selects nothing"); + } } #[test]