|
| 1 | +import 'package:example/src/common/widget/app.dart'; |
| 2 | +import 'package:example/src/feature/initialization/widget/inherited_dependencies.dart'; |
| 3 | +import 'package:flutter/material.dart'; |
| 4 | +import 'package:flutter_test/flutter_test.dart'; |
| 5 | +import 'package:integration_test/integration_test.dart'; |
| 6 | + |
| 7 | +import 'src/fake/fake_dependencies.dart'; |
| 8 | +import 'src/util/tester_extension.dart'; |
| 9 | + |
| 10 | +void main() { |
| 11 | + final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized(); |
| 12 | + group('end-to-end', () { |
| 13 | + late final Widget app; |
| 14 | + |
| 15 | + setUpAll(() async { |
| 16 | + binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive; |
| 17 | + final dependencies = await $initializeFakeDependencies(); |
| 18 | + app = InheritedDependencies( |
| 19 | + dependencies: dependencies, |
| 20 | + child: const App(), |
| 21 | + ); |
| 22 | + }); |
| 23 | + |
| 24 | + testWidgets('app', (tester) async { |
| 25 | + await tester.pumpWidget(app); |
| 26 | + await tester.pumpAndSettle(); |
| 27 | + expect(find.byType(InheritedDependencies), findsOneWidget); |
| 28 | + expect(find.byType(App), findsOneWidget); |
| 29 | + expect(find.byType(MaterialApp), findsOneWidget); |
| 30 | + }); |
| 31 | + |
| 32 | + testWidgets('sign-in', (tester) async { |
| 33 | + await tester.pumpWidget(app); |
| 34 | + await tester.pumpAndSettle(); |
| 35 | + expect(find.text('Sign-In'), findsAtLeastNWidgets(1)); |
| 36 | + await tester.tap(find.descendant( |
| 37 | + of: find.byType(InkWell), |
| 38 | + matching: find.text('Sign-Up'), |
| 39 | + )); |
| 40 | + await tester.pumpAndPause(); |
| 41 | + await tester.tap(find.descendant( |
| 42 | + of: find.byType(InkWell), |
| 43 | + matching: find.text('Cancel'), |
| 44 | + )); |
| 45 | + await tester.pumpAndPause(); |
| 46 | + await tester.enterText( |
| 47 | + find.ancestor( |
| 48 | + of: find.text('Username'), |
| 49 | + matching: find.byType(TextField), |
| 50 | + ), |
| 51 | + 'app-test@gmail.com'); |
| 52 | + await tester.enterText( |
| 53 | + find.ancestor( |
| 54 | + of: find.text('Password'), |
| 55 | + matching: find.byType(TextField), |
| 56 | + ), |
| 57 | + 'Password123'); |
| 58 | + await tester.tap(find.ancestor( |
| 59 | + of: find.byIcon(Icons.visibility), |
| 60 | + matching: find.byType(IconButton), |
| 61 | + )); |
| 62 | + await tester.pumpAndPause(); |
| 63 | + await tester.tap(find.ancestor( |
| 64 | + of: find.byIcon(Icons.visibility_off), |
| 65 | + matching: find.byType(IconButton), |
| 66 | + )); |
| 67 | + await tester.pumpAndPause(); |
| 68 | + await tester.tap(find.descendant( |
| 69 | + of: find.byType(InkWell), |
| 70 | + matching: find.text('Sign-In'), |
| 71 | + )); |
| 72 | + await tester.pumpAndPause(const Duration(seconds: 1)); |
| 73 | + expect(find.text('Sign-In'), findsNothing); |
| 74 | + expect(find.text('Home'), findsAtLeastNWidgets(1)); |
| 75 | + }); |
| 76 | + }); |
| 77 | +} |
0 commit comments