mirror of
https://github.com/storytold/deckcraft.git
synced 2026-10-31 07:38:16 +00:00
[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 <noreply@anthropic.com>
This commit is contained in:
1 parent
7b424a463b
commit
0efd6f1b85
1 file changed
+30
@@ -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");
|
||||
}
|
||||
Reference in new issue
Block a user