From a26f8db0bcc13bc81a0e59200d20a348565d331e Mon Sep 17 00:00:00 2001 From: mtlcl410 <2368091+mtlcl410@users.noreply.github.com> Date: Sat, 31 Oct 2026 07:40:14 +0800 Subject: [PATCH] M6: stamp_custom's line test uses a template the schema accepts (#1741) The test sent a 500-character line, past the schema's maxLength of 200, and only checked an upper bound on the page text, which also passes when the line is missing. It now sends a 198-character template whose filled-in line runs to 264 characters, and checks the saved /PCByLine holds exactly 200. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv --- crates/automation/tests/it/automation.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/crates/automation/tests/it/automation.rs b/crates/automation/tests/it/automation.rs index a769eb83d1..3eabcfee13 100644 --- a/crates/automation/tests/it/automation.rs +++ b/crates/automation/tests/it/automation.rs @@ -9441,10 +9441,20 @@ fn a_custom_stamp_line_is_filled_in_when_placed() { // The stamp stays within the natural 200 pt. Its line, at its usual size, is wider than the // picture, so the stamp is wider than the picture's shape with the band added. assert!(lw / lh > pw / ph * (1.0 - 0.22) + 0.01, "widened for the line: {pw}x{ph} vs {lw}x{lh}"); - // A line past the limit is cut, not refused. - let long = "x".repeat(500); + // A template within the schema's 200 characters whose filled-in line runs past the limit + // (33 times of 8 characters) is cut to exactly 200, not refused. + let long = "{time}".repeat(33); + assert!(long.chars().count() <= 200); ok(&mut a, "stamp_custom", json!({ "doc": doc, "page": 3, "path": "b.pdf", "file_page": 2, "at": [100, 150], "line": long })); - assert!(page_text(&mut a, doc)[2].matches('x').count() <= 200); + ok(&mut a, "doc_save", json!({ "doc": doc, "path": "stamped.pdf" })); + let saved = pdfcraft_cos::Document::open(std::sync::Arc::new(std::fs::read(dir.join("stamped.pdf")).unwrap())).unwrap(); + let lines: Vec = saved + .scan_objects() + .filter_map(|(_, o)| o.as_dict()?.get(b"PCByLine")?.as_string().map(pdfcraft_cos::PdfString::to_text)) + .filter(|l| l.starts_with("10:13 pm")) + .collect(); + assert_eq!(lines.len(), 1, "{lines:?}"); + assert_eq!(lines[0].chars().count(), 200, "{:?}", lines[0]); } /// Three paragraphs: Alpha (two rows), Bravo (one row) and Charlie (two rows), at the leading