import 'package:flutter_test/flutter_test.dart'; import 'package:myapp/main.dart'; import 'package:myapp/models/bank.dart'; import 'package:myapp/services/storage_service.dart'; import 'package:myapp/utils/constants.dart'; import 'package:myapp/utils/helpers.dart'; import 'package:shared_preferences/shared_preferences.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); Future pumpApp(WidgetTester tester) async { SharedPreferences.setMockInitialValues({}); final storage = StorageService(); await storage.init(); await tester.pumpWidget(MyApp(storage: storage)); } testWidgets('splash shows the app name then opens Balance', (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('Balance'), findsWidgets); expect(find.text('Transactions'), findsOneWidget); expect(find.text('Settings'), findsOneWidget); }); test('ConnectStart.fromJson maps authUrl and state', () { final start = ConnectStart.fromJson({ 'authUrl': 'https://example.test/auth', 'state': 'abc', }); expect(start.authUrl, 'https://example.test/auth'); expect(start.state, 'abc'); }); test('BankTransaction.fromJson maps API fields', () { final tx = BankTransaction.fromJson({ 'date': '2026-09-01', 'description': 'Coffee', 'amount': -3.5, 'currency': 'EUR', 'pending': false, }); expect(tx.description, 'Coffee'); expect(tx.amount, -3.5); expect(formatMoney(tx.amount, tx.currency), contains('EUR')); }); }