-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5fbbb50
commit 949939e
Showing
1 changed file
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:frontegg_flutter_example/main.dart'; | ||
import 'package:patrol/patrol.dart'; | ||
|
||
void main() { | ||
const appleButtonLabel = "continue with apple"; | ||
|
||
late final String email; | ||
late final String password; | ||
|
||
patrolSetUp(() { | ||
email = const String.fromEnvironment('APPLE_EMAIL'); | ||
password = const String.fromEnvironment('APPLE_PASSWORD'); | ||
|
||
assert(email.isNotEmpty && password.isNotEmpty); | ||
}); | ||
|
||
patrolTest( | ||
'Success Login via Apple Provider', | ||
($) async { | ||
await $.pumpWidget(const MyApp()); | ||
await $.pumpAndSettle(); | ||
|
||
await $.tap(find.byKey(const ValueKey("LoginButton"))); | ||
|
||
await $.native.tap( | ||
Selector(text: appleButtonLabel), | ||
timeout: const Duration(seconds: 10), | ||
); | ||
await Future.delayed(const Duration(seconds: 3)); | ||
if (Platform.isIOS) { | ||
await $.native.tap(Selector(text: "Continue")); | ||
await Future.delayed(const Duration(seconds: 7)); | ||
} | ||
|
||
await $.native2.enterText( | ||
NativeSelector( | ||
ios: IOSSelector( | ||
label: "Email or Phone Number", | ||
), | ||
android: AndroidSelector( | ||
resourceName: "account_name_text_field", | ||
), | ||
), | ||
text: email, | ||
keyboardBehavior: KeyboardBehavior.alternative, | ||
); | ||
if (Platform.isAndroid) { | ||
await $.native.tap(Selector(resourceId: "sign-in")); | ||
} | ||
await Future.delayed(const Duration(seconds: 3)); | ||
|
||
await $.native2.enterText( | ||
NativeSelector( | ||
ios: IOSSelector( | ||
label: "password", | ||
), | ||
android: AndroidSelector( | ||
resourceName: "password_text_field", | ||
), | ||
), | ||
text: password, | ||
keyboardBehavior: KeyboardBehavior.alternative, | ||
); | ||
if (Platform.isAndroid) { | ||
await $.native.tap(Selector(resourceId: "sign-in")); | ||
} | ||
|
||
await $.native.waitUntilVisible(Selector(textStartsWith: "Do you want to continue using")); | ||
await Future.delayed(const Duration(seconds: 2)); | ||
await $.native2.tap( | ||
NativeSelector( | ||
ios: IOSSelector( | ||
label: "Continue", | ||
instance: 1, | ||
), | ||
android: AndroidSelector( | ||
textContains: "Continue", | ||
isClickable: true, | ||
), | ||
), | ||
); | ||
|
||
await $.pumpAndSettle(); | ||
await $.waitUntilVisible(find.text("Logout"), timeout: const Duration(seconds: 15),); | ||
|
||
await $.tap(find.byKey(const ValueKey("LogoutButton"))); | ||
await $.pumpAndSettle(); | ||
await $.waitUntilVisible(find.text("Not Authenticated")); | ||
}, | ||
); | ||
} |