app working with sandbox

This commit is contained in:
davmar
2026-09-06 21:13:30 +02:00
parent 8475abeddb
commit 773187f0af
18 changed files with 1909 additions and 100 deletions
+23 -35
View File
@@ -1,9 +1,9 @@
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/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() {
@@ -13,15 +13,10 @@ void main() {
SharedPreferences.setMockInitialValues({});
final storage = StorageService();
await storage.init();
await tester.pumpWidget(
MyApp(
storage: storage,
repository: ItemRepository(),
),
);
await tester.pumpWidget(MyApp(storage: storage));
}
testWidgets('splash shows the app name then opens Home', (tester) async {
testWidgets('splash shows the app name then opens Balance', (tester) async {
await pumpApp(tester);
expect(find.text(kAppName), findsWidgets);
@@ -30,37 +25,30 @@ void main() {
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('Balance'), findsWidgets);
expect(find.text('Transactions'), 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('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('Item.fromJson maps a JSONPlaceholder post', () {
final item = Item.fromJson({
'id': 3,
'title': 'hello world',
'body': 'First sentence. Second sentence.',
test('BankTransaction.fromJson maps API fields', () {
final tx = BankTransaction.fromJson({
'date': '2026-09-01',
'description': 'Coffee',
'amount': -3.5,
'currency': 'EUR',
'pending': false,
});
expect(item.id, 'remote-3');
expect(item.title, 'Hello world');
expect(item.subtitle, 'First sentence.');
expect(item.category, ItemCategory.lifestyle);
expect(tx.description, 'Coffee');
expect(tx.amount, -3.5);
expect(formatMoney(tx.amount, tx.currency), contains('EUR'));
});
}