Guard corpus previews against warnings

The warning-free corpus sweep was only a manual check. Add a server test that
previews examples/hello.tex, boxes.tex, compat.tex and the arXiv template
through /api/route-d/preview and asserts each returns 200, at least one page
and an empty warnings array, so the corpus guard runs with the normal suite.
This commit is contained in:
gloamxun committed 2026-10-27 01:39:32 +08:00
1 parent 88a03ec1a1
commit 28aed153fe
3 files changed
+33 -4

No files matched your search

+28
View File
@@ -2344,3 +2344,31 @@ fn project_preview_defaults_to_route_d_without_env() {
assert!(svg.contains("font-style=\"italic\""), "{svg}");
assert!(!svg.contains('$'), "{svg}");
}
#[test]
fn corpus_documents_preview_without_warnings() {
let server = TestServer::start("corpus-warnings");
for relative in [
"examples/hello.tex",
"examples/boxes.tex",
"examples/compat.tex",
"fixtures/arxiv-template/template.tex",
] {
let path = Path::new(env!("CARGO_MANIFEST_DIR")).join(relative);
let source = fs::read_to_string(&path).expect("corpus source");
let response = server.request(
"POST",
"/api/route-d/preview",
source.as_bytes(),
"text/plain",
);
assert_eq!(response.status, 200, "{relative}: {}", response.text());
let value: Value = serde_json::from_slice(&response.body).expect("preview JSON");
let warnings = value["warnings"].as_array().cloned().unwrap_or_default();
assert!(warnings.is_empty(), "{relative}: {warnings:?}");
assert!(
value["pageCount"].as_u64().unwrap_or(0) >= 1,
"{relative}: no pages"
);
}
}