forked from eatvio/eatvio_app
feat(registration): added email verification, feat(diary): fixed moderation request, feat(oauth): fixed email and phone verification
This commit is contained in:
@@ -1,28 +1,42 @@
|
||||
// ignore_for_file: deprecated_member_use
|
||||
|
||||
import 'package:eatvio_app/app_keys.dart';
|
||||
import 'package:eatvio_app/core/firebase_api.dart';
|
||||
import 'package:eatvio_app/core/prefs.dart';
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/features/auth/models/token_model.dart';
|
||||
import 'package:eatvio_app/features/auth/presentation/bloc/auth_cubit/auth_cubit.dart';
|
||||
import 'package:eatvio_app/features/profile/repositories/profile_repository.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../../../fixtures/doubles/auth_doubles.dart';
|
||||
import '../../../../fixtures/doubles/profile_doubles.dart';
|
||||
import '../../../../fixtures/fixture_reader.dart';
|
||||
import 'basic_widget_test.mocks.dart';
|
||||
|
||||
@GenerateNiceMocks([MockSpec<Prefs>(), MockSpec<FirebaseApi>(), MockSpec<ProfileRepository>()])
|
||||
void main() {
|
||||
group('Auth Basic Widget Tests', () {
|
||||
late FixtureAuthRepository authRepository;
|
||||
late FixtureProfileRepository profileRepository;
|
||||
late MockPrefs mockPrefs;
|
||||
late MockFirebaseApi mockFirebaseApi;
|
||||
late AuthCubit authCubit;
|
||||
late Map<String, dynamic> credentialsFixture;
|
||||
|
||||
setUp(() {
|
||||
setUp(() async {
|
||||
credentialsFixture = FixtureReader.readAsMap('auth/login_credentials.json');
|
||||
authRepository = FixtureAuthRepository(
|
||||
tokenFixture: TokenModel.fromJson(FixtureReader.readAsMap('auth/token_response.json')),
|
||||
);
|
||||
authCubit = AuthCubit(authRepository: authRepository);
|
||||
authRepository = FixtureAuthRepository(tokenFixture: TokenModel.fromJson(FixtureReader.readAsMap('auth/token_response.json')));
|
||||
profileRepository = FixtureProfileRepository();
|
||||
mockPrefs = MockPrefs();
|
||||
mockFirebaseApi = MockFirebaseApi();
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
|
||||
authCubit = AuthCubit(authRepository: authRepository, prefs: mockPrefs, profileRepository: profileRepository, firebaseApi: mockFirebaseApi);
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
@@ -41,7 +55,7 @@ void main() {
|
||||
|
||||
testWidgets('should create AuthCubit successfully', (WidgetTester tester) async {
|
||||
// Arrange & Act
|
||||
final cubit = AuthCubit(authRepository: authRepository);
|
||||
final cubit = AuthCubit(authRepository: authRepository, prefs: mockPrefs, profileRepository: profileRepository, firebaseApi: mockFirebaseApi);
|
||||
|
||||
// Assert
|
||||
expect(cubit, isA<AuthCubit>());
|
||||
@@ -83,11 +97,7 @@ void main() {
|
||||
|
||||
testWidgets('should display sign in button', (WidgetTester tester) async {
|
||||
// Arrange
|
||||
Widget buttonWidget = FloatingActionButton.extended(
|
||||
key: AppKeys.signInButtonAuthScreen,
|
||||
onPressed: () {},
|
||||
label: const Text('Войти'),
|
||||
);
|
||||
Widget buttonWidget = FloatingActionButton.extended(key: AppKeys.signInButtonAuthScreen, onPressed: () {}, label: const Text('Войти'));
|
||||
|
||||
// Act
|
||||
await tester.pumpWidget(createTestWidget(buttonWidget));
|
||||
@@ -156,11 +166,7 @@ void main() {
|
||||
obscureText: true,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
FloatingActionButton.extended(
|
||||
key: AppKeys.signInButtonAuthScreen,
|
||||
onPressed: () {},
|
||||
label: const Text('Войти'),
|
||||
),
|
||||
FloatingActionButton.extended(key: AppKeys.signInButtonAuthScreen, onPressed: () {}, label: const Text('Войти')),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -227,10 +233,7 @@ void main() {
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Пароль',
|
||||
hintText: 'Введите пароль',
|
||||
suffix: IconButton(
|
||||
onPressed: null,
|
||||
icon: Icon(Icons.visibility_outlined),
|
||||
),
|
||||
suffix: IconButton(onPressed: null, icon: Icon(Icons.visibility_outlined)),
|
||||
),
|
||||
obscureText: true,
|
||||
);
|
||||
@@ -246,10 +249,7 @@ void main() {
|
||||
// Arrange
|
||||
Widget forgotPasswordWidget = GestureDetector(
|
||||
onTap: () {},
|
||||
child: const Text(
|
||||
'Забыли пароль?',
|
||||
style: TextStyle(decoration: TextDecoration.underline),
|
||||
),
|
||||
child: const Text('Забыли пароль?', style: TextStyle(decoration: TextDecoration.underline)),
|
||||
);
|
||||
|
||||
// Act
|
||||
@@ -267,10 +267,7 @@ void main() {
|
||||
const Text('Нет аккаунта? '),
|
||||
GestureDetector(
|
||||
onTap: () {},
|
||||
child: const Text(
|
||||
'Зарегистрироваться',
|
||||
style: TextStyle(decoration: TextDecoration.underline),
|
||||
),
|
||||
child: const Text('Зарегистрироваться', style: TextStyle(decoration: TextDecoration.underline)),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -336,11 +333,7 @@ void main() {
|
||||
// Arrange
|
||||
Widget emailWidget = TextFormField(
|
||||
key: AppKeys.emailTextFieldAuthScreen,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Email',
|
||||
hintText: 'Введите email',
|
||||
errorText: 'Введите корректный email',
|
||||
),
|
||||
decoration: const InputDecoration(labelText: 'Email', hintText: 'Введите email', errorText: 'Введите корректный email'),
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
);
|
||||
|
||||
@@ -371,12 +364,7 @@ void main() {
|
||||
|
||||
testWidgets('should display form labels correctly', (WidgetTester tester) async {
|
||||
// Arrange
|
||||
Widget formWidget = const Column(
|
||||
children: [
|
||||
Text('Email'),
|
||||
Text('Пароль'),
|
||||
],
|
||||
);
|
||||
Widget formWidget = const Column(children: [Text('Email'), Text('Пароль')]);
|
||||
|
||||
// Act
|
||||
await tester.pumpWidget(createTestWidget(formWidget));
|
||||
@@ -413,4 +401,3 @@ void main() {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user