Merge branch 'develop' into fd-862
This commit is contained in:
commit
641d6cb975
|
@ -6,165 +6,151 @@ import 'package:hub/main.dart';
|
||||||
import 'package:hub/shared/utils/storage_util.dart';
|
import 'package:hub/shared/utils/storage_util.dart';
|
||||||
import 'package:integration_test/integration_test.dart';
|
import 'package:integration_test/integration_test.dart';
|
||||||
|
|
||||||
|
|
||||||
late WidgetTester widget;
|
late WidgetTester widget;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
group('Initialization', () {
|
group('Initialization', () {
|
||||||
setUpAll(() async => await initializeApp().then((_) => StorageUtil().isLogged = false));
|
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 widget.pumpWidget(const App());
|
|
||||||
await widget.pumpAndSettle();
|
|
||||||
await _navigateToSignIn();
|
|
||||||
await _navigateToSignUp();
|
|
||||||
await widget.pumpAndSettle();
|
|
||||||
await widget.pumpWidget(const App());
|
|
||||||
await widget.pumpAndSettle();
|
|
||||||
await _navigateToSignUp();
|
|
||||||
await _navigateToSignIn();
|
|
||||||
await widget.pumpAndSettle();
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
group('Terms of Use', (){});
|
group('Terms of Use', () {
|
||||||
|
// Add tests for Terms of Use here
|
||||||
|
});
|
||||||
});
|
});
|
||||||
group('Authentication', () {
|
group('Authentication', () {
|
||||||
group('Sign in', () {
|
|
||||||
setUpAll(() async =>
|
|
||||||
await initializeApp().then((_) => StorageUtil().isLogged = false));
|
|
||||||
|
|
||||||
|
group('Sign in', () {
|
||||||
|
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 widget.pumpWidget(const App());
|
|
||||||
await _navigateToSignIn();
|
|
||||||
|
|
||||||
await _auth({'emailTextFormField': 'erro@exemplo.com', 'passwordTextFormField': '12345678'});
|
|
||||||
await _auth({'emailTextFormField': 'email_app@exemplo.com','passwordTextFormField': '12345678'});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
group('Sign up', () {
|
group('Sign up', () {
|
||||||
setUpAll(() async =>
|
setUpAll(() async => await initializeApp().then((_) => StorageUtil().isLogged = false));
|
||||||
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 tester.pumpWidget(const App());
|
await _testSignUp();
|
||||||
late String name;
|
|
||||||
late String email;
|
|
||||||
late String password;
|
|
||||||
late Map<String, dynamic> credentials;
|
|
||||||
|
|
||||||
await _navigateToSignUp();
|
|
||||||
|
|
||||||
name = 'app';
|
|
||||||
email = 'email_app@exemplo.com';
|
|
||||||
password = '12345678';
|
|
||||||
credentials = {
|
|
||||||
'nameTextFormField': name,
|
|
||||||
'emailTextFormField': email,
|
|
||||||
'passwordTextFormField': password
|
|
||||||
};
|
|
||||||
await _auth(credentials);
|
|
||||||
|
|
||||||
|
|
||||||
name = randomString(7, 7, true, true, true);
|
|
||||||
email = '$name@example.com';
|
|
||||||
password = '12345678';
|
|
||||||
credentials = {
|
|
||||||
'nameTextFormField': name,
|
|
||||||
'emailTextFormField': email,
|
|
||||||
'passwordTextFormField': password
|
|
||||||
};
|
|
||||||
await _navigateToSignUp();
|
|
||||||
await _auth(credentials);
|
|
||||||
credentials = {
|
|
||||||
'emailTextFormField': email,
|
|
||||||
'passwordTextFormField': password
|
|
||||||
};
|
|
||||||
await _auth(credentials);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
group('Sign Out', () {
|
group('Sign Out', () {
|
||||||
// setUpAll(() async =>
|
// Add tests for Sign Out here
|
||||||
// await initializeApp().then((_) => StorageUtil().isLogged = false));
|
|
||||||
});
|
});
|
||||||
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;
|
||||||
late final String addr = randomString(5, 5, true, true, true);
|
await _testForgotPassword();
|
||||||
late Map<String, dynamic> credentials;
|
|
||||||
|
|
||||||
await tester.pumpWidget(const App());
|
|
||||||
|
|
||||||
await _navigateToSignIn();
|
|
||||||
|
|
||||||
await _recoveryPassword();
|
|
||||||
credentials = {'recoveryTextFormField': '$addr@exemple.com'};
|
|
||||||
await _send(credentials);
|
|
||||||
|
|
||||||
await Future.delayed(const Duration(seconds: 2));
|
|
||||||
|
|
||||||
await _recoveryPassword();
|
|
||||||
credentials = {'recoveryTextFormField': 'email_app@exemple.com'};
|
|
||||||
await _send(credentials);
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
group('Localization', () {
|
||||||
|
// Add tests for Localization here
|
||||||
|
|
||||||
group('Localization', (){
|
|
||||||
|
|
||||||
});
|
});
|
||||||
group('Networking', (){
|
group('Networking', () {
|
||||||
|
// Add tests for Networking here
|
||||||
});
|
});
|
||||||
group('Functionality', (){
|
group('Functionality', () {
|
||||||
|
// Add tests for Functionality here
|
||||||
});
|
});
|
||||||
group('Usability', (){
|
group('Usability', () {
|
||||||
|
// Add tests for Usability here
|
||||||
});
|
});
|
||||||
group('Performance', (){
|
group('Performance', () {
|
||||||
|
// Add tests for Performance here
|
||||||
});
|
});
|
||||||
group('Security', (){
|
group('Security', () {
|
||||||
|
// Add tests for Security here
|
||||||
});
|
});
|
||||||
group('Accessibility', (){
|
group('Accessibility', () {
|
||||||
|
// Add tests for Accessibility here
|
||||||
});
|
});
|
||||||
group('Compatibility', (){
|
group('Compatibility', () {
|
||||||
|
// Add tests for Compatibility here
|
||||||
});
|
});
|
||||||
group('Internationalization', (){
|
group('Internationalization', () {
|
||||||
|
// Add tests for Internationalization here
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _testWelcome() async {
|
||||||
|
await widget.pumpWidget(const App());
|
||||||
|
await widget.pumpAndSettle();
|
||||||
|
await _navigateToSignIn();
|
||||||
|
await _navigateToSignUp();
|
||||||
|
await widget.pumpAndSettle();
|
||||||
|
await widget.pumpWidget(const App());
|
||||||
|
await widget.pumpAndSettle();
|
||||||
|
await _navigateToSignUp();
|
||||||
|
await _navigateToSignIn();
|
||||||
|
await widget.pumpAndSettle();
|
||||||
|
}
|
||||||
|
Future<void> _testSignIn() async {
|
||||||
|
await widget.pumpWidget(const App());
|
||||||
|
await _navigateToSignIn();
|
||||||
|
await _auth({'emailTextFormField': 'erro@exemplo.com', 'passwordTextFormField': '12345678'});
|
||||||
|
await _auth({'emailTextFormField': 'email_app@exemplo.com', 'passwordTextFormField': '12345678'});
|
||||||
|
}
|
||||||
|
Future<void> _testSignUp() async {
|
||||||
|
await widget.pumpWidget(const App());
|
||||||
|
await _navigateToSignUp();
|
||||||
|
|
||||||
|
var credentials = {
|
||||||
|
'nameTextFormField': 'app',
|
||||||
|
'emailTextFormField': 'email_app@exemplo.com',
|
||||||
|
'passwordTextFormField': '12345678'
|
||||||
|
};
|
||||||
|
await _auth(credentials);
|
||||||
|
|
||||||
|
var name = randomString(7, 7, true, true, true);
|
||||||
|
var email = '$name@example.com';
|
||||||
|
var password = '12345678';
|
||||||
|
credentials = {
|
||||||
|
'nameTextFormField': name,
|
||||||
|
'emailTextFormField': email,
|
||||||
|
'passwordTextFormField': password
|
||||||
|
};
|
||||||
|
await _navigateToSignUp();
|
||||||
|
await _auth(credentials);
|
||||||
|
credentials = {
|
||||||
|
'emailTextFormField': email,
|
||||||
|
'passwordTextFormField': password
|
||||||
|
};
|
||||||
|
await _auth(credentials);
|
||||||
|
}
|
||||||
|
Future<void> _testForgotPassword() async {
|
||||||
|
await widget.pumpWidget(const App());
|
||||||
|
await _navigateToSignIn();
|
||||||
|
await _recoveryPassword();
|
||||||
|
|
||||||
|
var addr = randomString(5, 5, true, true, true);
|
||||||
|
var credentials = {'recoveryTextFormField': '$addr@exemple.com'};
|
||||||
|
await _send(credentials);
|
||||||
|
|
||||||
|
await Future.delayed(const Duration(seconds: 2));
|
||||||
|
|
||||||
|
await _recoveryPassword();
|
||||||
|
credentials = {'recoveryTextFormField': 'email_app@exemple.com'};
|
||||||
|
await _send(credentials);
|
||||||
|
}
|
||||||
|
Future<void> _recoveryPassword() async {
|
||||||
|
await widget.pumpAndSettle();
|
||||||
|
final Finder forgotPassword = find.byKey(const ValueKey<String>('ForgotPassword'));
|
||||||
|
if (forgotPassword.evaluate().isNotEmpty) await widget.tap(forgotPassword);
|
||||||
|
await widget.ensureVisible(forgotPassword);
|
||||||
|
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'));
|
||||||
|
@ -173,7 +159,6 @@ Future<void> _navigateToSignUp() async {
|
||||||
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'));
|
||||||
|
@ -184,32 +169,16 @@ Future<void> _navigateToSignIn() async {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _recoveryPassword() async {
|
|
||||||
await widget.pumpAndSettle();
|
|
||||||
final Finder forgotPassword = find.byKey(const ValueKey<String>('ForgotPassword'));
|
|
||||||
if (forgotPassword.evaluate().isNotEmpty) await widget.tap(forgotPassword);
|
|
||||||
await widget.ensureVisible(forgotPassword);
|
|
||||||
await widget.pumpAndSettle();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Future<void> _auth(Map<String, dynamic> credentials) async {
|
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) {
|
||||||
final Finder field = find.byKey(ValueKey<String>(entry.key));
|
final Finder field = find.byKey(ValueKey<String>(entry.key));
|
||||||
await widget.pumpAndSettle();
|
await widget.pumpAndSettle();
|
||||||
|
@ -217,10 +186,8 @@ Future<void> _enterCredentials(Map<String, dynamic> credentials) async {
|
||||||
await widget.enterText(field, entry.value);
|
await widget.enterText(field, entry.value);
|
||||||
await widget.pumpAndSettle();
|
await widget.pumpAndSettle();
|
||||||
}
|
}
|
||||||
|
|
||||||
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));
|
||||||
|
@ -230,19 +197,13 @@ 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);
|
||||||
await widget.tap(ThrowExceptionWidget);
|
await widget.tap(throwExceptionWidget);
|
||||||
await widget.pumpAndSettle();
|
await widget.pumpAndSettle();
|
||||||
} else {
|
} else {
|
||||||
await _navigateBackUsingSystemGesture();
|
await _navigateBackUsingSystemGesture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue