Cache route-D project previews by expanded source
This commit is contained in:
1 parent
874a327dca
commit
0651e15111
5 files changed
+160
-5
No files matched your search
@@ -343,6 +343,53 @@ fn project_preview_expands_local_style_packages() {
|
||||
assert!(!text.contains("ProvidesPackage"), "{text}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn route_d_previews_are_cached_and_invalidated() {
|
||||
let server = TestServer::start("route-d-cache");
|
||||
let source = "\\documentclass{article}\n\\begin{document}\nCached QRX.\n\\end{document}";
|
||||
let put = server.request(
|
||||
"PUT",
|
||||
"/api/projects/hello/file?path=hello.tex",
|
||||
source.as_bytes(),
|
||||
"text/plain; charset=utf-8",
|
||||
);
|
||||
assert_eq!(put.status, 200, "{}", put.text());
|
||||
let first = server.request(
|
||||
"POST",
|
||||
"/api/projects/hello/preview?engine=route-d",
|
||||
&[],
|
||||
"application/json",
|
||||
);
|
||||
let second = server.request(
|
||||
"POST",
|
||||
"/api/projects/hello/preview?engine=route-d",
|
||||
&[],
|
||||
"application/json",
|
||||
);
|
||||
assert_eq!(first.status, 200, "{}", first.text());
|
||||
assert_eq!(second.status, 200, "{}", second.text());
|
||||
let second_json: Value = serde_json::from_slice(&second.body).expect("second JSON");
|
||||
assert_eq!(second_json["recomputedPages"], serde_json::json!(0));
|
||||
assert_eq!(second_json["changedPages"], serde_json::json!([]));
|
||||
let changed = "\\documentclass{article}\n\\begin{document}\nChanged ZZZ.\n\\end{document}";
|
||||
let put = server.request(
|
||||
"PUT",
|
||||
"/api/projects/hello/file?path=hello.tex",
|
||||
changed.as_bytes(),
|
||||
"text/plain; charset=utf-8",
|
||||
);
|
||||
assert_eq!(put.status, 200, "{}", put.text());
|
||||
let third = server.request(
|
||||
"POST",
|
||||
"/api/projects/hello/preview?engine=route-d",
|
||||
&[],
|
||||
"application/json",
|
||||
);
|
||||
assert_eq!(third.status, 200, "{}", third.text());
|
||||
assert_ne!(first.body, third.body, "editing must invalidate the cache");
|
||||
assert!(third.text().contains(">Z</text>"), "{}", third.text());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn route_d_renders_href_and_url() {
|
||||
let server = TestServer::start("route-d-links");
|
||||
|
||||
Reference in new issue
Block a user