Skip to content

Commit

Permalink
update for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nghia-t-nguyen committed Apr 25, 2023
1 parent 0b49009 commit 71fbfe8
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 36 deletions.
29 changes: 0 additions & 29 deletions app/integration_test/behavior_test.dart

This file was deleted.

82 changes: 82 additions & 0 deletions app/integration_test/behavior_tests.dart
Original file line number Diff line number Diff line change
@@ -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, "[email protected]");
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, "[email protected]");
await tester.pumpAndSettle();
expect(find.text('Sign Up!'), findsWidgets);
});
}
1 change: 0 additions & 1 deletion app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
8 changes: 4 additions & 4 deletions app/lib/screens/SignUpScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -47,10 +45,8 @@ class _SignUpPage extends State<SignUpPageState> {
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<void> createUserWithEmailAndPassword() async {
Expand Down Expand Up @@ -102,6 +98,7 @@ class _SignUpPage extends State<SignUpPageState> {
padding: const EdgeInsets.all(0),
color: Colors.white,
child: TextField(
key: const Key("signup_namefield"),
controller: nameController,
decoration: const InputDecoration(
border: OutlineInputBorder(),
Expand All @@ -118,6 +115,7 @@ class _SignUpPage extends State<SignUpPageState> {
padding: const EdgeInsets.all(0),
color: Colors.white,
child: TextField(
key: const Key("signup_passwordfield1"),
obscureText: true,
controller: passwordController,
decoration: const InputDecoration(
Expand All @@ -135,6 +133,7 @@ class _SignUpPage extends State<SignUpPageState> {
padding: const EdgeInsets.all(0),
color: Colors.white,
child: TextField(
key: const Key("signup_passwordfield2"),
obscureText: true,
controller: cpasswordController,
decoration: const InputDecoration(
Expand All @@ -152,6 +151,7 @@ class _SignUpPage extends State<SignUpPageState> {
padding: const EdgeInsets.all(0),
color: Colors.white,
child: TextField(
key: const Key("signup_emailfield"),
controller: emailController,
decoration: const InputDecoration(
border: OutlineInputBorder(),
Expand Down
3 changes: 2 additions & 1 deletion app/lib/screens/loginPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ class _LoginPage extends State<LoginPageState> {

//The login button color
static const Color b = Color.fromRGBO(45, 211, 112, 1.0);


@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -153,6 +152,7 @@ class _LoginPage extends State<LoginPageState> {
Container(
padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),
child: ElevatedButton(
key: const Key("SignUpButton"),
style: ElevatedButton.styleFrom(
backgroundColor: (b),
textStyle: const TextStyle(
Expand All @@ -177,6 +177,7 @@ class _LoginPage extends State<LoginPageState> {
padding: const EdgeInsets.fromLTRB(0, 0, 10, 0),
alignment: Alignment.bottomCenter,
child: ElevatedButton(
key: const Key("SignInButton_fromLogIn"),
style: ElevatedButton.styleFrom(
backgroundColor: (b),
),
Expand Down
2 changes: 1 addition & 1 deletion app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 71fbfe8

Please sign in to comment.