feat: update backend OCR parser, web app, mobile app camera/preview UI, tests, and documentation with sample images
This commit is contained in:
1 parent
aa3233e411
commit
bdb3a49742
71 files changed
+3360
-764
No files matched your search
@@ -80,6 +80,35 @@ async function runTests() {
|
||||
console.log('Upload error response body:', errText);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// -------------------------------------------------------------
|
||||
// Test 2b: Duplicate Document Upload Creates New Document (Deduplication Disabled)
|
||||
// -------------------------------------------------------------
|
||||
console.log('\n--- Test 2b: Duplicate Document Upload Creates New Document ---');
|
||||
const dupForm = new FormData();
|
||||
const mockFileDup = new File(['fake-jpeg-content-data'], testFilename, { type: 'image/jpeg' });
|
||||
dupForm.append('image', mockFileDup);
|
||||
dupForm.append('latitude', '-6.9999');
|
||||
dupForm.append('longitude', '107.9999');
|
||||
|
||||
const dupUploadRes = await fetch(`${BASE_URL}/documents/upload`, {
|
||||
method: 'POST',
|
||||
headers: token ? { 'Authorization': `Bearer ${token}` } : {},
|
||||
body: dupForm
|
||||
});
|
||||
|
||||
assert(dupUploadRes.status === 201, `POST /documents/upload (duplicate) status should be 201 (got ${dupUploadRes.status})`);
|
||||
|
||||
if (dupUploadRes.ok) {
|
||||
const dupUploadData = await dupUploadRes.json();
|
||||
assert(dupUploadData.status === 'success', 'Duplicate upload status should be "success"');
|
||||
assert(dupUploadData.data?.id !== uploadedDocId, 'Duplicate upload should return a new document ID (deduplication disabled)');
|
||||
assert(dupUploadData.data?.latitude === -6.9999, 'New document should return its own latitude (-6.9999)');
|
||||
assert(dupUploadData.data?.longitude === 107.9999, 'New document should return its own longitude (107.9999)');
|
||||
} else {
|
||||
console.log('Skipping duplicate upload asserts due to failed request');
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// Test 3: GET /documents (List with polling wait)
|
||||
// -------------------------------------------------------------
|
||||
@@ -113,6 +142,14 @@ async function runTests() {
|
||||
|
||||
assert(found, `List should contain the newly uploaded document (id: ${uploadedDocId}) after background parsing`);
|
||||
|
||||
if (found && listData) {
|
||||
const matchedDoc = listData.data?.find(doc => doc.id.toString() === uploadedDocId.toString());
|
||||
if (matchedDoc) {
|
||||
assert(matchedDoc.latitude === -6.2134, `Database latitude should remain -6.2134 (got ${matchedDoc.latitude})`);
|
||||
assert(matchedDoc.longitude === 106.8451, `Database longitude should remain 106.8451 (got ${matchedDoc.longitude})`);
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// Test 4: PUT /documents/[id] (Confirm / Update)
|
||||
// -------------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user