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); }); }); }