Some checks failed
CI/CD Pipeline / Backend - Lint & Test (push) Has been cancelled
CI/CD Pipeline / Frontend - Lint & Test (push) Has been cancelled
CI/CD Pipeline / Security Scan (push) Has been cancelled
CI/CD Pipeline / Build Backend (push) Has been cancelled
CI/CD Pipeline / Build Frontend (push) Has been cancelled
CI/CD Pipeline / Integration Tests (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / Performance Tests (push) Has been cancelled
CI/CD Pipeline / Dependency Updates (push) Has been cancelled
- Updated Anthropic API to latest version (2024-01-01) - Set Claude 3.7 Sonnet Latest as primary model - Removed deprecated Opus 3.5 references - Fixed LLM response validation and JSON parsing - Improved error handling and logging - Updated model configurations and pricing - Enhanced document processing reliability - Fixed TypeScript type issues - Updated environment configuration
57 lines
2.0 KiB
TypeScript
57 lines
2.0 KiB
TypeScript
import { describe, test, expect, beforeAll, afterAll } from '@jest/globals';
|
|
import { DocumentModel } from '../../models/DocumentModel';
|
|
import { unifiedDocumentProcessor } from '../../services/unifiedDocumentProcessor';
|
|
|
|
describe('Document Completion Status', () => {
|
|
const testUserId = 'e2e-test-user-002';
|
|
let testDocumentId: string;
|
|
|
|
beforeAll(async () => {
|
|
await DocumentModel.ensureTestUser(testUserId);
|
|
});
|
|
|
|
afterAll(async () => {
|
|
if (testDocumentId) {
|
|
await DocumentModel.deleteDocument(testDocumentId);
|
|
}
|
|
});
|
|
|
|
test('should have analysis_data when status is "completed"', async () => {
|
|
// 1. Create a document record
|
|
const documentData = {
|
|
userId: testUserId,
|
|
originalFileName: 'completion-test.pdf',
|
|
fileSize: 12345,
|
|
mimeType: 'application/pdf',
|
|
gcsPath: 'test-documents/completion-test.pdf',
|
|
status: 'uploaded'
|
|
};
|
|
const createResult = await DocumentModel.createDocument(documentData);
|
|
testDocumentId = createResult.document.id;
|
|
|
|
// 2. Simulate processing
|
|
await DocumentModel.updateDocumentStatus(testDocumentId, 'processing');
|
|
const processingResult = await unifiedDocumentProcessor.processDocument({
|
|
id: testDocumentId,
|
|
content: 'This is a test document.',
|
|
metadata: { filename: 'completion-test.pdf' }
|
|
}, {
|
|
processingStrategy: 'quick_summary'
|
|
});
|
|
|
|
// 3. Update document with analysis results
|
|
await DocumentModel.updateDocumentAnalysis(
|
|
testDocumentId,
|
|
processingResult.analysisData
|
|
);
|
|
await DocumentModel.updateDocumentStatus(testDocumentId, 'completed');
|
|
|
|
// 4. Fetch the document and verify
|
|
const finalDocument = await DocumentModel.getDocument(testDocumentId);
|
|
expect(finalDocument.status).toBe('completed');
|
|
expect(finalDocument.analysisData).toBeDefined();
|
|
expect(finalDocument.analysisData).not.toBeNull();
|
|
expect(Object.keys(finalDocument.analysisData).length).toBeGreaterThan(0);
|
|
}, 30000);
|
|
});
|