From ff2962c2f4f2d76ec19961490df1abd0e7cad5c0 Mon Sep 17 00:00:00 2001 From: alehel Date: Thu, 22 Oct 2026 17:58:11 +0200 Subject: [PATCH] =?UTF-8?q?fix(ui):=20test=20that=20Properties=20=E2=96=B8?= =?UTF-8?q?=20Space=20Audit=20measures=20again=20after=20an=20edit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The tab caches the audit per document and edit generation. Pin both halves: frames with the file unchanged keep the same rows, and an edit made while the tab is open (a new bookmark) shows up on the next frame. With the cache keyed on the document alone, the test fails. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/tests/it/dialog_chrome.rs | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/crates/ui-egui/tests/it/dialog_chrome.rs b/crates/ui-egui/tests/it/dialog_chrome.rs index b6be218ecd..d33ea7baac 100644 --- a/crates/ui-egui/tests/it/dialog_chrome.rs +++ b/crates/ui-egui/tests/it/dialog_chrome.rs @@ -168,6 +168,40 @@ fn space_audit_tab_measures_the_file_and_stays_in_the_card() { } } +#[test] +fn space_audit_tab_measures_again_after_an_edit() { + use pdfcraft_engine::optimize::SpaceCategory; + let mut h = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(|_cc| { + let mut app = PdfCraftApp::new(); + app.set_option("language", "en").unwrap(); + app.open_bytes("doc.pdf", None, fixture()).unwrap(); + app.set_option("dialog", "space-audit").unwrap(); + app + }); + h.run_steps(4); + let bookmarks = + |h: &Harness<'_, PdfCraftApp>| h.state().space_audit.iter().filter(|r| r.category == SpaceCategory::Bookmarks).map(|r| r.bytes).sum::(); + let before = h.state().space_audit.clone(); + assert_eq!(bookmarks(&h), 0, "the fixture has no outline: {before:?}"); + // Further frames with the file unchanged keep the same measurement. + h.run_steps(2); + assert_eq!(h.state().space_audit, before); + // An edit while the tab is open is measured on the next frame. + h.state_mut().apply_edit(pdfcraft_engine::Edit::AddBookmark { + parent: vec![], + index: 0, + title: "Chapter".into(), + page: 0, + left: None, + top: None, + }); + h.run_steps(2); + assert!(bookmarks(&h) > 0, "the new outline is counted: {:?}", h.state().space_audit); + // The table shows the new row (the rail's Bookmarks button has the same label). + let card = card(&h, "dialog"); + assert!(h.query_all_by_label("Bookmarks").any(|n| card.contains_rect(n.rect())), "a Bookmarks row in {card:?}"); +} + #[test] fn dialog_buttons_follow_the_content_after_a_taller_tab() { use pdfcraft_ui_egui::{Dialog, PropsTab};