From b1958ac483d5381fadc02ef7850867f58710613b Mon Sep 17 00:00:00 2001 From: batistalucasv Date: Sun, 22 Nov 2026 21:56:38 -0300 Subject: [PATCH 1/3] test(ui-egui): restore hyperlink_shortcut_focuses_address_and_preserves_document test (#1610) (#7317) --- crates/ui-egui/src/tests.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/crates/ui-egui/src/tests.rs b/crates/ui-egui/src/tests.rs index 29522a3760..265e41b7ea 100644 --- a/crates/ui-egui/src/tests.rs +++ b/crates/ui-egui/src/tests.rs @@ -331,6 +331,35 @@ fn default_chords_fire_their_commands() { } } +/// #1610: opening a hyperlink must direct typing and paste into its address. +#[test] +fn hyperlink_shortcut_focuses_address_and_preserves_document() { + let mut a = app(); + a.run("text.insert", json!({"text": "Keep this text"})).unwrap(); + a.run("select.text", json!({"text": "Keep this text"})).unwrap(); + let mut h = harness(a); + h.run_steps(6); + + for (event, expected) in [ + (egui::Event::Paste("https://example.com".into()), "https://example.com"), + (egui::Event::Text("https://example.org".into()), "https://example.org"), + ] { + press(&mut h, egui::Key::K, egui::Modifiers::COMMAND); + assert!(h.state().dialog_host.open_dialogs().iter().any(|d| d.key.as_deref() == Some("link")), "Link dialog open"); + h.event(event); + h.step(); + h.step(); + let address = h.get_by_label("Address:").value().unwrap_or_default(); + assert_eq!(address, expected, "input replaces the initial address"); + let display = h.get_by_label("Text to display:").value().unwrap_or_default(); + assert_eq!(display, "Keep this text"); + assert_eq!(body_text(h.state()), "Keep this text"); + press(&mut h, egui::Key::Escape, egui::Modifiers::NONE); + assert!(h.state().dialog_host.open_dialogs().is_empty(), "Cancel closes the dialog"); + assert_eq!(h.state().session.selected_text(), "Keep this text", "Cancel preserves selection"); + } +} + /// The key of the dialog a command opened, read off its reply. fn pending_of(reply: &Value) -> Option<&str> { reply.get("pending").and_then(Value::as_str) From 958dd78cebb3883183559b9b15edb0ef5d244c6d Mon Sep 17 00:00:00 2001 From: batistalucasv Date: Wed, 25 Nov 2026 12:48:06 -0300 Subject: [PATCH 2/3] test(ui-egui): speed up hyperlink_shortcut_focuses_address_and_preserves_document --- crates/ui-egui/src/tests.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/tests.rs b/crates/ui-egui/src/tests.rs index 265e41b7ea..9d12b406ea 100644 --- a/crates/ui-egui/src/tests.rs +++ b/crates/ui-egui/src/tests.rs @@ -337,24 +337,34 @@ fn hyperlink_shortcut_focuses_address_and_preserves_document() { let mut a = app(); a.run("text.insert", json!({"text": "Keep this text"})).unwrap(); a.run("select.text", json!({"text": "Keep this text"})).unwrap(); - let mut h = harness(a); - h.run_steps(6); + let mut h = crate::test_harness::builder().with_size(egui::vec2(600.0, 400.0)).build_ui_state( + |ui, app: &mut WordApp| { + let ctx = ui.ctx().clone(); + app.logic(&ctx); + app.dialog_host.run(ui); + }, + a, + ); for (event, expected) in [ (egui::Event::Paste("https://example.com".into()), "https://example.com"), (egui::Event::Text("https://example.org".into()), "https://example.org"), ] { - press(&mut h, egui::Key::K, egui::Modifiers::COMMAND); + h.event(egui::Event::Key { key: egui::Key::K, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::COMMAND }); + crate::test_harness::frame(&mut h); + crate::test_harness::frame(&mut h); assert!(h.state().dialog_host.open_dialogs().iter().any(|d| d.key.as_deref() == Some("link")), "Link dialog open"); h.event(event); - h.step(); - h.step(); + crate::test_harness::frame(&mut h); + crate::test_harness::frame(&mut h); let address = h.get_by_label("Address:").value().unwrap_or_default(); assert_eq!(address, expected, "input replaces the initial address"); let display = h.get_by_label("Text to display:").value().unwrap_or_default(); assert_eq!(display, "Keep this text"); assert_eq!(body_text(h.state()), "Keep this text"); - press(&mut h, egui::Key::Escape, egui::Modifiers::NONE); + h.event(egui::Event::Key { key: egui::Key::Escape, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::NONE }); + crate::test_harness::frame(&mut h); + crate::test_harness::frame(&mut h); assert!(h.state().dialog_host.open_dialogs().is_empty(), "Cancel closes the dialog"); assert_eq!(h.state().session.selected_text(), "Keep this text", "Cancel preserves selection"); } From b4b41e038d869e8f15352218dce173a2d9661663 Mon Sep 17 00:00:00 2001 From: batistalucasv Date: Fri, 27 Nov 2026 01:04:43 -0300 Subject: [PATCH 3/3] Use full app harness and press helper in hyperlink shortcut test (#7317) --- crates/ui-egui/src/tests.rs | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/crates/ui-egui/src/tests.rs b/crates/ui-egui/src/tests.rs index 3c3ce64e31..67a91e867e 100644 --- a/crates/ui-egui/src/tests.rs +++ b/crates/ui-egui/src/tests.rs @@ -397,34 +397,23 @@ fn hyperlink_shortcut_focuses_address_and_preserves_document() { let mut a = app(); a.run("text.insert", json!({"text": "Keep this text"})).unwrap(); a.run("select.text", json!({"text": "Keep this text"})).unwrap(); - let mut h = crate::test_harness::builder().with_size(egui::vec2(600.0, 400.0)).build_ui_state( - |ui, app: &mut WordApp| { - let ctx = ui.ctx().clone(); - app.logic(&ctx); - app.dialog_host.run(ui); - }, - a, - ); + let mut h = harness(a); + h.run_steps(2); for (event, expected) in [ (egui::Event::Paste("https://example.com".into()), "https://example.com"), (egui::Event::Text("https://example.org".into()), "https://example.org"), ] { - h.event(egui::Event::Key { key: egui::Key::K, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::COMMAND }); - crate::test_harness::frame(&mut h); - crate::test_harness::frame(&mut h); + press(&mut h, egui::Key::K, egui::Modifiers::COMMAND); assert!(h.state().dialog_host.open_dialogs().iter().any(|d| d.key.as_deref() == Some("link")), "Link dialog open"); h.event(event); - crate::test_harness::frame(&mut h); - crate::test_harness::frame(&mut h); + h.run_steps(2); let address = h.get_by_label("Address:").value().unwrap_or_default(); assert_eq!(address, expected, "input replaces the initial address"); let display = h.get_by_label("Text to display:").value().unwrap_or_default(); assert_eq!(display, "Keep this text"); assert_eq!(body_text(h.state()), "Keep this text"); - h.event(egui::Event::Key { key: egui::Key::Escape, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::NONE }); - crate::test_harness::frame(&mut h); - crate::test_harness::frame(&mut h); + press(&mut h, egui::Key::Escape, egui::Modifiers::NONE); assert!(h.state().dialog_host.open_dialogs().is_empty(), "Cancel closes the dialog"); assert_eq!(h.state().session.selected_text(), "Keep this text", "Cancel preserves selection"); }