fix(tests): fix ocr endpoint tests due to our endpoint change
This commit is contained in:
parent
971f9b69e0
commit
52b2cd6d88
|
|
@ -84,11 +84,12 @@ interface FailedOcrResponse {
|
|||
total: number;
|
||||
limit: number;
|
||||
offset: number;
|
||||
has_more: boolean;
|
||||
total_pages: number;
|
||||
};
|
||||
statistics: {
|
||||
total_failed: number;
|
||||
failure_categories: FailureCategory[];
|
||||
by_reason: Record<string, number>;
|
||||
by_stage: Record<string, number>;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -615,15 +616,15 @@ const FailedOcrPage: React.FC = () => {
|
|||
Failure Categories
|
||||
</Typography>
|
||||
<Box display="flex" flexWrap="wrap" gap={1}>
|
||||
{statistics?.failure_categories?.map((category) => (
|
||||
{statistics?.by_reason ? Object.entries(statistics.by_reason).map(([reason, count]) => (
|
||||
<Chip
|
||||
key={category.reason}
|
||||
label={`${category.display_name}: ${category.count}`}
|
||||
color={getFailureCategoryColor(category.display_name)}
|
||||
key={reason}
|
||||
label={`${reason}: ${count}`}
|
||||
color={getFailureCategoryColor(reason)}
|
||||
variant="outlined"
|
||||
size="small"
|
||||
/>
|
||||
)) || (
|
||||
)) : (
|
||||
<Typography variant="body2" color="text.secondary">
|
||||
No failure data available
|
||||
</Typography>
|
||||
|
|
|
|||
|
|
@ -250,12 +250,12 @@ async fn test_failed_ocr_endpoint_structure() {
|
|||
assert!(pagination.get("total").is_some());
|
||||
assert!(pagination.get("limit").is_some());
|
||||
assert!(pagination.get("offset").is_some());
|
||||
assert!(pagination.get("has_more").is_some());
|
||||
assert!(pagination.get("total_pages").is_some());
|
||||
|
||||
// Verify statistics structure
|
||||
let statistics = &failed_docs["statistics"];
|
||||
assert!(statistics.get("total_failed").is_some());
|
||||
assert!(statistics.get("failure_categories").is_some());
|
||||
assert!(statistics.get("by_reason").is_some());
|
||||
|
||||
println!("✅ Failed OCR endpoint returns proper structure");
|
||||
}
|
||||
|
|
@ -302,15 +302,20 @@ async fn test_failed_ocr_statistics_format() {
|
|||
|
||||
// Verify statistics format
|
||||
assert!(statistics["total_failed"].is_number());
|
||||
assert!(statistics["failure_categories"].is_array());
|
||||
assert!(statistics["by_reason"].is_object());
|
||||
|
||||
// Verify failure categories structure
|
||||
let categories = statistics["failure_categories"].as_array().unwrap();
|
||||
for category in categories {
|
||||
assert!(category.get("reason").is_some());
|
||||
assert!(category.get("display_name").is_some());
|
||||
assert!(category.get("count").is_some());
|
||||
assert!(category["count"].is_number());
|
||||
// Verify failure reasons structure
|
||||
let by_reason = statistics["by_reason"].as_object().unwrap();
|
||||
for (reason, count) in by_reason {
|
||||
assert!(!reason.is_empty());
|
||||
assert!(count.is_number());
|
||||
}
|
||||
|
||||
// Verify failure stages structure
|
||||
let by_stage = statistics["by_stage"].as_object().unwrap();
|
||||
for (stage, count) in by_stage {
|
||||
assert!(!stage.is_empty());
|
||||
assert!(count.is_number());
|
||||
}
|
||||
|
||||
println!("✅ Failed OCR statistics have correct format");
|
||||
|
|
@ -451,7 +456,7 @@ async fn test_failed_ocr_empty_response_structure() {
|
|||
// Structure should be consistent regardless of document count
|
||||
assert!(failed_docs["documents"].is_array());
|
||||
assert!(failed_docs["statistics"]["total_failed"].is_number());
|
||||
assert!(failed_docs["statistics"]["failure_categories"].is_array());
|
||||
assert!(failed_docs["statistics"]["by_reason"].is_object());
|
||||
|
||||
// The key test is structure consistency
|
||||
let documents = failed_docs["documents"].as_array().unwrap();
|
||||
|
|
@ -463,7 +468,7 @@ async fn test_failed_ocr_empty_response_structure() {
|
|||
|
||||
// Also test pagination values for empty result
|
||||
assert_eq!(failed_docs["pagination"]["total"], 0);
|
||||
assert_eq!(failed_docs["pagination"]["has_more"], false);
|
||||
assert_eq!(failed_docs["pagination"]["total_pages"], 0);
|
||||
|
||||
println!("✅ Failed OCR endpoint returns consistent empty structure for new user");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue