reading test receipt text detected OK

This commit is contained in:
davmar
2026-08-28 19:14:38 +02:00
parent 0311b8955a
commit 2d8fc46a30
31 changed files with 356 additions and 2289 deletions
+10 -59
View File
@@ -1,66 +1,17 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:myapp/main.dart';
import 'package:myapp/models/item.dart';
import 'package:myapp/services/item_repository.dart';
import 'package:myapp/services/storage_service.dart';
import 'package:myapp/utils/constants.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:receipity/main.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
testWidgets('scan screen shows capture actions', (tester) async {
await tester.pumpWidget(const ReceipityApp());
Future<void> pumpApp(WidgetTester tester) async {
SharedPreferences.setMockInitialValues({});
final storage = StorageService();
await storage.init();
await tester.pumpWidget(
MyApp(
storage: storage,
repository: ItemRepository(),
),
expect(find.text('Receipity'), findsOneWidget);
expect(find.text('Take photo'), findsOneWidget);
expect(find.text('Pick from gallery'), findsOneWidget);
expect(find.text('Use sample receipt'), findsOneWidget);
expect(
find.textContaining('Take a photo of a shopping receipt'),
findsOneWidget,
);
}
testWidgets('splash shows the app name then opens Home', (tester) async {
await pumpApp(tester);
expect(find.text(kAppName), findsWidgets);
await tester.pump(kSplashDuration);
await tester.pump(const Duration(milliseconds: 450));
await tester.pump(const Duration(milliseconds: 350));
expect(find.text('Home'), findsWidgets);
expect(find.text('Featured items'), findsOneWidget);
expect(find.text('Search'), findsOneWidget);
expect(find.text('Profile'), findsOneWidget);
expect(find.text('Settings'), findsOneWidget);
});
testWidgets('tapping a list card opens the detail screen', (tester) async {
await pumpApp(tester);
await tester.pump(kSplashDuration);
await tester.pump(const Duration(milliseconds: 450));
await tester.pump(const Duration(milliseconds: 350));
await tester.tap(find.text('Material 3 surfaces'));
await tester.pump();
await tester.pump(const Duration(milliseconds: 400));
expect(find.text('Details'), findsOneWidget);
expect(find.text('Back to list'), findsOneWidget);
});
test('Item.fromJson maps a JSONPlaceholder post', () {
final item = Item.fromJson({
'id': 3,
'title': 'hello world',
'body': 'First sentence. Second sentence.',
});
expect(item.id, 'remote-3');
expect(item.title, 'Hello world');
expect(item.subtitle, 'First sentence.');
expect(item.category, ItemCategory.lifestyle);
});
}