From 3e776e4c7d6fb901d2439738b9ced1513ec2c426 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sun, 15 Nov 2026 20:27:16 +0100 Subject: [PATCH] M14: cover PDF suffix case in web downloads Assert exact delivered filenames and PDF bytes for lowercase, uppercase, mixed-case Unicode and missing suffixes. --- crates/ui-egui/src/file_dialogs/tests.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/crates/ui-egui/src/file_dialogs/tests.rs b/crates/ui-egui/src/file_dialogs/tests.rs index 6ab3e77552..4d022b312a 100644 --- a/crates/ui-egui/src/file_dialogs/tests.rs +++ b/crates/ui-egui/src/file_dialogs/tests.rs @@ -465,6 +465,26 @@ fn export_pdf_without_a_path_asks_where_to_save() { let _ = std::fs::remove_dir_all(&dir); } +/// An explicit web PDF export keeps an existing PDF suffix regardless of ASCII case. +#[test] +fn web_pdf_export_keeps_an_existing_suffix_in_any_case() { + let downloaded = Rc::new(RefCell::new(Vec::new())); + let captured = downloaded.clone(); + let services = Services { + download: Some(Box::new(move |name, bytes| { + captured.borrow_mut().push((name.to_string(), bytes.starts_with(b"%PDF"))); + Ok(()) + })), + ..Default::default() + }; + let mut a = WordApp::new(Session::new(wordcraft_doc::Document::new()), services); + for (name, expected) in [("Report.pdf", "Report.pdf"), ("Report.PDF", "Report.PDF"), ("Résumé.PdF", "Résumé.PdF"), ("Report", "Report.pdf")] { + let result = a.execute("file.exportPdf", json!({"path": name})).unwrap(); + assert_eq!(result["downloaded"], expected, "{name}"); + assert_eq!(downloaded.borrow().last().cloned(), Some((expected.to_string(), true)), "{name}"); + } +} + /// Open, Save As and Export PNG from the command search (no path) ask for a file the same way. #[test] fn file_commands_without_a_path_ask_for_one() {