From 3a9c4fc3862e3235fa14968ea44520d034792beb Mon Sep 17 00:00:00 2001 From: Codex Date: Thu, 3 Dec 2026 00:23:57 +0100 Subject: [PATCH] Describe the browser handoff and cover retrying selected artboards --- apps/vectorcraft-web/src/web.rs | 5 ++- crates/ui-egui/src/dialogs/tests_print.rs | 39 +++++++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/apps/vectorcraft-web/src/web.rs b/apps/vectorcraft-web/src/web.rs index ca0226632b..7e9ece12f3 100644 --- a/apps/vectorcraft-web/src/web.rs +++ b/apps/vectorcraft-web/src/web.rs @@ -562,8 +562,7 @@ fn blob_url(bytes: &[u8], mime: &str) -> Result { web_sys::Url::create_object_url_with_blob(&blob).map_err(js_err) } -/// File → Print in the browser: the job's PDF in a hidden frame, printed through the browser's -/// print dialog (which picks the printer). +/// Hands File → Print's composed PDF to the shared browser workflow. struct BrowserPrint; impl PrintService for BrowserPrint { @@ -574,6 +573,6 @@ impl PrintService for BrowserPrint { fn print(&mut self, job: &PrintJob) -> Result { craft::print::browser::print_pdf(job.pdf)?; - Ok(format!("Printing “{}”: pick the printer in the browser's print dialog", job.title)) + Ok(format!("“{}” is ready to print in the browser", job.title)) } } diff --git a/crates/ui-egui/src/dialogs/tests_print.rs b/crates/ui-egui/src/dialogs/tests_print.rs index 35bc78f194..cad7fccd60 100644 --- a/crates/ui-egui/src/dialogs/tests_print.rs +++ b/crates/ui-egui/src/dialogs/tests_print.rs @@ -171,6 +171,45 @@ fn print_sends_every_page_to_the_chosen_printer_and_keeps_the_settings() { assert_eq!(fields(&app)["copies"], 2); } +/// The browser supplies its own printer picker and can refuse to open it. Retrying prints +/// only the artboards the user selected in the same File → Print window. +#[test] +fn refused_browser_handoff_keeps_the_selected_artboards_for_retry() { + struct Browser { + refuse: bool, + accepted: Jobs, + } + impl PrintService for Browser { + fn printers(&mut self) -> Vec { + Vec::new() + } + + fn print(&mut self, job: &PrintJob) -> Result { + if std::mem::take(&mut self.refuse) { + return Err("The browser could not open the print document".into()); + } + MockPrint(self.accepted.clone()).print(job) + } + } + + let (mut app, jobs) = app(); + app.services.print = Some(Box::new(Browser { refuse: true, accepted: jobs.clone() })); + app.run("file.print", json!({})).unwrap(); + pump(&mut app); + set(&mut app, "artboards", json!("range")); + set(&mut app, "range", json!("2-3")); + confirm(&mut app); + assert!(is_open(&app)); + assert_eq!(fields(&app)["range"], "2-3"); + assert!(jobs.borrow().is_empty()); + confirm(&mut app); + assert!(!is_open(&app)); + let accepted = jobs.borrow(); + assert_eq!(accepted.len(), 1); + assert_eq!(accepted[0].0, None); + assert_eq!(pages(&accepted[0].2), 2); +} + #[test] fn done_keeps_the_settings_without_printing_and_bad_settings_keep_the_dialog() { let (mut app, jobs) = app();