Cover the engine parameter matrix over the environment default

This commit is contained in:
gloamxun committed 2026-10-25 01:44:26 +08:00
1 parent df977704c5
commit a11a9ec641
4 files changed
+92 -4

No files matched your search

+88
View File
@@ -422,6 +422,94 @@ fn project_preview_uses_the_engine_default() {
assert!(svg.contains("TexrraSerif"), "{svg}");
}
#[test]
fn engine_parameter_overrides_the_environment_default() {
let main = "\\documentclass{article}\n\\begin{document}\nInline $x$ math.\n\\end{document}\n";
let route_d = TestServer::start_with_env("engine-route-d", &[("TEXRRA_ENGINE", "route-d")]);
let put = route_d.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 default_preview = route_d.request(
"POST",
"/api/projects/hello/preview",
&[],
"application/json",
);
let value: Value = serde_json::from_slice(&default_preview.body).expect("preview JSON");
let svg = value["pages"][0]["svg"].as_str().unwrap();
assert!(svg.contains("font-style=\"italic\""), "{svg}");
let v1_preview = route_d.request(
"POST",
"/api/projects/hello/preview?engine=v1",
&[],
"application/json",
);
let value: Value = serde_json::from_slice(&v1_preview.body).expect("preview JSON");
let svg = value["pages"][0]["svg"].as_str().unwrap();
assert!(svg.contains("TexrraSerif"), "{svg}");
let default_pdf = route_d.request("POST", "/api/projects/hello/pdf", &[], "application/pdf");
assert_eq!(default_pdf.status, 200, "{}", default_pdf.text());
assert!(
default_pdf.text().contains("/BaseFont /CMMI10"),
"route-d PDF lacks CMMI10"
);
let v1_pdf = route_d.request(
"POST",
"/api/projects/hello/pdf?engine=v1",
&[],
"application/pdf",
);
assert_eq!(v1_pdf.status, 200, "{}", v1_pdf.text());
assert!(!v1_pdf.text().contains("/BaseFont /CMMI10"), "v1 used CM");
let v1 = TestServer::start_with_env("engine-v1", &[("TEXRRA_ENGINE", "v1")]);
let put = v1.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 v1_default = v1.request(
"POST",
"/api/projects/hello/preview",
&[],
"application/json",
);
let value: Value = serde_json::from_slice(&v1_default.body).expect("preview JSON");
let svg = value["pages"][0]["svg"].as_str().unwrap();
assert!(svg.contains("TexrraSerif"), "{svg}");
let forced = v1.request(
"POST",
"/api/projects/hello/preview?engine=route-d",
&[],
"application/json",
);
let value: Value = serde_json::from_slice(&forced.body).expect("preview JSON");
let svg = value["pages"][0]["svg"].as_str().unwrap();
assert!(svg.contains("font-style=\"italic\""), "{svg}");
let forced_pdf = v1.request(
"POST",
"/api/projects/hello/pdf?engine=route-d",
&[],
"application/pdf",
);
assert_eq!(forced_pdf.status, 200, "{}", forced_pdf.text());
assert!(
forced_pdf.text().contains("/BaseFont /CMMI10"),
"forced route-d PDF lacks CMMI10"
);
}
#[test]
fn project_preview_executes_local_package_options() {
let server = TestServer::start("route-d-package-options");