From 3416fe81f6972f40f406149fe3fd3cd7dd9b6370 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Mon, 9 Nov 2026 02:00:25 +0700 Subject: [PATCH] Fill & Sign test checks Escape writes nothing by edits, not saved bytes The test compared two saves' bytes, which carry the save time, so it failed when the saves landed in different seconds (seen on CI). It now checks that the edit generation, the unsaved state and the undo step are unchanged and that the one annotation is all there is. --- crates/ui-egui/tests/it/fill_sign.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/tests/it/fill_sign.rs b/crates/ui-egui/tests/it/fill_sign.rs index b5bb52cfa7..fe65314fa4 100644 --- a/crates/ui-egui/tests/it/fill_sign.rs +++ b/crates/ui-egui/tests/it/fill_sign.rs @@ -2527,10 +2527,17 @@ fn fill_sign_enter_adds_lines_outside_click_commits_and_escape_cancels() { let annot = &session.get(reopened).unwrap().info.annotations[0]; assert_eq!(annot.contents.as_deref(), Some(text)); assert!(annot.rect[3] - annot.rect[1] >= 5.0 * 10.0 * 1.2, "the saved box keeps all five lines"); + // Compared as edits, not saved bytes: a save stamps its time, so two saves a second apart differ. + let unchanged = |h: &Harness<'static, PdfCraftApp>| { + let doc = h.state().session.get(id).unwrap(); + (doc.edit_generation(), doc.dirty, doc.can_undo().map(str::to_owned)) + }; + let before = unchanged(&h); click(&mut h, 50.0, 180.0); fill_input(&mut h, [egui::Event::Text("Cancel me".into())]); fill_key(&mut h, egui::Key::Enter); fill_key(&mut h, egui::Key::Escape); assert!(h.state().views[0].fill_text.is_none()); - assert_eq!(h.state().session.save_bytes(id).unwrap(), saved, "Escape cancels without writing"); + assert_eq!(unchanged(&h), before, "Escape cancels without writing"); + assert_eq!(items(&h), [("FreeText".to_owned(), Some(text.to_owned()))]); }