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.
This commit is contained in:
bflatastic committed 2026-11-09 02:00:25 +07:00
1 parent 43f24aa169
commit 3416fe81f6
1 file changed
+8 -1
+8 -1
View File
@@ -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()))]);
}