Return dirty-page preview patches
Project previews accept ?patch=1 and only include pages listed in changedPages. Cache hits return an empty patch list. The web client applies sparse patches by page index instead of rebuilding every page. Add a two-page server test that edits only the second page and checks that the patched payload contains exactly the changed page indices. Measure the arXiv heading edit: 2 of 3 pages still changed (315 KB vs 396 KB full, 2.66 s), so dirty-page transfer is in place but incremental layout latency is not. Test count is 1073 (67 server).
This commit is contained in:
1 parent
86e95881e7
commit
9231c3a7d6
8 files changed
+90
-17
No files matched your search
@@ -1292,6 +1292,46 @@ fn project_preview_compiles_the_editor_buffer_without_saving() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_preview_patch_returns_only_changed_pages() {
|
||||
let server = TestServer::start("route-d-patch");
|
||||
let first = "\\documentclass{article}\n\\begin{document}\n\nFirst page.\n\n\\newpage\n\nSecond page.\n\n\\end{document}\n";
|
||||
let preview = server.request(
|
||||
"POST",
|
||||
"/api/projects/hello/preview?engine=route-d&buffer=1&patch=1",
|
||||
first.as_bytes(),
|
||||
"text/plain; charset=utf-8",
|
||||
);
|
||||
assert_eq!(preview.status, 200, "{}", preview.text());
|
||||
let value: Value = serde_json::from_slice(&preview.body).expect("preview JSON");
|
||||
assert_eq!(value["status"], "ok", "{}", value["message"]);
|
||||
assert_eq!(value["pageCount"], 2);
|
||||
|
||||
let second = first.replace("Second page.", "Second page edited.");
|
||||
let preview = server.request(
|
||||
"POST",
|
||||
"/api/projects/hello/preview?engine=route-d&buffer=1&patch=1",
|
||||
second.as_bytes(),
|
||||
"text/plain; charset=utf-8",
|
||||
);
|
||||
assert_eq!(preview.status, 200, "{}", preview.text());
|
||||
let value: Value = serde_json::from_slice(&preview.body).expect("patched preview JSON");
|
||||
assert_eq!(value["status"], "ok", "{}", value["message"]);
|
||||
assert_eq!(value["pageCount"], 2);
|
||||
let changed: Vec<u64> = value["changedPages"]
|
||||
.as_array()
|
||||
.expect("changedPages")
|
||||
.iter()
|
||||
.filter_map(|index| index.as_u64())
|
||||
.collect();
|
||||
let pages = value["pages"].as_array().expect("pages");
|
||||
assert_eq!(pages.len(), changed.len(), "{}", value);
|
||||
for page in pages {
|
||||
let index = page["index"].as_u64().expect("page index");
|
||||
assert!(changed.contains(&index), "unexpected page {index}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_preview_can_switch_to_route_d() {
|
||||
let server = TestServer::start("route-d-toggle");
|
||||
|
||||
Reference in new issue
Block a user