prasule/integration_test/setup_test.dart

62 lines
1.8 KiB
Dart
Raw Normal View History

2024-01-19 20:23:16 +01:00
import 'package:flutter/material.dart';
2023-09-14 17:11:40 +02:00
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
2024-01-19 20:23:16 +01:00
import 'package:logger/logger.dart';
import 'package:prasule/api/wallet_manager.dart';
2023-09-14 17:11:40 +02:00
import 'package:prasule/main.dart';
2024-01-19 20:23:16 +01:00
import 'package:prasule/pw/platformfield.dart';
2023-09-14 17:11:40 +02:00
void main() {
2024-01-19 20:23:16 +01:00
final logger = Logger();
2023-09-14 17:11:40 +02:00
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
group("Test Setup screen:", () {
testWidgets('First-time setup', (WidgetTester tester) async {
2024-01-19 20:23:16 +01:00
// delete all data
await WalletManager.deleteAllData();
2023-09-14 17:11:40 +02:00
// Build our app and trigger a frame.
2024-01-19 20:23:16 +01:00
await tester.pumpWidget(
const MyApp(
locale: Locale('en', 'US'),
),
);
await tester.pumpAndSettle();
logger.i("Looking for welcome header");
2023-09-14 17:11:40 +02:00
expect(find.text('Welcome!'), findsOneWidget);
2024-01-19 20:23:16 +01:00
// Tap "Next" button
await tester.tap(find.text("Next"));
await tester.pumpAndSettle();
logger.i("Next view, looking for name+balance fields");
final firstFields = find.byType(PlatformField);
expect(firstFields, findsExactly(2));
logger.i("Entering text");
await tester.enterText(find.byType(PlatformField).first, "Debugging");
await tester.pumpAndSettle();
await tester.enterText(find.byType(PlatformField).last, "100");
await tester.pumpAndSettle();
// Tap "Next" button
await tester.tap(find.text("Next"));
await tester.pumpAndSettle();
// Tap "Finish" button
await tester.tap(find.text("Finish"));
await tester.pumpAndSettle();
2023-09-14 17:11:40 +02:00
2024-01-19 20:23:16 +01:00
expect(
find.byWidgetPredicate(
(widget) =>
widget is DropdownButton &&
((widget as DropdownButton<int>).value ?? -1) == 0,
),
findsOne,
);
2023-09-14 17:11:40 +02:00
});
});
}