DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
M6: guard IDML variant coverage and strengthen export tests
skylar taylor-barrick21a54becce68
diff --git a/ROADMAP.md b/ROADMAP.mdindex 625e83073..d46697f99 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -14,7 +14,7 @@ DesignCraft aims at full Adobe InDesign parity — and to be better: faster, ope- **2026-10-24** · Embedded IDML keeps independent placed-PDF layer choices in table-cell andfootnote text. The variant rewrite reaches endnote stories too, but IDML endnote structures and- artwork remain unsupported. External-only export rejects active nested choices; no readiness percentage change.+ artwork remain unsupported. External-only export continues to reject active nested choices; no readiness percentage change.- **2026-10-24** · PDF/A-2b preparation applies placed-PDF layer choices, including explicit all-on,to anchors inside table-cell text, footnotes and endnotes in an export-only copy. The nestedIDML variant write pass remains separate work; no readiness percentage change.diff --git a/crates/engine/src/cmd/interchange.rs b/crates/engine/src/cmd/interchange.rsindex 2d955d9f3..e7fcb0a0f 100644--- a/crates/engine/src/cmd/interchange.rs+++ b/crates/engine/src/cmd/interchange.rs@@ -87,7 +87,7 @@ fn with_pdf_layer_variants(doc: &Document, embed: bool) -> Result<Option<Documen}// Anchored objects live in stories, and parent pages outside the document-spread walk, so// the choice is cleared where the placement actually is.- out.update_placed_items(+ let applied = out.update_placed_items(|it| variants.contains_key(&it.id),|it| {if let designcraft_doc::Content::Graphic(g) = &mut it.content@@ -99,6 +99,12 @@ fn with_pdf_layer_variants(doc: &Document, embed: bool) -> Result<Option<Documenit.pdf_hidden_layers.clear();},);+ if applied != variants.len() {+ return Err(EngineError::Other(format!(+ "PDF layer choices could not be applied to every placement (updated {applied}, expected {})",+ variants.len()+ )));+ }Ok(Some(out))}@@ -750,9 +756,10 @@ mod nested_layer_tests {);let mut single = Session::new();single.add_document(DocState::new(one, None));+ let before = single.doc().unwrap().doc.clone();let err = single.execute("file.exportIdml", &json!({"embedImages": false})).unwrap_err().to_string();assert!(err.contains("embedded images"), "{location}: {err}");- assert!(Arc::ptr_eq(&original, &session.doc().unwrap().doc));+ assert!(Arc::ptr_eq(&before, &single.doc().unwrap().doc));}Arc::make_mut(&mut session.doc_mut().unwrap().doc).update_placed_items(|i| ids.contains(&i.id),@@ -764,6 +771,17 @@ mod nested_layer_tests {session.execute("file.exportIdml", &json!({"embedImages": false})).unwrap();}+ #[test]+ fn nested_idml_variant_mapping_mismatch_is_rejected() {+ let (mut session, _, ids) = fixture("cell");+ let source = Arc::make_mut(&mut session.doc_mut().unwrap().doc);+ source.update_placed_items(|i| i.id == ids[1], |i| i.id = ids[0]);+ // Both nested placements now use one id: the mapping has one entry, the write walk+ // updates two items. A malformed document must not silently assign one choice to both.+ let err = with_pdf_layer_variants(source, true).err().unwrap().to_string();+ assert!(err.contains("every placement") && err.contains("updated 2, expected 1"), "{err}");+ }+#[test]fn nested_idml_cell_variants_are_applied() {prepared("cell");