Cache route-D project PDF exports

This commit is contained in:
gloamxun committed 2026-10-24 23:10:09 +08:00
1 parent 6d5a3eb686
commit 4b0e4eba0c
5 files changed
+102 -5

No files matched your search

+48
View File
@@ -283,6 +283,54 @@ fn project_preview_expands_included_files() {
assert!(svg.contains(">B</text>"), "{svg}");
}
#[test]
fn project_pdf_caches_route_d_exports() {
let server = TestServer::start("route-d-pdf-cache");
let main = "\\documentclass{article}\n\\begin{document}\nCached body.\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 first = server.request(
"POST",
"/api/projects/hello/pdf?engine=route-d",
&[],
"application/pdf",
);
assert_eq!(first.status, 200);
assert_eq!(first.header("x-texrra-cache"), Some("miss"));
let second = server.request(
"POST",
"/api/projects/hello/pdf?engine=route-d",
&[],
"application/pdf",
);
assert_eq!(second.status, 200);
assert_eq!(second.header("x-texrra-cache"), Some("hit"));
assert_eq!(first.body, second.body);
let edited = "\\documentclass{article}\n\\begin{document}\nEdited body.\n\\end{document}\n";
let put = server.request(
"PUT",
"/api/projects/hello/file?path=hello.tex",
edited.as_bytes(),
"text/plain; charset=utf-8",
);
assert_eq!(put.status, 200, "{}", put.text());
let third = server.request(
"POST",
"/api/projects/hello/pdf?engine=route-d",
&[],
"application/pdf",
);
assert_eq!(third.status, 200);
assert_eq!(third.header("x-texrra-cache"), Some("miss"));
assert_ne!(first.body, third.body);
}
#[test]
fn project_pdf_annotates_href_links() {
let server = TestServer::start("route-d-link-pdf");