Skip to content

Commit

Permalink
FR-18979: Added Login 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 da0b805 commit 17b8b02
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 3 deletions.
5 changes: 5 additions & 0 deletions example/integration_test/fixtures/const.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const loginEmail = '[email protected]';
const loginPassword = 'Testing123?';

const loginWrongEmail = '[email protected]';
const loginWrongPassword = 'Testing123?2231';
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
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 '../fixtures/const.dart';

void main() {
patrolTest(
'Success Login 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.enterTextByIndex(
loginEmail,
index: 0,
keyboardBehavior: KeyboardBehavior.alternative,
);

await $.native.enterTextByIndex(
loginPassword,
index: 1,
keyboardBehavior: KeyboardBehavior.alternative,
);

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

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

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

patrolTest(
'Failure Login via wrong 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.enterTextByIndex(
loginWrongEmail,
index: 0,
keyboardBehavior: KeyboardBehavior.alternative,
);

await $.native.enterTextByIndex(
loginPassword,
index: 1,
keyboardBehavior: KeyboardBehavior.alternative,
);

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

await $.native.waitUntilVisible(Selector(text: "Incorrect email or password"));
},
);

patrolTest(
'Failure Login via email and wrong password',
($) async {
await $.pumpWidget(const MyApp());
await $.pumpAndSettle();

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

await $.native.enterTextByIndex(
loginEmail,
index: 0,
keyboardBehavior: KeyboardBehavior.alternative,
);

await $.native.enterTextByIndex(
loginWrongPassword,
index: 1,
keyboardBehavior: KeyboardBehavior.alternative,
);

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

await $.native.waitUntilVisible(Selector(text: "Incorrect email or password"));
},
);
}
1 change: 1 addition & 0 deletions example/lib/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class LoginPage extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
key: const ValueKey("LoginButton"),
child: const Text("Login"),
onPressed: () async {
await frontegg.login();
Expand Down
5 changes: 2 additions & 3 deletions example/lib/user_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ class UserTab extends StatelessWidget {
),
if (!state.isLoading)
ElevatedButton(
child: const Text(
"Logout",
),
key: const ValueKey("LogoutButton"),
child: const Text("Logout"),
onPressed: () async {
await frontegg.logout();
debugPrint("Logout Finished");
Expand Down

0 comments on commit 17b8b02

Please sign in to comment.