WIP
This commit is contained in:
parent
148b10b81e
commit
01c38fcdc4
|
@ -11,30 +11,30 @@ late WidgetTester widget;
|
||||||
void main() {
|
void main() {
|
||||||
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
group('Initialization', () {
|
group('Initialization', () {
|
||||||
setUpAll(() async => await initializeApp().then((_) => StorageUtil().isLogged = false));
|
group('Navigation', () {
|
||||||
|
setUpAll(() async =>
|
||||||
|
await initializeApp().then((_) => StorageUtil().isLogged = false));
|
||||||
testWidgets('Test Welcome', (WidgetTester tester) async {
|
testWidgets('Test Welcome', (WidgetTester tester) async {
|
||||||
widget = tester;
|
widget = tester;
|
||||||
await _testWelcome();
|
await _testWelcome();
|
||||||
});
|
});
|
||||||
|
|
||||||
group('Terms of Use', () {
|
|
||||||
// Add tests for Terms of Use here
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
group('Terms of Use', () {});
|
||||||
});
|
});
|
||||||
group('Authentication', () {
|
group('Authentication', () {
|
||||||
|
|
||||||
group('Sign in', () {
|
group('Sign in', () {
|
||||||
setUpAll(() async => await initializeApp().then((_) => StorageUtil().isLogged = false));
|
setUpAll(() async =>
|
||||||
|
await initializeApp().then((_) => StorageUtil().isLogged = false));
|
||||||
testWidgets('Test Sign In', (WidgetTester tester) async {
|
testWidgets('Test Sign In', (WidgetTester tester) async {
|
||||||
widget = tester;
|
widget = tester;
|
||||||
await _testSignIn();
|
await _testSignIn();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
group('Sign up', () {
|
group('Sign up', () {
|
||||||
setUpAll(() async => await initializeApp().then((_) => StorageUtil().isLogged = false));
|
setUpAll(() async =>
|
||||||
|
await initializeApp().then((_) => StorageUtil().isLogged = false));
|
||||||
testWidgets('Test Sign Up', (WidgetTester tester) async {
|
testWidgets('Test Sign Up', (WidgetTester tester) async {
|
||||||
widget = tester;
|
widget = tester;
|
||||||
await _testSignUp();
|
await _testSignUp();
|
||||||
|
@ -44,14 +44,13 @@ void main() {
|
||||||
// Add tests for Sign Out here
|
// Add tests for Sign Out here
|
||||||
});
|
});
|
||||||
group('Forgot Password', () {
|
group('Forgot Password', () {
|
||||||
setUpAll(() async => await initializeApp().then((_) => StorageUtil().isLogged = false));
|
// setUpAll(() async => await initializeApp().then((_) => StorageUtil().isLogged = false));
|
||||||
testWidgets('Test Forgot Password', (WidgetTester tester) async {
|
// testWidgets('Test Forgot Password', (WidgetTester tester) async {
|
||||||
widget = tester;
|
// widget = tester;
|
||||||
await _testForgotPassword();
|
// await _testForgotPassword();
|
||||||
|
// });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
|
||||||
group('Localization', () {
|
group('Localization', () {
|
||||||
// Add tests for Localization here
|
// Add tests for Localization here
|
||||||
});
|
});
|
||||||
|
@ -93,12 +92,20 @@ Future<void> _testWelcome() async {
|
||||||
await _navigateToSignIn();
|
await _navigateToSignIn();
|
||||||
await widget.pumpAndSettle();
|
await widget.pumpAndSettle();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _testSignIn() async {
|
Future<void> _testSignIn() async {
|
||||||
await widget.pumpWidget(const App());
|
await widget.pumpWidget(const App());
|
||||||
await _navigateToSignIn();
|
await _navigateToSignIn();
|
||||||
await _auth({'emailTextFormField': 'erro@exemplo.com', 'passwordTextFormField': '12345678'});
|
await _auth({
|
||||||
await _auth({'emailTextFormField': 'email_app@exemplo.com', 'passwordTextFormField': '12345678'});
|
'emailTextFormField': 'erro@exemplo.com',
|
||||||
|
'passwordTextFormField': '12345678'
|
||||||
|
});
|
||||||
|
await _auth({
|
||||||
|
'emailTextFormField': 'email_app@exemplo.com',
|
||||||
|
'passwordTextFormField': '12345678'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _testSignUp() async {
|
Future<void> _testSignUp() async {
|
||||||
await widget.pumpWidget(const App());
|
await widget.pumpWidget(const App());
|
||||||
await _navigateToSignUp();
|
await _navigateToSignUp();
|
||||||
|
@ -126,6 +133,7 @@ Future<void> _testSignUp() async {
|
||||||
};
|
};
|
||||||
await _auth(credentials);
|
await _auth(credentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _testForgotPassword() async {
|
Future<void> _testForgotPassword() async {
|
||||||
await widget.pumpWidget(const App());
|
await widget.pumpWidget(const App());
|
||||||
await _navigateToSignIn();
|
await _navigateToSignIn();
|
||||||
|
@ -141,27 +149,33 @@ Future<void> _testForgotPassword() async {
|
||||||
credentials = {'recoveryTextFormField': 'email_app@exemple.com'};
|
credentials = {'recoveryTextFormField': 'email_app@exemple.com'};
|
||||||
await _send(credentials);
|
await _send(credentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _recoveryPassword() async {
|
Future<void> _recoveryPassword() async {
|
||||||
await widget.pumpAndSettle();
|
await widget.pumpAndSettle();
|
||||||
final Finder forgotPassword = find.byKey(const ValueKey<String>('ForgotPassword'));
|
final Finder forgotPassword =
|
||||||
|
find.byKey(const ValueKey<String>('ForgotPassword'));
|
||||||
if (forgotPassword.evaluate().isNotEmpty) await widget.tap(forgotPassword);
|
if (forgotPassword.evaluate().isNotEmpty) await widget.tap(forgotPassword);
|
||||||
await widget.ensureVisible(forgotPassword);
|
await widget.ensureVisible(forgotPassword);
|
||||||
await widget.pumpAndSettle();
|
await widget.pumpAndSettle();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _navigateBackUsingSystemGesture() async =>
|
Future<void> _navigateBackUsingSystemGesture() async =>
|
||||||
IntegrationTestWidgetsFlutterBinding.instance.keyboard.isLogicalKeyPressed(LogicalKeyboardKey.escape);
|
IntegrationTestWidgetsFlutterBinding.instance.keyboard
|
||||||
|
.isLogicalKeyPressed(LogicalKeyboardKey.escape);
|
||||||
Future<void> _navigateToSignUp() async {
|
Future<void> _navigateToSignUp() async {
|
||||||
await widget.pumpAndSettle();
|
await widget.pumpAndSettle();
|
||||||
final Finder navToSignUp = find.byKey(const ValueKey<String>('toggleSignUpPage'));
|
final Finder navToSignUp =
|
||||||
|
find.byKey(const ValueKey<String>('toggleSignUpPage'));
|
||||||
if (navToSignUp.evaluate().isNotEmpty) {
|
if (navToSignUp.evaluate().isNotEmpty) {
|
||||||
await widget.tap(navToSignUp);
|
await widget.tap(navToSignUp);
|
||||||
await widget.pumpAndSettle();
|
await widget.pumpAndSettle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _navigateToSignIn() async {
|
Future<void> _navigateToSignIn() async {
|
||||||
await widget.pumpAndSettle();
|
await widget.pumpAndSettle();
|
||||||
final Finder navToSignIn = find.byKey(const ValueKey<String>('toggleSignInPage'));
|
final Finder navToSignIn =
|
||||||
|
find.byKey(const ValueKey<String>('toggleSignInPage'));
|
||||||
expect(navToSignIn, findsOneWidget);
|
expect(navToSignIn, findsOneWidget);
|
||||||
if (navToSignIn.evaluate().isNotEmpty) {
|
if (navToSignIn.evaluate().isNotEmpty) {
|
||||||
await widget.tap(navToSignIn);
|
await widget.tap(navToSignIn);
|
||||||
|
@ -173,10 +187,12 @@ Future<void> _auth(Map<String, dynamic> credentials) async {
|
||||||
await _enterCredentials(credentials);
|
await _enterCredentials(credentials);
|
||||||
await _submit('SubmitButtonWidget');
|
await _submit('SubmitButtonWidget');
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _send(Map<String, dynamic> credentials) async {
|
Future<void> _send(Map<String, dynamic> credentials) async {
|
||||||
await _enterCredentials(credentials);
|
await _enterCredentials(credentials);
|
||||||
await _submit('SendButtonWidget');
|
await _submit('SendButtonWidget');
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _enterCredentials(Map<String, dynamic> credentials) async {
|
Future<void> _enterCredentials(Map<String, dynamic> credentials) async {
|
||||||
await widget.pumpAndSettle();
|
await widget.pumpAndSettle();
|
||||||
for (var entry in credentials.entries) {
|
for (var entry in credentials.entries) {
|
||||||
|
@ -188,6 +204,7 @@ Future<void> _enterCredentials(Map<String, dynamic> credentials) async {
|
||||||
}
|
}
|
||||||
await widget.pumpAndSettle();
|
await widget.pumpAndSettle();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _submit(String key) async {
|
Future<void> _submit(String key) async {
|
||||||
await widget.pumpAndSettle();
|
await widget.pumpAndSettle();
|
||||||
final Finder submitButton = find.byKey(ValueKey<String>(key));
|
final Finder submitButton = find.byKey(ValueKey<String>(key));
|
||||||
|
@ -197,7 +214,8 @@ Future<void> _submit(String key) async {
|
||||||
await widget.pumpAndSettle();
|
await widget.pumpAndSettle();
|
||||||
}
|
}
|
||||||
|
|
||||||
final Finder throwExceptionWidget = find.byKey(const ValueKey<String>('ThrowExceptionWidget'));
|
final Finder throwExceptionWidget =
|
||||||
|
find.byKey(const ValueKey<String>('ThrowExceptionWidget'));
|
||||||
await widget.pumpAndSettle();
|
await widget.pumpAndSettle();
|
||||||
if (throwExceptionWidget.evaluate().isNotEmpty) {
|
if (throwExceptionWidget.evaluate().isNotEmpty) {
|
||||||
await widget.ensureVisible(throwExceptionWidget);
|
await widget.ensureVisible(throwExceptionWidget);
|
||||||
|
|
Loading…
Reference in New Issue