Default project previews and PDFs to route-D

uses_route_d still treated v1 as the default unless TEXRRA_ENGINE=route-d was
set, so only the flat /preview endpoint had switched. Make route-D the default
there too: an explicit engine parameter still wins, TEXRRA_ENGINE=v1 forces the
old pipeline, and a route-D error now falls through to the v1 compiler instead
of answering 422 (both preview and PDF).

Because route-D follows pdfLaTeX's Letter default for geometry-less documents,
the two server tests that asserted the v1 A4 page now ask for ?engine=v1 or
expect 215.9mm. A new test starts a server without the environment variable and
checks a project preview uses route-D's italic math face with no literal $.
This commit is contained in:
gloamxun committed 2026-10-27 00:32:45 +08:00
1 parent a56d441513
commit 371f05baaa
4 files changed
+48 -23

No files matched your search

+26 -2
View File
@@ -1143,7 +1143,7 @@ fn serves_project_api_preview_and_pdf() {
let value: Value = serde_json::from_slice(&preview.body).expect("preview JSON");
assert_eq!(value["status"], "ok", "{}", value["message"]);
assert_eq!(value["pages"].as_array().map(Vec::len), Some(1));
assert!((value["pageWidthMm"].as_f64().unwrap() - 210.0).abs() < 0.1);
assert!((value["pageWidthMm"].as_f64().unwrap() - 215.9).abs() < 0.1);
let pdf = server.request("POST", "/api/projects/hello/pdf", &[], "application/pdf");
assert_eq!(pdf.status, 200, "{}", String::from_utf8_lossy(&pdf.body));
@@ -1232,7 +1232,7 @@ fn project_preview_can_switch_to_route_d() {
let v1 = server.request(
"POST",
"/api/projects/hello/preview",
"/api/projects/hello/preview?engine=v1",
&[],
"application/json",
);
@@ -2320,3 +2320,27 @@ fn preview_uses_route_d_by_default_and_v1_on_request() {
assert_eq!(v1.status, 200, "{}", v1.text());
assert_eq!(v1.header("X-Preview-Engine"), Some("v1"));
}
#[test]
fn project_preview_defaults_to_route_d_without_env() {
let server = TestServer::start("project-default-route-d");
let main = "\\documentclass{article}\n\\begin{document}\nInline $x$ math.\n\\end{document}\n";
let put = server.request(
"PUT",
"/api/projects/hello/file?path=hello.tex",
main.as_bytes(),
"text/plain; charset=utf-8",
);
assert_eq!(put.status, 200, "{}", put.text());
let preview = server.request(
"POST",
"/api/projects/hello/preview",
&[],
"application/json",
);
assert_eq!(preview.status, 200, "{}", preview.text());
let value: Value = serde_json::from_slice(&preview.body).expect("preview JSON");
let svg = value["pages"][0]["svg"].as_str().unwrap();
assert!(svg.contains("font-style=\"italic\""), "{svg}");
assert!(!svg.contains('$'), "{svg}");
}