Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Integration: book chapter-number test closes its chapters before Update Numbering (#341 x #615 open-chapter refusal)

aiongg774ecf4fa53f
diff --git a/crates/engine/src/cmd/book.rs b/crates/engine/src/cmd/book.rs
index 1997e6e8b..796d992af 100644
--- a/crates/engine/src/cmd/book.rs
+++ b/crates/engine/src/cmd/book.rs
@@ -378,12 +378,15 @@ mod tests {
}
s.execute("file.saveAs", &json!({"path": p(name)})).unwrap();
s.execute("book.add", &json!({"path": p(name)})).unwrap();
+ // Book updates write closed chapters only.
+ s.execute("file.close", &json!({})).unwrap();
}
let r = s.execute("book.paginate", &json!({})).unwrap();
// Same as previous takes the number, written in the document's own style.
assert_eq!(r["chapters"], json!(["I", "1", "2", "g", "8"]));
assert_eq!(super::load(&p("e.designcraft")).unwrap().settings.chapter_number, 8);
- // The open document (e) names its book.
+ // An open chapter (e) names its book.
+ s.execute("file.open", &json!({"path": p("e.designcraft")})).unwrap();
assert_eq!(s.execute("layout.chapterNumbering", &json!({})).unwrap()["book"], "Field Guide");
std::fs::remove_dir_all(&dir).ok();
}