forked from eatvio/eatvio_app
chore(version): update app version to 1.3.5+85 and improve test coverage reporting in CI
This commit is contained in:
@@ -0,0 +1,165 @@
|
||||
import 'package:eatvio_app/core/prefs.dart';
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/features/registration/models/user_registration_model.dart';
|
||||
import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart';
|
||||
import 'package:eatvio_app/features/registration/presentation/pages/blood_pressure_screen.dart';
|
||||
import 'package:eatvio_app/features/registration/repositories/registration_repository.dart';
|
||||
import 'package:eatvio_app/generated/l10n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
|
||||
import 'blood_pressure_screen_test.mocks.dart';
|
||||
|
||||
@GenerateMocks([RegistrationRepository, Prefs])
|
||||
void main() {
|
||||
group('BloodPressureScreen', () {
|
||||
late MockRegistrationRepository mockRegistrationRepository;
|
||||
late MockPrefs mockPrefs;
|
||||
late RegistrationCubit registrationCubit;
|
||||
|
||||
setUp(() {
|
||||
mockRegistrationRepository = MockRegistrationRepository();
|
||||
mockPrefs = MockPrefs();
|
||||
registrationCubit = RegistrationCubit(
|
||||
registrationRepository: mockRegistrationRepository,
|
||||
prefs: mockPrefs,
|
||||
);
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
registrationCubit.close();
|
||||
});
|
||||
|
||||
Widget createTestWidget(UserRegistrationSheet sheet) {
|
||||
return MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
localizationsDelegates: [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: const [Locale('ru'), Locale('en')],
|
||||
locale: const Locale('ru'),
|
||||
home: BlocProvider<RegistrationCubit>.value(
|
||||
value: registrationCubit,
|
||||
child: Scaffold(
|
||||
body: BloodPressureScreen(sheet: sheet),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('displays blood pressure screen', (tester) async {
|
||||
final sheet = UserRegistrationSheet(
|
||||
firstName: 'Test',
|
||||
lastName: 'User',
|
||||
email: 'test@example.com',
|
||||
password: 'password',
|
||||
passwordConfirmation: 'password',
|
||||
birthdate: '',
|
||||
gender: 'male',
|
||||
location: '',
|
||||
responseBody: '{}',
|
||||
lang: 'ru',
|
||||
weight: 70,
|
||||
height: 175,
|
||||
phone: '',
|
||||
chestCircumference: 90,
|
||||
waistCircumference: 80,
|
||||
hipCircumference: 95,
|
||||
bloodPressureUp: 0,
|
||||
bloodPressureDown: 0,
|
||||
hasHypo: 0,
|
||||
hasHyper: 0,
|
||||
aboutAllergy: '',
|
||||
aboutTakingPils: '',
|
||||
aboutSportHobbies: '',
|
||||
favoriteFoods: '',
|
||||
unfavoriteFoods: '',
|
||||
additionalInfo: '',
|
||||
);
|
||||
|
||||
await tester.pumpWidget(createTestWidget(sheet));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(BloodPressureScreen), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('displays existing blood pressure values', (tester) async {
|
||||
final sheet = UserRegistrationSheet(
|
||||
firstName: 'Test',
|
||||
lastName: 'User',
|
||||
email: 'test@example.com',
|
||||
password: 'password',
|
||||
passwordConfirmation: 'password',
|
||||
birthdate: '',
|
||||
gender: 'male',
|
||||
location: '',
|
||||
responseBody: '{}',
|
||||
lang: 'ru',
|
||||
weight: 70,
|
||||
height: 175,
|
||||
phone: '',
|
||||
chestCircumference: 90,
|
||||
waistCircumference: 80,
|
||||
hipCircumference: 95,
|
||||
bloodPressureUp: 120,
|
||||
bloodPressureDown: 80,
|
||||
hasHypo: 0,
|
||||
hasHyper: 0,
|
||||
aboutAllergy: '',
|
||||
aboutTakingPils: '',
|
||||
aboutSportHobbies: '',
|
||||
favoriteFoods: '',
|
||||
unfavoriteFoods: '',
|
||||
additionalInfo: '',
|
||||
);
|
||||
|
||||
await tester.pumpWidget(createTestWidget(sheet));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(BloodPressureScreen), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('displays dropdowns for hypo and hyper', (tester) async {
|
||||
final sheet = UserRegistrationSheet(
|
||||
firstName: 'Test',
|
||||
lastName: 'User',
|
||||
email: 'test@example.com',
|
||||
password: 'password',
|
||||
passwordConfirmation: 'password',
|
||||
birthdate: '',
|
||||
gender: 'male',
|
||||
location: '',
|
||||
responseBody: '{}',
|
||||
lang: 'ru',
|
||||
weight: 70,
|
||||
height: 175,
|
||||
phone: '',
|
||||
chestCircumference: 90,
|
||||
waistCircumference: 80,
|
||||
hipCircumference: 95,
|
||||
bloodPressureUp: 0,
|
||||
bloodPressureDown: 0,
|
||||
hasHypo: 1,
|
||||
hasHyper: 1,
|
||||
aboutAllergy: '',
|
||||
aboutTakingPils: '',
|
||||
aboutSportHobbies: '',
|
||||
favoriteFoods: '',
|
||||
unfavoriteFoods: '',
|
||||
additionalInfo: '',
|
||||
);
|
||||
|
||||
await tester.pumpWidget(createTestWidget(sheet));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(BloodPressureScreen), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
import 'package:eatvio_app/core/prefs.dart';
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/features/registration/models/user_registration_model.dart';
|
||||
import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart';
|
||||
import 'package:eatvio_app/features/registration/presentation/pages/credentials_screen.dart';
|
||||
import 'package:eatvio_app/features/registration/repositories/registration_repository.dart';
|
||||
import 'package:eatvio_app/generated/l10n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
|
||||
import 'credentials_screen_test.mocks.dart';
|
||||
|
||||
@GenerateMocks([RegistrationRepository, Prefs])
|
||||
void main() {
|
||||
group('CredentialsScreen', () {
|
||||
late MockRegistrationRepository mockRegistrationRepository;
|
||||
late MockPrefs mockPrefs;
|
||||
late RegistrationCubit registrationCubit;
|
||||
|
||||
setUp(() {
|
||||
mockRegistrationRepository = MockRegistrationRepository();
|
||||
mockPrefs = MockPrefs();
|
||||
registrationCubit = RegistrationCubit(
|
||||
registrationRepository: mockRegistrationRepository,
|
||||
prefs: mockPrefs,
|
||||
);
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
registrationCubit.close();
|
||||
});
|
||||
|
||||
Widget createTestWidget(UserRegistrationSheet sheet) {
|
||||
return MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
localizationsDelegates: [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: const [Locale('ru'), Locale('en')],
|
||||
locale: const Locale('ru'),
|
||||
home: BlocProvider<RegistrationCubit>.value(
|
||||
value: registrationCubit,
|
||||
child: Scaffold(
|
||||
body: CredentialsScreen(sheet: sheet),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('displays email field', (tester) async {
|
||||
final sheet = UserRegistrationSheet(
|
||||
firstName: 'Test',
|
||||
lastName: 'User',
|
||||
email: '',
|
||||
password: '',
|
||||
passwordConfirmation: '',
|
||||
birthdate: '',
|
||||
gender: 'male',
|
||||
location: '',
|
||||
responseBody: '{}',
|
||||
lang: 'ru',
|
||||
weight: 70,
|
||||
height: 175,
|
||||
phone: '',
|
||||
chestCircumference: 90,
|
||||
waistCircumference: 80,
|
||||
hipCircumference: 95,
|
||||
bloodPressureUp: 0,
|
||||
bloodPressureDown: 0,
|
||||
hasHypo: 0,
|
||||
hasHyper: 0,
|
||||
aboutAllergy: '',
|
||||
aboutTakingPils: '',
|
||||
aboutSportHobbies: '',
|
||||
favoriteFoods: '',
|
||||
unfavoriteFoods: '',
|
||||
additionalInfo: '',
|
||||
);
|
||||
|
||||
await tester.pumpWidget(createTestWidget(sheet));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(CredentialsScreen), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('displays password fields', (tester) async {
|
||||
final sheet = UserRegistrationSheet(
|
||||
firstName: 'Test',
|
||||
lastName: 'User',
|
||||
email: 'test@example.com',
|
||||
password: '',
|
||||
passwordConfirmation: '',
|
||||
birthdate: '',
|
||||
gender: 'male',
|
||||
location: '',
|
||||
responseBody: '{}',
|
||||
lang: 'ru',
|
||||
weight: 70,
|
||||
height: 175,
|
||||
phone: '',
|
||||
chestCircumference: 90,
|
||||
waistCircumference: 80,
|
||||
hipCircumference: 95,
|
||||
bloodPressureUp: 0,
|
||||
bloodPressureDown: 0,
|
||||
hasHypo: 0,
|
||||
hasHyper: 0,
|
||||
aboutAllergy: '',
|
||||
aboutTakingPils: '',
|
||||
aboutSportHobbies: '',
|
||||
favoriteFoods: '',
|
||||
unfavoriteFoods: '',
|
||||
additionalInfo: '',
|
||||
);
|
||||
|
||||
await tester.pumpWidget(createTestWidget(sheet));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(CredentialsScreen), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('initializes with existing values', (tester) async {
|
||||
final sheet = UserRegistrationSheet(
|
||||
firstName: 'Test',
|
||||
lastName: 'User',
|
||||
email: 'test@example.com',
|
||||
password: 'password123',
|
||||
passwordConfirmation: 'password123',
|
||||
birthdate: '',
|
||||
gender: 'male',
|
||||
location: '',
|
||||
responseBody: '{}',
|
||||
lang: 'ru',
|
||||
weight: 70,
|
||||
height: 175,
|
||||
phone: '',
|
||||
chestCircumference: 90,
|
||||
waistCircumference: 80,
|
||||
hipCircumference: 95,
|
||||
bloodPressureUp: 0,
|
||||
bloodPressureDown: 0,
|
||||
hasHypo: 0,
|
||||
hasHyper: 0,
|
||||
aboutAllergy: '',
|
||||
aboutTakingPils: '',
|
||||
aboutSportHobbies: '',
|
||||
favoriteFoods: '',
|
||||
unfavoriteFoods: '',
|
||||
additionalInfo: '',
|
||||
);
|
||||
|
||||
await tester.pumpWidget(createTestWidget(sheet));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(CredentialsScreen), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
import 'package:eatvio_app/core/prefs.dart';
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/features/registration/models/user_registration_model.dart';
|
||||
import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart';
|
||||
import 'package:eatvio_app/features/registration/presentation/pages/date_of_birth_screen.dart';
|
||||
import 'package:eatvio_app/features/registration/repositories/registration_repository.dart';
|
||||
import 'package:eatvio_app/generated/l10n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
|
||||
import 'date_of_birth_screen_test.mocks.dart';
|
||||
|
||||
@GenerateMocks([RegistrationRepository, Prefs])
|
||||
void main() {
|
||||
group('DateOfBirthScreen', () {
|
||||
late MockRegistrationRepository mockRegistrationRepository;
|
||||
late MockPrefs mockPrefs;
|
||||
late RegistrationCubit registrationCubit;
|
||||
|
||||
setUp(() {
|
||||
mockRegistrationRepository = MockRegistrationRepository();
|
||||
mockPrefs = MockPrefs();
|
||||
registrationCubit = RegistrationCubit(
|
||||
registrationRepository: mockRegistrationRepository,
|
||||
prefs: mockPrefs,
|
||||
);
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
registrationCubit.close();
|
||||
});
|
||||
|
||||
Widget createTestWidget(UserRegistrationSheet sheet) {
|
||||
return MaterialApp(
|
||||
theme: ThemeHelper().themeData(),
|
||||
localizationsDelegates: [
|
||||
S.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: const [Locale('ru'), Locale('en')],
|
||||
locale: const Locale('ru'),
|
||||
home: BlocProvider<RegistrationCubit>.value(
|
||||
value: registrationCubit,
|
||||
child: Scaffold(
|
||||
body: DateOfBirthScreen(sheet: sheet),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('displays date of birth screen', (tester) async {
|
||||
final sheet = UserRegistrationSheet(
|
||||
firstName: 'Test',
|
||||
lastName: 'User',
|
||||
email: 'test@example.com',
|
||||
password: 'password',
|
||||
passwordConfirmation: 'password',
|
||||
birthdate: '',
|
||||
gender: 'male',
|
||||
location: '',
|
||||
responseBody: '{}',
|
||||
lang: 'ru',
|
||||
weight: 70,
|
||||
height: 175,
|
||||
phone: '',
|
||||
chestCircumference: 90,
|
||||
waistCircumference: 80,
|
||||
hipCircumference: 95,
|
||||
bloodPressureUp: 0,
|
||||
bloodPressureDown: 0,
|
||||
hasHypo: 0,
|
||||
hasHyper: 0,
|
||||
aboutAllergy: '',
|
||||
aboutTakingPils: '',
|
||||
aboutSportHobbies: '',
|
||||
favoriteFoods: '',
|
||||
unfavoriteFoods: '',
|
||||
additionalInfo: '',
|
||||
);
|
||||
|
||||
await tester.pumpWidget(createTestWidget(sheet));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(DateOfBirthScreen), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('displays existing birthdate when provided', (tester) async {
|
||||
final sheet = UserRegistrationSheet(
|
||||
firstName: 'Test',
|
||||
lastName: 'User',
|
||||
email: 'test@example.com',
|
||||
password: 'password',
|
||||
passwordConfirmation: 'password',
|
||||
birthdate: '2000-01-01',
|
||||
gender: 'male',
|
||||
location: '',
|
||||
responseBody: '{}',
|
||||
lang: 'ru',
|
||||
weight: 70,
|
||||
height: 175,
|
||||
phone: '',
|
||||
chestCircumference: 90,
|
||||
waistCircumference: 80,
|
||||
hipCircumference: 95,
|
||||
bloodPressureUp: 0,
|
||||
bloodPressureDown: 0,
|
||||
hasHypo: 0,
|
||||
hasHyper: 0,
|
||||
aboutAllergy: '',
|
||||
aboutTakingPils: '',
|
||||
aboutSportHobbies: '',
|
||||
favoriteFoods: '',
|
||||
unfavoriteFoods: '',
|
||||
additionalInfo: '',
|
||||
);
|
||||
|
||||
await tester.pumpWidget(createTestWidget(sheet));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(DateOfBirthScreen), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('displays calendar icon', (tester) async {
|
||||
final sheet = UserRegistrationSheet(
|
||||
firstName: 'Test',
|
||||
lastName: 'User',
|
||||
email: 'test@example.com',
|
||||
password: 'password',
|
||||
passwordConfirmation: 'password',
|
||||
birthdate: '',
|
||||
gender: 'male',
|
||||
location: '',
|
||||
responseBody: '{}',
|
||||
lang: 'ru',
|
||||
weight: 70,
|
||||
height: 175,
|
||||
phone: '',
|
||||
chestCircumference: 90,
|
||||
waistCircumference: 80,
|
||||
hipCircumference: 95,
|
||||
bloodPressureUp: 0,
|
||||
bloodPressureDown: 0,
|
||||
hasHypo: 0,
|
||||
hasHyper: 0,
|
||||
aboutAllergy: '',
|
||||
aboutTakingPils: '',
|
||||
aboutSportHobbies: '',
|
||||
favoriteFoods: '',
|
||||
unfavoriteFoods: '',
|
||||
additionalInfo: '',
|
||||
);
|
||||
|
||||
await tester.pumpWidget(createTestWidget(sheet));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byIcon(Icons.calendar_month_rounded), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user