fix(tests): resolve broken frontend tests due to retry functionality
This commit is contained in:
parent
4279823268
commit
9004633d68
|
|
@ -92,7 +92,7 @@ export const RetryRecommendations: React.FC<RetryRecommendationsProps> = ({
|
||||||
return `${percentage}% (Low)`;
|
return `${percentage}% (Low)`;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (loading && recommendations.length === 0) {
|
if (loading && (!recommendations || recommendations.length === 0)) {
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
|
|
@ -138,7 +138,7 @@ export const RetryRecommendations: React.FC<RetryRecommendationsProps> = ({
|
||||||
</Alert>
|
</Alert>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{recommendations.length === 0 && !loading ? (
|
{(!recommendations || recommendations.length === 0) && !loading ? (
|
||||||
<Alert severity="info">
|
<Alert severity="info">
|
||||||
<Typography variant="body2">
|
<Typography variant="body2">
|
||||||
No retry recommendations available. This usually means:
|
No retry recommendations available. This usually means:
|
||||||
|
|
@ -151,7 +151,7 @@ export const RetryRecommendations: React.FC<RetryRecommendationsProps> = ({
|
||||||
</Alert>
|
</Alert>
|
||||||
) : (
|
) : (
|
||||||
<Stack spacing={2}>
|
<Stack spacing={2}>
|
||||||
{recommendations.map((recommendation, index) => (
|
{(recommendations || []).map((recommendation, index) => (
|
||||||
<Card key={recommendation.reason} variant="outlined">
|
<Card key={recommendation.reason} variant="outlined">
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<Box display="flex" justifyContent="space-between" alignItems="flex-start" mb={1}>
|
<Box display="flex" justifyContent="space-between" alignItems="flex-start" mb={1}>
|
||||||
|
|
@ -236,7 +236,7 @@ export const RetryRecommendations: React.FC<RetryRecommendationsProps> = ({
|
||||||
</Stack>
|
</Stack>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{loading && recommendations.length > 0 && (
|
{loading && recommendations && recommendations.length > 0 && (
|
||||||
<LinearProgress sx={{ mt: 2 }} />
|
<LinearProgress sx={{ mt: 2 }} />
|
||||||
)}
|
)}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,9 @@ const mockDocumentService = {
|
||||||
deleteLowConfidence: vi.fn(),
|
deleteLowConfidence: vi.fn(),
|
||||||
deleteFailedOcr: vi.fn(),
|
deleteFailedOcr: vi.fn(),
|
||||||
downloadFile: vi.fn(),
|
downloadFile: vi.fn(),
|
||||||
|
getRetryRecommendations: vi.fn(),
|
||||||
|
getRetryStats: vi.fn(),
|
||||||
|
getDocumentRetryHistory: vi.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockQueueService = {
|
const mockQueueService = {
|
||||||
|
|
@ -23,6 +26,7 @@ const mockQueueService = {
|
||||||
const mockApi = {
|
const mockApi = {
|
||||||
get: vi.fn(),
|
get: vi.fn(),
|
||||||
delete: vi.fn(),
|
delete: vi.fn(),
|
||||||
|
bulkRetryOcr: vi.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Mock API with comprehensive responses
|
// Mock API with comprehensive responses
|
||||||
|
|
@ -51,6 +55,20 @@ describe('DocumentManagementPage - Runtime Error Prevention', () => {
|
||||||
mockDocumentService.getFailedOcrDocuments.mockClear();
|
mockDocumentService.getFailedOcrDocuments.mockClear();
|
||||||
mockDocumentService.getDuplicates.mockClear();
|
mockDocumentService.getDuplicates.mockClear();
|
||||||
mockQueueService.requeueFailed.mockClear();
|
mockQueueService.requeueFailed.mockClear();
|
||||||
|
|
||||||
|
// Setup default mock returns for retry functionality
|
||||||
|
mockDocumentService.getRetryRecommendations.mockResolvedValue({
|
||||||
|
data: { recommendations: [], total_recommendations: 0 }
|
||||||
|
});
|
||||||
|
mockDocumentService.getRetryStats.mockResolvedValue({
|
||||||
|
data: { failure_reasons: [], file_types: [], total_failed: 0 }
|
||||||
|
});
|
||||||
|
mockDocumentService.getDocumentRetryHistory.mockResolvedValue({
|
||||||
|
data: { document_id: 'test', retry_history: [], total_retries: 0 }
|
||||||
|
});
|
||||||
|
mockApi.bulkRetryOcr.mockResolvedValue({
|
||||||
|
data: { success: true, queued_count: 0, matched_count: 0, documents: [] }
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('OCR Confidence Display - Null Safety', () => {
|
describe('OCR Confidence Display - Null Safety', () => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue