Skip to content

Commit

Permalink
chore: fix access to applocalization
Browse files Browse the repository at this point in the history
- Enable access to an instance of AppLocalization from the test file
- Rename the onboarding screen integration test file
  • Loading branch information
lkmandy committed Mar 28, 2023
1 parent 52544f2 commit 595c511
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 123 deletions.
2 changes: 1 addition & 1 deletion integration_test/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

import 'bottom_nav_bar_test.dart';
import 'onboarding/view/onboarding_screens.dart';
import 'onboarding/view/onboarding_flow_test.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
Expand Down
81 changes: 81 additions & 0 deletions integration_test/onboarding/view/onboarding_flow_test.dart
Original file line number Diff line number Diff line change
@@ -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<void> waitForNextScreen(WidgetTester tester) async {
await tester.pumpAndSettle();
await tester.pump(Duration(seconds: 1));
}
122 changes: 0 additions & 122 deletions integration_test/onboarding/view/onboarding_screens.dart

This file was deleted.

0 comments on commit 595c511

Please sign in to comment.