From 27d3b4acf5ac48d62db2e9390e08e5a4e2daea7b Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Fri, 13 Nov 2026 04:08:30 -0500 Subject: [PATCH] Keep StencilCraft v1 fixtures with shared document crate --- crates/stencilcraft-document/src/lib.rs | 9 +- .../tests/fixtures/poster.stencilcraft | 98 ++++++++++++++++ .../tests/fixtures/starter.stencilcraft | 111 ++++++++++++++++++ .../tests/fixtures/stencil-frame.stencilcraft | 86 ++++++++++++++ 4 files changed, 301 insertions(+), 3 deletions(-) create mode 100644 crates/stencilcraft-document/tests/fixtures/poster.stencilcraft create mode 100644 crates/stencilcraft-document/tests/fixtures/starter.stencilcraft create mode 100644 crates/stencilcraft-document/tests/fixtures/stencil-frame.stencilcraft diff --git a/crates/stencilcraft-document/src/lib.rs b/crates/stencilcraft-document/src/lib.rs index a966536c5..bca33fb8d 100644 --- a/crates/stencilcraft-document/src/lib.rs +++ b/crates/stencilcraft-document/src/lib.rs @@ -772,9 +772,12 @@ mod tests { #[test] fn version_1_files_without_canvas_fields_still_load() { - for name in ["starter", "poster", "stencil-frame"] { - let path = format!("{}/../../examples/{name}.stencilcraft", env!("CARGO_MANIFEST_DIR")); - let doc = load_from(&path).unwrap(); + for json in [ + include_str!("../tests/fixtures/starter.stencilcraft"), + include_str!("../tests/fixtures/poster.stencilcraft"), + include_str!("../tests/fixtures/stencil-frame.stencilcraft"), + ] { + let doc = Document::load_json(json).unwrap(); assert!(doc.pages.is_empty() && doc.groups.is_empty() && doc.guides.is_empty()); assert_eq!(doc.grid, Grid::default()); assert!(doc.layers.iter().all(|l| !l.template && !l.locked)); diff --git a/crates/stencilcraft-document/tests/fixtures/poster.stencilcraft b/crates/stencilcraft-document/tests/fixtures/poster.stencilcraft new file mode 100644 index 000000000..4de690925 --- /dev/null +++ b/crates/stencilcraft-document/tests/fixtures/poster.stencilcraft @@ -0,0 +1,98 @@ +{ + "board": { + "height_mm": 400.0, + "width_mm": 500.0 + }, + "kerf": { + "apply_to_exports": false, + "width_mm": 0.0 + }, + "layers": [ + { + "kind": "cut", + "name": "cut", + "shapes": [ + { + "id": 1, + "path": [ + { + "MoveTo": { + "x": 10.0, + "y": 20.0 + } + }, + { + "LineTo": { + "x": 70.0, + "y": 20.0 + } + }, + { + "LineTo": { + "x": 70.0, + "y": 80.0 + } + }, + { + "LineTo": { + "x": 10.0, + "y": 80.0 + } + }, + "ClosePath" + ], + "style": "cut" + }, + { + "id": 2, + "path": [ + { + "MoveTo": { + "x": 10.0, + "y": 390.0 + } + }, + { + "LineTo": { + "x": 490.0, + "y": 10.0 + } + } + ], + "style": "cut" + } + ], + "visible": true + }, + { + "kind": "engrave", + "name": "engrave", + "shapes": [ + { + "id": 3, + "path": [ + { + "MoveTo": { + "x": 100.0, + "y": 200.0 + } + }, + { + "LineTo": { + "x": 400.0, + "y": 200.0 + } + } + ], + "style": "engrave" + } + ], + "visible": true + } + ], + "next-shape-id": 4, + "stencilcraft": { + "name": "stencilcraft", + "version": 1 + } +} diff --git a/crates/stencilcraft-document/tests/fixtures/starter.stencilcraft b/crates/stencilcraft-document/tests/fixtures/starter.stencilcraft new file mode 100644 index 000000000..2a18fbb11 --- /dev/null +++ b/crates/stencilcraft-document/tests/fixtures/starter.stencilcraft @@ -0,0 +1,111 @@ +{ + "board": { + "height_mm": 150.0, + "width_mm": 100.0 + }, + "kerf": { + "apply_to_exports": false, + "width_mm": 0.0 + }, + "layers": [ + { + "kind": "cut", + "name": "cut", + "shapes": [ + { + "id": 1, + "path": [ + { + "MoveTo": { + "x": 10.0, + "y": 10.0 + } + }, + { + "LineTo": { + "x": 60.0, + "y": 10.0 + } + }, + { + "LineTo": { + "x": 60.0, + "y": 60.0 + } + }, + { + "LineTo": { + "x": 10.0, + "y": 60.0 + } + }, + "ClosePath" + ], + "style": "cut" + }, + { + "id": 2, + "path": [ + { + "MoveTo": { + "x": 70.0, + "y": 20.0 + } + }, + { + "LineTo": { + "x": 85.0, + "y": 20.0 + } + }, + { + "LineTo": { + "x": 85.0, + "y": 60.0 + } + }, + { + "LineTo": { + "x": 70.0, + "y": 60.0 + } + }, + "ClosePath" + ], + "style": "cut" + } + ], + "visible": true + }, + { + "kind": "engrave", + "name": "engrave", + "shapes": [ + { + "id": 3, + "path": [ + { + "MoveTo": { + "x": 10.0, + "y": 90.0 + } + }, + { + "LineTo": { + "x": 90.0, + "y": 90.0 + } + } + ], + "style": "engrave" + } + ], + "visible": true + } + ], + "next-shape-id": 4, + "stencilcraft": { + "name": "stencilcraft", + "version": 1 + } +} \ No newline at end of file diff --git a/crates/stencilcraft-document/tests/fixtures/stencil-frame.stencilcraft b/crates/stencilcraft-document/tests/fixtures/stencil-frame.stencilcraft new file mode 100644 index 000000000..3e0a77ed8 --- /dev/null +++ b/crates/stencilcraft-document/tests/fixtures/stencil-frame.stencilcraft @@ -0,0 +1,86 @@ +{ + "board": { + "height_mm": 150.0, + "width_mm": 120.0 + }, + "kerf": { + "apply_to_exports": true, + "width_mm": 0.2 + }, + "layers": [ + { + "kind": "cut", + "name": "cut", + "shapes": [ + { + "id": 1, + "path": [ + { + "MoveTo": { + "x": 0.0, + "y": 0.0 + } + }, + { + "LineTo": { + "x": 100.0, + "y": 0.0 + } + }, + { + "LineTo": { + "x": 100.0, + "y": 100.0 + } + }, + { + "LineTo": { + "x": 0.0, + "y": 100.0 + } + }, + "ClosePath" + ], + "style": "cut" + }, + { + "id": 2, + "path": [ + { + "MoveTo": { + "x": 30.0, + "y": 30.0 + } + }, + { + "LineTo": { + "x": 70.0, + "y": 30.0 + } + }, + { + "LineTo": { + "x": 70.0, + "y": 70.0 + } + }, + { + "LineTo": { + "x": 30.0, + "y": 70.0 + } + }, + "ClosePath" + ], + "style": "cut" + } + ], + "visible": true + } + ], + "next-shape-id": 3, + "stencilcraft": { + "name": "stencilcraft", + "version": 1 + } +}