feat: consolidate backend and docker-compose setup
This commit is contained in:
commit
ff3753a745
306 files changed
+35450
No files matched your search
@@ -0,0 +1,100 @@
|
||||
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/documents/documents_screen.dart';
|
||||
import 'package:app_pfm_ocr_v2/models/document_model.dart';
|
||||
import 'package:app_pfm_ocr_v2/main.dart';
|
||||
import 'package:app_pfm_ocr_v2/core/storage/local_storage.dart';
|
||||
|
||||
class MockLocalStorage extends LocalStorage {
|
||||
final List<DocumentModel> docs;
|
||||
|
||||
MockLocalStorage(this.docs);
|
||||
|
||||
@override
|
||||
Future<void> init() async {}
|
||||
|
||||
@override
|
||||
List<DocumentModel> getAllDocuments() {
|
||||
return docs;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> saveDocument(DocumentModel doc) async {}
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('DocumentsScreen search and coordinate formatting tests', (WidgetTester tester) async {
|
||||
final testDocs = [
|
||||
DocumentModel(
|
||||
id: '1',
|
||||
tanggal: '29 Juni 2026',
|
||||
noPo: 'PO/26/0000111111',
|
||||
noSo: '1000000001',
|
||||
noDo: 'DO-111111',
|
||||
kepadaYth: 'PT. PRIMAFOOD BEKASI',
|
||||
orderUntuk: 'PRIMA FRESH MART',
|
||||
alamat: 'Bekasi',
|
||||
platTruk: 'B 1234 ABC',
|
||||
namaDriver: 'Driver A',
|
||||
namaPenerima: 'Penerima A',
|
||||
latitude: -6.123456,
|
||||
longitude: 106.567890,
|
||||
items: [],
|
||||
createdAt: DateTime.now(),
|
||||
),
|
||||
DocumentModel(
|
||||
id: '2',
|
||||
tanggal: '30 Juni 2026',
|
||||
noPo: 'PO/26/0000222222',
|
||||
noSo: '2000000002',
|
||||
noDo: 'DO-222222',
|
||||
kepadaYth: 'PT. PRIMAFOOD TANGERANG',
|
||||
orderUntuk: 'PRIMA FRESH MART',
|
||||
alamat: 'Tangerang',
|
||||
platTruk: 'B 5678 XYZ',
|
||||
namaDriver: 'Driver B',
|
||||
namaPenerima: 'Penerima B',
|
||||
latitude: null,
|
||||
longitude: null,
|
||||
items: [],
|
||||
createdAt: DateTime.now().subtract(const Duration(hours: 1)),
|
||||
),
|
||||
];
|
||||
|
||||
final mockLocalStorage = MockLocalStorage(testDocs);
|
||||
|
||||
await tester.pumpWidget(
|
||||
ProviderScope(
|
||||
overrides: [
|
||||
localStorageProvider.overrideWithValue(mockLocalStorage),
|
||||
],
|
||||
child: const MaterialApp(
|
||||
home: DocumentsScreen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Verify both documents are rendered initially
|
||||
expect(find.text('DO: DO-111111'), findsOneWidget);
|
||||
expect(find.text('DO: DO-222222'), findsOneWidget);
|
||||
|
||||
// Verify coordinate rounding to 4 decimal places
|
||||
// -6.123456 -> -6.1235
|
||||
// 106.567890 -> 106.5679
|
||||
expect(find.text('Lat: -6.1235'), findsOneWidget);
|
||||
expect(find.text('Lng: 106.5679'), findsOneWidget);
|
||||
|
||||
// Type query in search bar to filter only Bekasi
|
||||
final searchField = find.byType(TextField);
|
||||
expect(searchField, findsOneWidget);
|
||||
await tester.enterText(searchField, 'BEKASI');
|
||||
await tester.pump();
|
||||
|
||||
// Verify only the Bekasi document matches
|
||||
expect(find.text('DO: DO-111111'), findsOneWidget);
|
||||
expect(find.text('DO: DO-222222'), findsNothing);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user