feat(app): scan-mode sync, confirmation-gated documents, single-pass product classification
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>
This commit is contained in:
1 parent
2febe0c886
commit
ada6488592
67 files changed
+5705
-1142
No files matched your search
@@ -0,0 +1,52 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:app_pfm_ocr_v2/features/editor/product_editor_screen.dart';
|
||||
import 'package:app_pfm_ocr_v2/main.dart';
|
||||
import 'package:app_pfm_ocr_v2/core/storage/local_storage.dart';
|
||||
import 'package:app_pfm_ocr_v2/models/document_model.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class MockLocalStorage extends LocalStorage {
|
||||
@override
|
||||
Future<void> init() async {}
|
||||
@override
|
||||
List<DocumentModel> getAllDocuments() => [];
|
||||
@override
|
||||
Future<void> savePendingDocument(Map<String, dynamic> data) async {}
|
||||
@override
|
||||
Future<void> removePendingDocument(String id) async {}
|
||||
@override
|
||||
List<Map<String, dynamic>> getAllPendingDocuments() => [];
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('shows an explicit retry state instead of fabricated SKU matches when the backend is unreachable', (tester) async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
|
||||
final container = ProviderContainer(
|
||||
overrides: [localStorageProvider.overrideWithValue(MockLocalStorage())],
|
||||
);
|
||||
addTearDown(container.dispose);
|
||||
|
||||
await tester.pumpWidget(
|
||||
UncontrolledProviderScope(
|
||||
container: container,
|
||||
child: const MaterialApp(
|
||||
home: ProductEditorScreen(pendingId: null),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle(const Duration(seconds: 5));
|
||||
|
||||
// The old behavior fabricated these exact hardcoded matches on any
|
||||
// fetch failure - they must never appear again.
|
||||
expect(find.textContaining('FIESTA SPICY CHICKEN NUGGET'), findsNothing);
|
||||
expect(find.textContaining('AKUMO NUGGET COIN'), findsNothing);
|
||||
expect(find.textContaining('98.5'), findsNothing); // old fake 0.985 confidence
|
||||
|
||||
expect(find.text('Gagal Memuat Klasifikasi Produk'), findsOneWidget);
|
||||
expect(find.widgetWithText(ElevatedButton, 'Coba Lagi'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user