Skip to content

Commit

Permalink
FR-18979: Added Sign up via email and password test
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-minaiev-frontegg committed Dec 10, 2024
1 parent 61d6a12 commit 0d55914
Show file tree
Hide file tree
Showing 4 changed files with 290 additions and 1 deletion.
6 changes: 5 additions & 1 deletion example/integration_test/fixtures/const.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ const loginEmail = '[email protected]';
const loginPassword = 'Testing123?';

const loginWrongEmail = '[email protected]';
const loginWrongPassword = 'Testing123?2231';
const loginWrongPassword = 'Testing123?2231';

const signUpEmailTemplate = "alexm122322+{uuid}@gmail.com";
const signUpName = "Test";
const signUpOrganization = "Flutter Integration Testing";
252 changes: 252 additions & 0 deletions example/integration_test/src/sign_up_via_email_and_password_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:frontegg_flutter_example/main.dart';
import 'package:patrol/patrol.dart';
import 'package:uuid/uuid.dart';

import '../fixtures/const.dart';

void main() {
late final String userEmail;

patrolSetUp(() {
userEmail = signUpEmailTemplate.replaceFirst("{uuid}", const Uuid().v4());
});

patrolTest(
"Success Sign up via email and password",
($) async {
await $.pumpWidget(const MyApp());
await $.pumpAndSettle();

await $.tap(find.byKey(const ValueKey("LoginButton")));
await Future.delayed(const Duration(seconds: 5));

await $.native.tap(Selector(text: "Sign up"));
await $.native.waitUntilVisible(Selector(text: "Account sign-up"));

await $.native.enterTextByIndex(
userEmail,
index: 0,
keyboardBehavior: KeyboardBehavior.alternative,
);
await $.native.enterTextByIndex(
signUpName,
index: 1,
keyboardBehavior: KeyboardBehavior.alternative,
);
await $.native.enterTextByIndex(
loginPassword,
index: 2,
keyboardBehavior: KeyboardBehavior.alternative,
);
await $.native.enterTextByIndex(
signUpOrganization,
index: 3,
keyboardBehavior: KeyboardBehavior.alternative,
);

await $.native.tap(Selector(text: "Sign up"));

await $.waitUntilVisible(find.text("Logout"));

await $.tap(find.byKey(const ValueKey("LogoutButton")));
await $.pumpAndSettle();
},
);

patrolTest(
'Failure Sign up with existing user',
($) async {
await $.pumpWidget(const MyApp());
await $.pumpAndSettle();

await $.tap(find.byKey(const ValueKey("LoginButton")));
await Future.delayed(const Duration(seconds: 5));

await $.native.tap(Selector(text: "Sign up"));
await $.native.waitUntilVisible(Selector(text: "Account sign-up"));

await $.native.enterTextByIndex(
loginEmail,
index: 0,
keyboardBehavior: KeyboardBehavior.alternative,
);
await $.native.enterTextByIndex(
signUpName,
index: 1,
keyboardBehavior: KeyboardBehavior.alternative,
);
await $.native.enterTextByIndex(
loginPassword,
index: 2,
keyboardBehavior: KeyboardBehavior.alternative,
);
await $.native.enterTextByIndex(
signUpOrganization,
index: 3,
keyboardBehavior: KeyboardBehavior.alternative,
);

await $.native.tap(Selector(text: "Sign up"));

await $.native.waitUntilVisible(Selector(text: "User already exists"));
},
);

patrolTest(
'Failure Sign up with invalid Email field',
($) async {
await $.pumpWidget(const MyApp());
await $.pumpAndSettle();

await $.tap(find.byKey(const ValueKey("LoginButton")));
await Future.delayed(const Duration(seconds: 5));

await $.native.tap(Selector(text: "Sign up"));
await $.native.waitUntilVisible(Selector(text: "Account sign-up"));

await $.native.enterTextByIndex(
"s",
index: 0,
keyboardBehavior: KeyboardBehavior.alternative,
);
await $.native.enterTextByIndex(
signUpName,
index: 1,
keyboardBehavior: KeyboardBehavior.alternative,
);
await $.native.enterTextByIndex(
loginPassword,
index: 2,
keyboardBehavior: KeyboardBehavior.alternative,
);
await $.native.enterTextByIndex(
signUpOrganization,
index: 3,
keyboardBehavior: KeyboardBehavior.alternative,
);

await $.native.tap(Selector(text: "Sign up"));

await $.native.waitUntilVisible(Selector(text: "Must be a valid email"));
},
);

patrolTest(
'Failure Sign up with empty Name field',
($) async {
await $.pumpWidget(const MyApp());
await $.pumpAndSettle();

await $.tap(find.byKey(const ValueKey("LoginButton")));
await Future.delayed(const Duration(seconds: 5));

await $.native.tap(Selector(text: "Sign up"));
await $.native.waitUntilVisible(Selector(text: "Account sign-up"));

await $.native.enterTextByIndex(
loginEmail,
index: 0,
keyboardBehavior: KeyboardBehavior.alternative,
);
await $.native.enterTextByIndex(
"",
index: 1,
keyboardBehavior: KeyboardBehavior.alternative,
);
await $.native.enterTextByIndex(
loginPassword,
index: 2,
keyboardBehavior: KeyboardBehavior.alternative,
);
await $.native.enterTextByIndex(
signUpOrganization,
index: 3,
keyboardBehavior: KeyboardBehavior.alternative,
);

await $.native.tap(Selector(text: "Sign up"));

await $.native.waitUntilVisible(Selector(text: "Name is required"));
},
);

patrolTest(
'Failure Sign up with empty Password field',
($) async {
await $.pumpWidget(const MyApp());
await $.pumpAndSettle();

await $.tap(find.byKey(const ValueKey("LoginButton")));
await Future.delayed(const Duration(seconds: 5));

await $.native.tap(Selector(text: "Sign up"));
await $.native.waitUntilVisible(Selector(text: "Account sign-up"));

await $.native.enterTextByIndex(
loginEmail,
index: 0,
keyboardBehavior: KeyboardBehavior.alternative,
);
await $.native.enterTextByIndex(
signUpName,
index: 1,
keyboardBehavior: KeyboardBehavior.alternative,
);
await $.native.enterTextByIndex(
"",
index: 2,
keyboardBehavior: KeyboardBehavior.alternative,
);
await $.native.enterTextByIndex(
signUpOrganization,
index: 3,
keyboardBehavior: KeyboardBehavior.alternative,
);

await $.native.tap(Selector(text: "Sign up"));

await $.native.waitUntilVisible(Selector(text: "Password is required"));
},
);

patrolTest(
'Failure Sign up with empty CompanyName field',
($) async {
await $.pumpWidget(const MyApp());
await $.pumpAndSettle();

await $.tap(find.byKey(const ValueKey("LoginButton")));
await Future.delayed(const Duration(seconds: 5));

await $.native.tap(Selector(text: "Sign up"));
await $.native.waitUntilVisible(Selector(text: "Account sign-up"));

await $.native.enterTextByIndex(
loginEmail,
index: 0,
keyboardBehavior: KeyboardBehavior.alternative,
);
await $.native.enterTextByIndex(
signUpName,
index: 1,
keyboardBehavior: KeyboardBehavior.alternative,
);
await $.native.enterTextByIndex(
loginPassword,
index: 2,
keyboardBehavior: KeyboardBehavior.alternative,
);
await $.native.enterTextByIndex(
"",
index: 3,
keyboardBehavior: KeyboardBehavior.alternative,
);

await $.native.tap(Selector(text: "Sign up"));

await $.native.waitUntilVisible(Selector(text: "Company name is required"));
},
);
}
32 changes: 32 additions & 0 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.18.0"
crypto:
dependency: transitive
description:
name: crypto
sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855"
url: "https://pub.dev"
source: hosted
version: "3.0.6"
dispose_scope:
dependency: transitive
description:
Expand Down Expand Up @@ -73,6 +81,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "7.0.0"
fixnum:
dependency: transitive
description:
name: fixnum
sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be
url: "https://pub.dev"
source: hosted
version: "1.1.1"
flutter:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -278,6 +294,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.10.0"
sprintf:
dependency: transitive
description:
name: sprintf
sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -334,6 +358,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.4.0"
uuid:
dependency: "direct dev"
description:
name: uuid
sha256: a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff
url: "https://pub.dev"
source: hosted
version: "4.5.1"
vector_math:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dev_dependencies:
sdk: flutter
flutter_lints: ^4.0.0
patrol: ^3.13.1
uuid: ^4.5.1

flutter:
uses-material-design: true
Expand Down

0 comments on commit 0d55914

Please sign in to comment.