From 01c38fcdc4f50cf331e1122a12ca1274721b7dfe Mon Sep 17 00:00:00 2001 From: "J. A. Messias" Date: Tue, 15 Oct 2024 16:19:25 -0300 Subject: [PATCH] WIP --- integration_test/app_test.dart | 68 +++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 25 deletions(-) diff --git a/integration_test/app_test.dart b/integration_test/app_test.dart index cec0d5f2..f5a1de48 100644 --- a/integration_test/app_test.dart +++ b/integration_test/app_test.dart @@ -11,30 +11,30 @@ late WidgetTester widget; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - - group('Initialization', () { - setUpAll(() async => await initializeApp().then((_) => StorageUtil().isLogged = false)); - testWidgets('Test Welcome', (WidgetTester tester) async { - widget = tester; - await _testWelcome(); + group('Navigation', () { + setUpAll(() async => + await initializeApp().then((_) => StorageUtil().isLogged = false)); + testWidgets('Test Welcome', (WidgetTester tester) async { + widget = tester; + await _testWelcome(); + }); }); - group('Terms of Use', () { - // Add tests for Terms of Use here - }); + group('Terms of Use', () {}); }); group('Authentication', () { - group('Sign in', () { - setUpAll(() async => await initializeApp().then((_) => StorageUtil().isLogged = false)); + setUpAll(() async => + await initializeApp().then((_) => StorageUtil().isLogged = false)); testWidgets('Test Sign In', (WidgetTester tester) async { widget = tester; await _testSignIn(); }); }); group('Sign up', () { - setUpAll(() async => await initializeApp().then((_) => StorageUtil().isLogged = false)); + setUpAll(() async => + await initializeApp().then((_) => StorageUtil().isLogged = false)); testWidgets('Test Sign Up', (WidgetTester tester) async { widget = tester; await _testSignUp(); @@ -44,13 +44,12 @@ void main() { // Add tests for Sign Out here }); group('Forgot Password', () { - setUpAll(() async => await initializeApp().then((_) => StorageUtil().isLogged = false)); - testWidgets('Test Forgot Password', (WidgetTester tester) async { - widget = tester; - await _testForgotPassword(); - }); + // setUpAll(() async => await initializeApp().then((_) => StorageUtil().isLogged = false)); + // testWidgets('Test Forgot Password', (WidgetTester tester) async { + // widget = tester; + // await _testForgotPassword(); + // }); }); - }); group('Localization', () { // Add tests for Localization here @@ -93,12 +92,20 @@ Future _testWelcome() async { await _navigateToSignIn(); await widget.pumpAndSettle(); } + Future _testSignIn() async { await widget.pumpWidget(const App()); await _navigateToSignIn(); - await _auth({'emailTextFormField': 'erro@exemplo.com', 'passwordTextFormField': '12345678'}); - await _auth({'emailTextFormField': 'email_app@exemplo.com', 'passwordTextFormField': '12345678'}); + await _auth({ + 'emailTextFormField': 'erro@exemplo.com', + 'passwordTextFormField': '12345678' + }); + await _auth({ + 'emailTextFormField': 'email_app@exemplo.com', + 'passwordTextFormField': '12345678' + }); } + Future _testSignUp() async { await widget.pumpWidget(const App()); await _navigateToSignUp(); @@ -126,6 +133,7 @@ Future _testSignUp() async { }; await _auth(credentials); } + Future _testForgotPassword() async { await widget.pumpWidget(const App()); await _navigateToSignIn(); @@ -141,27 +149,33 @@ Future _testForgotPassword() async { credentials = {'recoveryTextFormField': 'email_app@exemple.com'}; await _send(credentials); } + Future _recoveryPassword() async { await widget.pumpAndSettle(); - final Finder forgotPassword = find.byKey(const ValueKey('ForgotPassword')); + final Finder forgotPassword = + find.byKey(const ValueKey('ForgotPassword')); if (forgotPassword.evaluate().isNotEmpty) await widget.tap(forgotPassword); await widget.ensureVisible(forgotPassword); await widget.pumpAndSettle(); } Future _navigateBackUsingSystemGesture() async => - IntegrationTestWidgetsFlutterBinding.instance.keyboard.isLogicalKeyPressed(LogicalKeyboardKey.escape); + IntegrationTestWidgetsFlutterBinding.instance.keyboard + .isLogicalKeyPressed(LogicalKeyboardKey.escape); Future _navigateToSignUp() async { await widget.pumpAndSettle(); - final Finder navToSignUp = find.byKey(const ValueKey('toggleSignUpPage')); + final Finder navToSignUp = + find.byKey(const ValueKey('toggleSignUpPage')); if (navToSignUp.evaluate().isNotEmpty) { await widget.tap(navToSignUp); await widget.pumpAndSettle(); } } + Future _navigateToSignIn() async { await widget.pumpAndSettle(); - final Finder navToSignIn = find.byKey(const ValueKey('toggleSignInPage')); + final Finder navToSignIn = + find.byKey(const ValueKey('toggleSignInPage')); expect(navToSignIn, findsOneWidget); if (navToSignIn.evaluate().isNotEmpty) { await widget.tap(navToSignIn); @@ -173,10 +187,12 @@ Future _auth(Map credentials) async { await _enterCredentials(credentials); await _submit('SubmitButtonWidget'); } + Future _send(Map credentials) async { await _enterCredentials(credentials); await _submit('SendButtonWidget'); } + Future _enterCredentials(Map credentials) async { await widget.pumpAndSettle(); for (var entry in credentials.entries) { @@ -188,6 +204,7 @@ Future _enterCredentials(Map credentials) async { } await widget.pumpAndSettle(); } + Future _submit(String key) async { await widget.pumpAndSettle(); final Finder submitButton = find.byKey(ValueKey(key)); @@ -197,7 +214,8 @@ Future _submit(String key) async { await widget.pumpAndSettle(); } - final Finder throwExceptionWidget = find.byKey(const ValueKey('ThrowExceptionWidget')); + final Finder throwExceptionWidget = + find.byKey(const ValueKey('ThrowExceptionWidget')); await widget.pumpAndSettle(); if (throwExceptionWidget.evaluate().isNotEmpty) { await widget.ensureVisible(throwExceptionWidget);