test(file_browser): restore no_keytips_behind_the_browser test (#7317) (#7620)

This commit is contained in:
Lucas Batista Vargas
2026-11-26 21:02:23 +00:00
committed by GitHub
parent 5d2153c15d
commit c98954d755
+55
View File
@@ -45,3 +45,58 @@ fn a_dialog_closing_into_the_browser_leaves_it_the_keyboard() {
let after_doc = h.state().session.doc.plain_text(wordcraft_doc::StoryRef::Body);
assert_eq!(after_doc, before_doc, "typing does not leak into the document behind the browser");
}
/// #3859: no keytips behind the browser.
#[test]
fn no_keytips_behind_the_browser() {
let a = WordApp::new(Session::new(wordcraft_doc::Document::new()), Services::default());
let mut h = crate::test_harness::builder().with_size(vec2(1440.0, 900.0)).build_ui_state(
|ui, app: &mut WordApp| {
let ctx = ui.ctx().clone();
crate::test_harness::logic(&ctx, app);
app.ui(ui);
},
a,
);
crate::test_harness::frames(&mut h, 4);
let ctx = h.ctx.clone();
h.state_mut().canvas.focus_page(&ctx);
crate::test_harness::frames(&mut h, 2);
let keytip_badges = |h: &egui_kittest::Harness<'_, WordApp>| -> Vec<String> {
const TAB_BADGES: [&str; 11] = ["F", "H", "N", "D", "G", "P", "S", "M", "R", "W", "Y"];
h.output()
.shapes
.iter()
.filter_map(|s| match &s.shape {
egui::Shape::Text(t) if TAB_BADGES.contains(&t.galley.text()) => Some(t.galley.text().to_string()),
_ => None,
})
.collect()
};
assert!(!h.state().keytips_active, "keytips start off");
assert!(keytip_badges(&h).is_empty(), "no keytip badges start painted: {:?}", keytip_badges(&h));
let folders = FolderCache::new(Arc::new(FakeDirectories::new().folder("/d/drafts")), Arc::new(ManualJobs::new()), Wake::none());
let req = PickRequest::open("document").directory("/d").fallback(true);
h.state_mut().dialog_host.open(FileChooser::new(req, None, folders));
crate::test_harness::frames(&mut h, 4);
assert!(h.state().dialog_host.is_open::<FileChooser>(), "the browser is open");
h.key_press(egui::Key::F10);
crate::test_harness::frames(&mut h, 2);
assert!(!h.state().keytips_active, "F10 does not activate keytips while the browser is open");
assert!(keytip_badges(&h).is_empty(), "no keytip badges are painted behind the browser: {:?}", keytip_badges(&h));
// Close the browser and check F10 works as a control.
h.key_press(egui::Key::Escape);
crate::test_harness::frames(&mut h, 4);
assert!(!h.state().dialog_host.is_open::<FileChooser>(), "Escape closes the browser");
assert!(!h.state().modal_open(), "no modal remains open after closing the browser");
h.key_press(egui::Key::F10);
crate::test_harness::frames(&mut h, 2);
assert!(h.state().keytips_active, "F10 activates keytips once the browser is closed");
assert!(!keytip_badges(&h).is_empty(), "keytip badges paint once the browser is closed");
}