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,84 @@
|
||||
import 'dart:io';
|
||||
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/camera/image_preview_screen.dart';
|
||||
import 'package:app_pfm_ocr_v2/features/camera/blur_detector.dart';
|
||||
|
||||
void main() {
|
||||
late Directory tempDir;
|
||||
late File tempFile;
|
||||
|
||||
setUpAll(() {
|
||||
tempDir = Directory.systemTemp.createTempSync();
|
||||
tempFile = File('${tempDir.path}/test_preview_image.png');
|
||||
final dummyPngBytes = [
|
||||
137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82,
|
||||
0, 0, 0, 1, 0, 0, 0, 1, 8, 6, 0, 0, 0, 31, 21, 196, 137,
|
||||
0, 0, 0, 10, 73, 68, 65, 84, 120, 156, 99, 0, 1, 0, 0, 5,
|
||||
0, 1, 13, 10, 45, 180, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130
|
||||
];
|
||||
tempFile.writeAsBytesSync(dummyPngBytes);
|
||||
});
|
||||
|
||||
tearDownAll(() {
|
||||
try {
|
||||
tempFile.deleteSync();
|
||||
tempDir.deleteSync();
|
||||
} catch (_) {}
|
||||
});
|
||||
|
||||
testWidgets('ImagePreviewScreen shows Blur Warning when image is blurry', (WidgetTester tester) async {
|
||||
// Inject blurry mock result
|
||||
BlurDetector.mockResult = BlurResult(score: 50.0, isBlur: true, rawScore: 250.0);
|
||||
|
||||
await tester.pumpWidget(
|
||||
ProviderScope(
|
||||
child: MaterialApp(
|
||||
home: ImagePreviewScreen(imagePath: tempFile.path),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Wait for analysis to finish
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
|
||||
// Verify warning text is displayed
|
||||
expect(find.text('Foto Terdeteksi Blur!'), findsOneWidget);
|
||||
expect(find.text('Kualitas Foto Baik'), findsNothing);
|
||||
|
||||
// Verify "Unggah Dokumen" button is disabled (has null onPressed)
|
||||
final uploadButton = tester.widget<ElevatedButton>(find.byType(ElevatedButton));
|
||||
expect(uploadButton.onPressed, isNull);
|
||||
|
||||
BlurDetector.mockResult = null;
|
||||
});
|
||||
|
||||
testWidgets('ImagePreviewScreen shows Sharp Success when image is clear', (WidgetTester tester) async {
|
||||
// Inject sharp mock result
|
||||
BlurDetector.mockResult = BlurResult(score: 95.0, isBlur: false, rawScore: 475.0);
|
||||
|
||||
await tester.pumpWidget(
|
||||
ProviderScope(
|
||||
child: MaterialApp(
|
||||
home: ImagePreviewScreen(imagePath: tempFile.path),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Wait for analysis to finish
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
|
||||
// Verify success text is displayed
|
||||
expect(find.text('Kualitas Foto Baik'), findsOneWidget);
|
||||
expect(find.text('Foto Terdeteksi Blur!'), findsNothing);
|
||||
|
||||
// Verify "Unggah Dokumen" button is enabled (has non-null onPressed)
|
||||
final uploadButton = tester.widget<ElevatedButton>(find.byType(ElevatedButton));
|
||||
expect(uploadButton.onPressed, isNotNull);
|
||||
|
||||
BlurDetector.mockResult = null;
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user