mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-28 20:18:06 -06:00
fix(ui): test that Properties ▸ Space Audit measures again after an edit
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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
16d2b2ef50
commit
ff2962c2f4
@@ -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::<u64>();
|
||||
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};
|
||||
|
||||
Reference in New Issue
Block a user