diff --git a/app/integration_test/behavior_test.dart b/app/integration_test/behavior_test.dart deleted file mode 100644 index c274fb8..0000000 --- a/app/integration_test/behavior_test.dart +++ /dev/null @@ -1,29 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:integration_test/integration_test.dart'; - -import 'package:pohnpeian_language_app/main.dart' as app; - -void main() { - IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - - testWidgets('User has the ability to log in', (WidgetTester tester) async { - app.main(); - await tester.pumpAndSettle(); - final button = find.byKey(const ValueKey("signInButton")); - await Future.delayed(const Duration(seconds: 2)); - await tester.tap(button); - await Future.delayed(const Duration(seconds: 1)); - final userNameField = find.byKey(const ValueKey("usernameField")); - await Future.delayed(const Duration(seconds: 1)); - final passwordField = find.byKey(const ValueKey("passwordField")); - await Future.delayed(const Duration(seconds: 1)); - await tester.enterText(userNameField, "someUserName"); - await Future.delayed(const Duration(seconds: 2)); - await tester.enterText(passwordField, "somePassword"); - await Future.delayed(const Duration(seconds: 2)); - await tester.pumpAndSettle(); - await Future.delayed(const Duration(seconds: 1)); - expect(find.text('Log In'), findsWidgets); - }); -} diff --git a/app/integration_test/behavior_tests.dart b/app/integration_test/behavior_tests.dart new file mode 100644 index 0000000..04ed6f0 --- /dev/null +++ b/app/integration_test/behavior_tests.dart @@ -0,0 +1,82 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; + +import 'package:pohnpeian_language_app/main.dart' as app; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + testWidgets('User has the ability to log in', (WidgetTester tester) async { + app.main(); + await tester.pumpAndSettle(); + final button = find.byKey(const ValueKey("SignInButton_fromLogIn")); + expect(button, findsOneWidget); + await Future.delayed(const Duration(seconds: 2)); + await Future.delayed(const Duration(seconds: 1)); + final userNameField = find.byKey(const ValueKey("emailField")); + await Future.delayed(const Duration(seconds: 1)); + final passwordField = find.byKey(const ValueKey("passwordField")); + await Future.delayed(const Duration(seconds: 1)); + await tester.enterText(userNameField, "someUserName"); + await Future.delayed(const Duration(seconds: 2)); + await tester.enterText(passwordField, "somePassword"); + await Future.delayed(const Duration(seconds: 2)); + await tester.pumpAndSettle(); + await Future.delayed(const Duration(seconds: 1)); + expect(find.text('Log In'), findsWidgets); + }); + + testWidgets('Log in user', (WidgetTester tester) async { + app.main(); + await tester.pumpAndSettle(); + await Future.delayed(const Duration(seconds: 1)); + await Future.delayed(const Duration(seconds: 1)); + final userNameField = find.byKey(const ValueKey("emailField")); + await Future.delayed(const Duration(seconds: 1)); + final passwordField = find.byKey(const ValueKey("passwordField")); + await Future.delayed(const Duration(seconds: 1)); + await tester.enterText(userNameField, "tester@email.com"); + await Future.delayed(const Duration(seconds: 1)); + await tester.enterText(passwordField, "tester"); + await Future.delayed(const Duration(seconds: 1)); + await tester.pumpAndSettle(); + await tester.testTextInput.receiveAction(TextInputAction.done); + await tester.pumpAndSettle(); + await Future.delayed(const Duration(seconds: 1)); + await tester.ensureVisible(find.byKey(const Key("SignInButton_fromLogIn"))); + final button = find.byKey(const ValueKey("SignInButton_fromLogIn")); + await tester.tap(button); + await tester.pumpAndSettle(); + await Future.delayed(const Duration(seconds: 6)); + await tester.pumpAndSettle(); + expect(find.textContaining("Learn"), findsWidgets); + }); + + testWidgets('Sign up', (WidgetTester tester) async { + app.main(); + await tester.pumpAndSettle(); + await Future.delayed(const Duration(seconds: 1)); + final button = find.byKey(const ValueKey("SignUpButton")); + await tester.tap(button); + await tester.pumpAndSettle(); + await Future.delayed(const Duration(seconds: 3)); + + final nameField = find.byKey(const ValueKey("signup_namefield")); + final passwordField1 = find.byKey(const ValueKey("signup_passwordfield1")); + final passwordField2 = find.byKey(const ValueKey("signup_passwordfield2")); + final emailField = find.byKey(const ValueKey("signup_emailfield")); + + await tester.pumpAndSettle(); + await tester.enterText(nameField, "SomeName"); + await tester.pumpAndSettle(); + await tester.enterText(passwordField1, "SomePassword"); + await tester.pumpAndSettle(); + await tester.enterText(passwordField2, "SomePassword"); + await tester.pumpAndSettle(); + await tester.enterText(emailField, "someemail@email.com"); + await tester.pumpAndSettle(); + expect(find.text('Sign Up!'), findsWidgets); + }); +} diff --git a/app/lib/main.dart b/app/lib/main.dart index 50e6bbf..dd4d468 100644 --- a/app/lib/main.dart +++ b/app/lib/main.dart @@ -10,7 +10,6 @@ import 'package:firebase_core/firebase_core.dart'; //imports google sign in authentication Future main() async { - ErrorWidget.builder = (FlutterErrorDetails details) => Container(); WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); diff --git a/app/lib/screens/SignUpScreen.dart b/app/lib/screens/SignUpScreen.dart index 1b4278d..b63117e 100644 --- a/app/lib/screens/SignUpScreen.dart +++ b/app/lib/screens/SignUpScreen.dart @@ -4,14 +4,12 @@ import 'loginPage.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:pohnpeian_language_app/services/auth.dart'; - class SignUpPage extends StatelessWidget { const SignUpPage({Key? key}) : super(key: key); static const String _title = "Welcome to Pweek"; static const Color b3 = Color.fromRGBO(45, 211, 112, 1.0); - @override Widget build(BuildContext context) { @@ -47,10 +45,8 @@ class _SignUpPage extends State { TextEditingController cpasswordController = TextEditingController(); TextEditingController emailController = TextEditingController(); - static const b3 = Color.fromRGBO(45, 211, 112, 1.0); - // Create a new user with Email and password using text inside the // Email and password controllers Future createUserWithEmailAndPassword() async { @@ -102,6 +98,7 @@ class _SignUpPage extends State { padding: const EdgeInsets.all(0), color: Colors.white, child: TextField( + key: const Key("signup_namefield"), controller: nameController, decoration: const InputDecoration( border: OutlineInputBorder(), @@ -118,6 +115,7 @@ class _SignUpPage extends State { padding: const EdgeInsets.all(0), color: Colors.white, child: TextField( + key: const Key("signup_passwordfield1"), obscureText: true, controller: passwordController, decoration: const InputDecoration( @@ -135,6 +133,7 @@ class _SignUpPage extends State { padding: const EdgeInsets.all(0), color: Colors.white, child: TextField( + key: const Key("signup_passwordfield2"), obscureText: true, controller: cpasswordController, decoration: const InputDecoration( @@ -152,6 +151,7 @@ class _SignUpPage extends State { padding: const EdgeInsets.all(0), color: Colors.white, child: TextField( + key: const Key("signup_emailfield"), controller: emailController, decoration: const InputDecoration( border: OutlineInputBorder(), diff --git a/app/lib/screens/loginPage.dart b/app/lib/screens/loginPage.dart index 810ad0d..a4d829e 100644 --- a/app/lib/screens/loginPage.dart +++ b/app/lib/screens/loginPage.dart @@ -72,7 +72,6 @@ class _LoginPage extends State { //The login button color static const Color b = Color.fromRGBO(45, 211, 112, 1.0); - @override Widget build(BuildContext context) { @@ -153,6 +152,7 @@ class _LoginPage extends State { Container( padding: const EdgeInsets.fromLTRB(20, 0, 20, 0), child: ElevatedButton( + key: const Key("SignUpButton"), style: ElevatedButton.styleFrom( backgroundColor: (b), textStyle: const TextStyle( @@ -177,6 +177,7 @@ class _LoginPage extends State { padding: const EdgeInsets.fromLTRB(0, 0, 10, 0), alignment: Alignment.bottomCenter, child: ElevatedButton( + key: const Key("SignInButton_fromLogIn"), style: ElevatedButton.styleFrom( backgroundColor: (b), ), diff --git a/app/pubspec.lock b/app/pubspec.lock index 5a0273e..b940a87 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -573,5 +573,5 @@ packages: source: hosted version: "3.0.1" sdks: - dart: ">=2.19.0 <4.0.0" + dart: ">=2.19.0 <3.0.0" flutter: ">=3.3.0"