fix(dashboard,server): restore code change ledger UI and enrich model schema parity and pagination
This commit is contained in:
1 parent
3b146f91c2
commit
73c3d41c87
9 files changed
+297
-19
No files matched your search
@@ -78,3 +78,80 @@ fn test_eager_tools_parity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_dashboard_route_parity() {
|
||||
let dashboard_path = if std::path::Path::new("src/dashboard.ts").exists() {
|
||||
"src/dashboard.ts"
|
||||
} else {
|
||||
"server/src/dashboard.ts"
|
||||
};
|
||||
|
||||
let setup_path = if std::path::Path::new("src/api/setup.rs").exists() {
|
||||
"src/api/setup.rs"
|
||||
} else {
|
||||
"server/src/api/setup.rs"
|
||||
};
|
||||
|
||||
let dashboard_content = std::fs::read_to_string(dashboard_path)
|
||||
.expect("Failed to read dashboard.ts");
|
||||
let setup_content = std::fs::read_to_string(setup_path)
|
||||
.expect("Failed to read setup.rs");
|
||||
|
||||
// 1. Extract routes from setup.rs
|
||||
let mut registered_routes = HashSet::new();
|
||||
for part in setup_content.split(".route(") {
|
||||
let trimmed = part.trim_start();
|
||||
if trimmed.starts_with('"') {
|
||||
if let Some(end_quote) = trimmed[1..].find('"') {
|
||||
let route = &trimmed[1..=end_quote];
|
||||
registered_routes.insert(route.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assert!(!registered_routes.is_empty(), "No routes found in setup.rs");
|
||||
|
||||
// 2. Extract /api/ endpoints called in dashboard.ts
|
||||
let mut frontend_endpoints = HashSet::new();
|
||||
let mut cursor = 0;
|
||||
while let Some(idx) = dashboard_content[cursor..].find("/api/") {
|
||||
let start = cursor + idx;
|
||||
let rest = &dashboard_content[start..];
|
||||
let quote_char = dashboard_content[..start].chars().last();
|
||||
let mut endpoint = String::new();
|
||||
if let Some(q) = quote_char {
|
||||
if q == '`' || q == '"' || q == '\'' {
|
||||
if let Some(close_idx) = rest.find(q) {
|
||||
let full_call = &rest[..close_idx];
|
||||
let clean = if let Some(q_idx) = full_call.find('?') {
|
||||
&full_call[..q_idx]
|
||||
} else {
|
||||
full_call
|
||||
};
|
||||
let normalized = clean.replace("${id}", "{id}");
|
||||
endpoint = normalized.to_string();
|
||||
}
|
||||
}
|
||||
}
|
||||
if endpoint.is_empty() {
|
||||
let end_idx = rest.find(['"', '`', '\'', ' ', '\n', '?'])
|
||||
.unwrap_or(rest.len());
|
||||
endpoint = rest[..end_idx].to_string();
|
||||
}
|
||||
|
||||
if endpoint.starts_with("/api/") {
|
||||
frontend_endpoints.insert(endpoint);
|
||||
}
|
||||
cursor = start + 5;
|
||||
}
|
||||
|
||||
assert!(!frontend_endpoints.is_empty(), "No frontend endpoints found in dashboard.ts");
|
||||
|
||||
for endpoint in &frontend_endpoints {
|
||||
assert!(
|
||||
registered_routes.contains(endpoint),
|
||||
"Frontend endpoint '{endpoint}' is not registered in setup.rs! Parity violation detected."
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user