diff --git a/integration_test/app_test.dart b/integration_test/app_test.dart index f303140..870d5bd 100644 --- a/integration_test/app_test.dart +++ b/integration_test/app_test.dart @@ -2,11 +2,14 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'bottom_nav_bar_test.dart'; +import 'onboarding/view/onboarding_flow_test.dart'; + void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('Development App', () { bottomNavBarTest(); + onboardingFlowTest(); }); } diff --git a/integration_test/onboarding/view/onboarding_flow_test.dart b/integration_test/onboarding/view/onboarding_flow_test.dart new file mode 100644 index 0000000..b77be07 --- /dev/null +++ b/integration_test/onboarding/view/onboarding_flow_test.dart @@ -0,0 +1,81 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:fpb/assets/fpb_svg.dart'; +import 'package:fpb/authentication_with_google/application/google_auth_bloc/google_sign_in_bloc.dart'; +import 'package:fpb/l10n/l10n.dart'; +import 'package:fpb/onboarding/onboarding.dart'; + +import '../../../test/helpers/helpers.dart'; + + +void onboardingFlowTest() { + + late AppLocalizations l10n; + + group('onboarding flow', () { + testWidgets('displays the onboarding flow', (tester) async { + await tester.pumpApp(Builder( + builder: (BuildContext context) { + l10n = context.l10n; + return OnboardingScreen(); + } + )); + + await tester.pumpAndSettle(); + + /// TODO: write tests for the bubble animation when it's implemented + + /// Onboarding Screen One + expect(find.image(AssetImage(SvgNames.sendIllustration)), findsOneWidget); + expect(find.text(l10n.onboardingSendTitle), findsOneWidget); + expect(find.text(l10n.onboardingSendDescription), findsOneWidget); + + final Finder skipButtonLabel = find.byKey(ValueKey('skip_button')); + final Finder nextButtonLabel = find.byKey(ValueKey('next_button')); + + expect(find.text(l10n.onboardingSkipLabel), findsOneWidget); + expect(find.text(l10n.onboardingNextLabel), findsOneWidget); + expect(find.byKey(ValueKey('next_icon')), findsOneWidget); + + await tester.tap(skipButtonLabel, warnIfMissed: true); + await tester.tap(nextButtonLabel, warnIfMissed: true); + + await waitForNextScreen(tester); + + /// Onboarding Screen Two + expect( + find.image(AssetImage( + SvgNames.saveIllustration, + )), + findsOneWidget); + expect(find.text(l10n.onboardingSaveTitle), findsOneWidget); + expect(find.text(l10n.onboardingSaveDescription), findsOneWidget); + expect(find.text(l10n.onboardingSkipLabel), findsOneWidget); + expect(find.text(l10n.onboardingNextLabel), findsOneWidget); + await tester.tap(skipButtonLabel, warnIfMissed: true); + await tester.tap(nextButtonLabel, warnIfMissed: true); + + await waitForNextScreen(tester); + + /// Onboarding Screen Three + expect( + find.image(AssetImage(SvgNames.transIllustration)), findsOneWidget); + expect(find.text(l10n.onboardingTransactionTitle), findsOneWidget); + expect(find.text(l10n.onboardingTransactionDescription), findsOneWidget); + final Finder getStartedButtonLabel = + find.byKey(ValueKey('get_started_button')); + await tester.tap(getStartedButtonLabel, warnIfMissed: true); + + // Trigger a frame. + await tester.pumpAndSettle(); + + /// Display the Login screen at the end of the onboarding flow + expect(find.byType(SignIn), findsOneWidget); + }); + }); +} + +Future waitForNextScreen(WidgetTester tester) async { + await tester.pumpAndSettle(); + await tester.pump(Duration(seconds: 1)); +} diff --git a/lib/onboarding/view/widgets/actions.dart b/lib/onboarding/view/widgets/actions.dart index 35079c5..ce97b1a 100644 --- a/lib/onboarding/view/widgets/actions.dart +++ b/lib/onboarding/view/widgets/actions.dart @@ -29,6 +29,7 @@ class Actions extends StatelessWidget { if (!isLastPage) const SizedBox(), if (!isLastPage) TextButton( + key: Key("skip_button"), onPressed: onSkipPressed, child: Text( l10n.onboardingSkipLabel, @@ -36,6 +37,7 @@ class Actions extends StatelessWidget { ), ), FpbButton( + key: !isLastPage ? Key("next_button") : Key('get_started_button'), label: !isLastPage ? l10n.onboardingNextLabel : l10n.onboardingGetStartedLabel, @@ -44,7 +46,8 @@ class Actions extends StatelessWidget { height: cts.maxHeight * 0.07, trailing: !isLastPage ? Icon( - FpbIcons.arrow_right, + key: Key("next_icon"), + FpbIcons.arrow_right, size: cts.maxHeight * 0.02, color: colors.background, )