mirror of
https://github.com/storytold/designcraft.git
synced 2026-10-29 04:36:47 -06:00
Print color: the print test retries across a second boundary, as its sibling does
This commit is contained in:
@@ -96,20 +96,30 @@ mod tests {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"pages": 4})).unwrap();
|
||||
let params = json!({"printer": "Office (east)", "copies": 2, "pages": "2-3", "marks": true, "bleed": true});
|
||||
let expected = super::super::export::pdf_export(&s, ¶ms).unwrap().bytes;
|
||||
let r = print_with(&mut s, ¶ms, |pdf, job| {
|
||||
// The production export options and full bytes reach the shared spooler boundary.
|
||||
assert_eq!(pdf, expected);
|
||||
assert!(pdf.starts_with(b"%PDF-"));
|
||||
assert_eq!(job.printer.as_deref(), Some("Office (east)"));
|
||||
assert_eq!(job.copies, 2);
|
||||
assert_eq!(job.duplex, None);
|
||||
assert_eq!(job.scaling, craft_print::Scaling::ShrinkToFit);
|
||||
assert!(!job.title.is_empty());
|
||||
Ok("request id is Office-1".into())
|
||||
})
|
||||
.unwrap();
|
||||
assert_eq!(r["pages"], 2);
|
||||
// The production export options and full bytes reach the shared spooler boundary. The
|
||||
// creation date is in whole seconds: an attempt can straddle a second boundary.
|
||||
let mut matched = false;
|
||||
for _ in 0..3 {
|
||||
let expected = super::super::export::pdf_export(&s, ¶ms).unwrap().bytes;
|
||||
let mut printed = Vec::new();
|
||||
let r = print_with(&mut s, ¶ms, |pdf, job| {
|
||||
printed = pdf.to_vec();
|
||||
assert!(pdf.starts_with(b"%PDF-"));
|
||||
assert_eq!(job.printer.as_deref(), Some("Office (east)"));
|
||||
assert_eq!(job.copies, 2);
|
||||
assert_eq!(job.duplex, None);
|
||||
assert_eq!(job.scaling, craft_print::Scaling::ShrinkToFit);
|
||||
assert!(!job.title.is_empty());
|
||||
Ok("request id is Office-1".into())
|
||||
})
|
||||
.unwrap();
|
||||
assert_eq!(r["pages"], 2);
|
||||
if printed == expected {
|
||||
matched = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert!(matched, "File › Print spools the selected export's bytes");
|
||||
let refusal = print_with(&mut s, ¶ms, |_, _| Err(craft_print::Error::Spool("printer offline".into()))).unwrap_err();
|
||||
assert!(refusal.to_string().contains("printer offline"));
|
||||
print_with(&mut s, &json!({"dryRun": true}), |_, _| panic!("dry runs must not spool")).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user