Skip to content

PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust

test(ui): target the Bookmarks submenu item explicitly (#5677)

FredApps0b2f93538ded
diff --git a/crates/ui-egui/tests/it/view.rs b/crates/ui-egui/tests/it/view.rs
index aef5ddae7..7f444bee0 100644
--- a/crates/ui-egui/tests/it/view.rs
+++ b/crates/ui-egui/tests/it/view.rs
@@ -2072,7 +2072,11 @@ fn long_view_menu_fits_a_short_window() {
assert!(after <= 400.0, "the menu scrolls Side panels into view: {after}");
crate::support::menu_row(&h, "Side panels").hover();
h.run_steps(4);
- h.get_all_by_label("Bookmarks").last().unwrap().click();
+ // The navigation rail has a Bookmarks button too; click the submenu's radio item.
+ let bookmarks = h.get_by(|n| n.role() == egui::accesskit::Role::MenuItemRadio && n.label().as_deref() == Some("Bookmarks"));
+ let row = bookmarks.rect();
+ assert!(row.top() >= 0.0 && row.bottom() <= 400.0, "the Bookmarks submenu row is onscreen: {row:?}");
+ bookmarks.click();
h.run_steps(4);
assert_eq!(h.state().right, Some(pdfcraft_ui_egui::RightPanel::Bookmarks));
}