Add route-D web contract and experiment matrix
Route-D preview JSON now reports durationMs on the flat, project and edit paths, and project preview/PDF responses carry X-Preview-Engine (route-d or v1), including cache hits and silent fallback. The server tests assert the headers, the duration field and both PDF engines. docs/WEB_ROUTE_D_EXPERIMENT.md records the audit verdict, the initial contract probe, the supported/gap matrix, the three-project trial plan and the prioritised backlog; ROUTE_D_STATUS.md links to it and the test counts move to 1063.
This commit is contained in:
1 parent
c49afbdecb
commit
1058122388
7 files changed
+190
-20
No files matched your search
@@ -322,7 +322,13 @@ fn project_preview_expands_included_files() {
|
||||
"application/json",
|
||||
);
|
||||
assert_eq!(preview.status, 200, "{}", preview.text());
|
||||
assert_eq!(preview.header("x-preview-engine"), Some("route-d"));
|
||||
let value: Value = serde_json::from_slice(&preview.body).expect("preview JSON");
|
||||
assert!(
|
||||
value["durationMs"].as_f64().unwrap_or(0.0) > 0.0,
|
||||
"{}",
|
||||
value["durationMs"]
|
||||
);
|
||||
let svg = value["pages"][0]["svg"].as_str().unwrap();
|
||||
assert!(svg.contains(">Z</text>"), "{svg}");
|
||||
assert!(svg.contains(">X</text>"), "{svg}");
|
||||
@@ -349,6 +355,7 @@ fn project_pdf_caches_route_d_exports() {
|
||||
);
|
||||
assert_eq!(first.status, 200);
|
||||
assert_eq!(first.header("x-texrra-cache"), Some("miss"));
|
||||
assert_eq!(first.header("x-preview-engine"), Some("route-d"));
|
||||
let second = server.request(
|
||||
"POST",
|
||||
"/api/projects/hello/pdf?engine=route-d",
|
||||
@@ -378,6 +385,37 @@ fn project_pdf_caches_route_d_exports() {
|
||||
assert_ne!(first.body, third.body);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_pdfs_report_the_engine() {
|
||||
let server = TestServer::start("engine-pdf-header");
|
||||
let main = "\\documentclass{article}\n\\begin{document}\nEngine header.\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 route_d = server.request(
|
||||
"POST",
|
||||
"/api/projects/hello/pdf?engine=route-d",
|
||||
&[],
|
||||
"application/pdf",
|
||||
);
|
||||
assert_eq!(route_d.status, 200, "{}", route_d.text());
|
||||
assert_eq!(route_d.header("x-preview-engine"), Some("route-d"));
|
||||
|
||||
let v1 = server.request(
|
||||
"POST",
|
||||
"/api/projects/hello/pdf?engine=v1",
|
||||
&[],
|
||||
"application/pdf",
|
||||
);
|
||||
assert_eq!(v1.status, 200, "{}", v1.text());
|
||||
assert_eq!(v1.header("x-preview-engine"), Some("v1"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_pdf_annotates_href_links() {
|
||||
let server = TestServer::start("route-d-link-pdf");
|
||||
@@ -422,7 +460,13 @@ fn project_preview_uses_the_engine_default() {
|
||||
"application/json",
|
||||
);
|
||||
assert_eq!(preview.status, 200, "{}", preview.text());
|
||||
assert_eq!(preview.header("x-preview-engine"), Some("route-d"));
|
||||
let value: Value = serde_json::from_slice(&preview.body).expect("preview JSON");
|
||||
assert!(
|
||||
value["durationMs"].as_f64().unwrap_or(0.0) > 0.0,
|
||||
"{}",
|
||||
value["durationMs"]
|
||||
);
|
||||
let svg = value["pages"][0]["svg"].as_str().unwrap();
|
||||
assert!(svg.contains("font-style=\"italic\""), "{svg}");
|
||||
assert!(!svg.contains('$'), "{svg}");
|
||||
@@ -434,6 +478,7 @@ fn project_preview_uses_the_engine_default() {
|
||||
"application/json",
|
||||
);
|
||||
assert_eq!(forced.status, 200, "{}", forced.text());
|
||||
assert_eq!(forced.header("x-preview-engine"), Some("v1"));
|
||||
let value: Value = serde_json::from_slice(&forced.body).expect("preview JSON");
|
||||
let svg = value["pages"][0]["svg"].as_str().unwrap();
|
||||
assert!(svg.contains("TexrraSerif"), "{svg}");
|
||||
|
||||
Reference in new issue
Block a user