From 5d601bbd984c00341373e1456872051c612a033f Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Sat, 7 Nov 2026 18:42:50 -0600 Subject: [PATCH] Note Clear All tests: Enter is OK and Escape is Cancel (eliets2 review on crates/ui-egui/src/tools/note_clear_all_tests.rs, keyboard) Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/tools/note_clear_all_tests.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/ui-egui/src/tools/note_clear_all_tests.rs b/crates/ui-egui/src/tools/note_clear_all_tests.rs index 39a2cc4f10f..a30a253d855 100644 --- a/crates/ui-egui/src/tools/note_clear_all_tests.rs +++ b/crates/ui-egui/src/tools/note_clear_all_tests.rs @@ -173,3 +173,17 @@ fn the_alert_shows_its_question_and_its_buttons_answer() { assert_eq!(steps(h.state()), before + usize::from(left == 0), "{button}: history"); } } + +#[test] +fn enter_is_ok_and_escape_is_cancel() { + for (key, left) in [(egui::Key::Escape, 3), (egui::Key::Enter, 0)] { + let mut h = harness_with_dialogs(app()); + let before = steps(h.state()); + clear_all(&mut h); + h.key_press(key); + h.run_steps(3); + assert!(alert(h.state()).is_none(), "{key:?} closes the alert"); + assert_eq!(notes(h.state()), left, "{key:?}: {left} notes left"); + assert_eq!(steps(h.state()), before + usize::from(left == 0), "{key:?}: history"); + } +}