Fixes reported from APK field testing: DO/Product scan mode was inconsistent between the camera drawer and documents screen (now one shared provider, with an orange/green color cue); unconfirmed scans leaked into history with placeholder data before the user tapped confirm (backend now gates GET /documents on a new `confirmed` column, flipped only by PUT); and Product Scan ran the GPU classifier twice, once at upload and again on review (now a single pass at upload, persisted and read directly by the editor). Also removes the unused "Hubungkan ke PO" field and fabricated PO/SO/DO placeholder values from the Product Scan flow, closes out the per-document-polling and save-recovery tasks (6.1/6.3), and splits several touched files to stay under the repo's 256-line guideline. Full detail in docs/iteration-log.md and backend/docs/iteration-log.md. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
54 lines
1.6 KiB
Dart
54 lines
1.6 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:app_pfm_ocr_v2/features/editor/document_save_action.dart';
|
|
import 'package:app_pfm_ocr_v2/models/document_model.dart';
|
|
|
|
DocumentModel _doc(String id) {
|
|
return DocumentModel(
|
|
id: id,
|
|
tanggal: '',
|
|
noPo: '',
|
|
noSo: '',
|
|
noDo: '',
|
|
kepadaYth: '',
|
|
orderUntuk: '',
|
|
alamat: '',
|
|
platTruk: '',
|
|
namaDriver: '',
|
|
namaPenerima: '',
|
|
items: const [],
|
|
createdAt: DateTime(2026, 7, 10),
|
|
);
|
|
}
|
|
|
|
void main() {
|
|
group('resolveDocumentSaveAction', () {
|
|
test('a resolved server document -> putExisting with its real id', () {
|
|
final action = resolveDocumentSaveAction(
|
|
existingDocument: _doc('3390'),
|
|
localImagePath: '/tmp/photo.jpg',
|
|
);
|
|
expect(action.kind, DocumentSaveActionKind.putExisting);
|
|
expect(action.serverId, '3390');
|
|
});
|
|
|
|
test('no resolved document but a local image is available -> reuploadThenPut, never a fabricated id', () {
|
|
final action = resolveDocumentSaveAction(
|
|
existingDocument: null,
|
|
localImagePath: '/tmp/photo.jpg',
|
|
);
|
|
expect(action.kind, DocumentSaveActionKind.reuploadThenPut);
|
|
expect(action.serverId, isNull);
|
|
});
|
|
|
|
test('no resolved document and no local image -> blocked with an explicit message', () {
|
|
final action = resolveDocumentSaveAction(
|
|
existingDocument: null,
|
|
localImagePath: '',
|
|
);
|
|
expect(action.kind, DocumentSaveActionKind.blocked);
|
|
expect(action.blockedMessage, isNotNull);
|
|
expect(action.blockedMessage, isNotEmpty);
|
|
});
|
|
});
|
|
}
|