From 0efd6f1b853395ee753dd2848aab96db08643bba Mon Sep 17 00:00:00 2001 From: Zach Berry <1112351+zberry@users.noreply.github.com> Date: Mon, 19 Oct 2026 00:14:43 -0500 Subject: [PATCH] [HH12] Pin that exporting a slide again overwrites the PNG Not a bug: file.export writes the second PNG over the first with the edit in it. The test pins it (export, edit, export to the same path, files differ). PowerPoint: Save As / Export to an existing file name replaces the file. Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/tests.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index deeca260..ac9183c3 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -5672,3 +5672,33 @@ fn picture_reset_keeps_the_frame_shape() { let doc = command_specs().iter().find(|c| c.id == "picture.reset").unwrap().params; assert!(doc.contains("frame shape"), "{doc}"); } + +/// HH12: exporting the same slide twice to one PNG path after an edit overwrites the file with +/// the new picture (not a bug: the second file differs). +#[test] +fn exporting_a_slide_again_overwrites_the_png_with_the_edit() { + /// Removes the folder when the test ends, a failed assertion included. + struct Cleanup(std::path::PathBuf); + impl Drop for Cleanup { + fn drop(&mut self) { + let _ = std::fs::remove_dir_all(&self.0); + } + } + // A folder of this run's own: created exclusively (never one an earlier or parallel run left). + let stamp = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map_or(0, |d| d.as_nanos()); + let dir = (0..100) + .map(|k| std::env::temp_dir().join(format!("deckcraft-hh12-{}-{stamp}-{k}", std::process::id()))) + .find(|d| std::fs::create_dir(d).is_ok()) + .expect("a fresh temporary folder"); + let _cleanup = Cleanup(dir.clone()); + let png = dir.join("slide.png"); + let mut s = session(); + let path = png.to_string_lossy().to_string(); + s.execute("file.export", &json!({"path": path, "format": "png", "slide": 0, "scale": 0.5})).unwrap(); + let first = std::fs::read(&png).unwrap(); + s.execute("shape.insert", &json!({"preset": "rect", "rect": [100, 100, 400, 300]})).unwrap(); + s.execute("shape.fill", &json!({"color": "#FF0000"})).unwrap(); + s.execute("file.export", &json!({"path": path, "format": "png", "slide": 0, "scale": 0.5})).unwrap(); + let second = std::fs::read(&png).unwrap(); + assert_ne!(first, second, "the second export replaced the file with the edited slide"); +}