Merge pull request 'chore: update Flutter version in CI workflow from 3.38.1 to 3.38.5' (#831) from mso7nueh/eatvio_app:main into main

Reviewed-on: eatvio/eatvio_app#831
This commit is contained in:
mso7nueh
2025-12-25 12:55:49 +00:00
43 changed files with 4729 additions and 4565 deletions

View File

@@ -3,7 +3,7 @@ name: Eatvio App Android Test
on: [ pull_request ]
env:
flutter_version: "3.38.1"
flutter_version: "3.38.5"
java_version: "21.x"
flutter_channel: "stable"
my_local_cache_dir: "/opt/hostedtoolcache/"

View File

@@ -1,29 +1,33 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'oauth_verification_confirm_response.freezed.dart';
part 'oauth_verification_confirm_response.g.dart';
@freezed
abstract class OAuthVerificationConfirmResponse with _$OAuthVerificationConfirmResponse {
const factory OAuthVerificationConfirmResponse({
required bool success,
required String message,
required String token,
required Map<String, dynamic> user,
@JsonKey(name: 'is_new_user') required bool isNewUser,
}) = _OAuthVerificationConfirmResponse;
factory OAuthVerificationConfirmResponse.fromJson(Map<String, dynamic> json) => _$OAuthVerificationConfirmResponseFromJson(json);
}
import 'package:freezed_annotation/freezed_annotation.dart';
part 'oauth_verification_confirm_response.freezed.dart';
part 'oauth_verification_confirm_response.g.dart';
@freezed
abstract class OAuthVerificationConfirmResponse with _$OAuthVerificationConfirmResponse {
const factory OAuthVerificationConfirmResponse({
required bool success,
required String message,
required String token,
required Map<String, dynamic> user,
@JsonKey(name: 'is_new_user') required bool isNewUser,
}) = _OAuthVerificationConfirmResponse;
factory OAuthVerificationConfirmResponse.fromJson(Map<String, dynamic> json) => _$OAuthVerificationConfirmResponseFromJson(json);
}

View File

@@ -1,23 +1,27 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'oauth_verification_request.freezed.dart';
part 'oauth_verification_request.g.dart';
@freezed
abstract class OAuthVerificationRequest with _$OAuthVerificationRequest {
const factory OAuthVerificationRequest({String? email, String? phone}) = _OAuthVerificationRequest;
factory OAuthVerificationRequest.fromJson(Map<String, dynamic> json) => _$OAuthVerificationRequestFromJson(json);
}
import 'package:freezed_annotation/freezed_annotation.dart';
part 'oauth_verification_request.freezed.dart';
part 'oauth_verification_request.g.dart';
@freezed
abstract class OAuthVerificationRequest with _$OAuthVerificationRequest {
const factory OAuthVerificationRequest({String? email, String? phone}) = _OAuthVerificationRequest;
factory OAuthVerificationRequest.fromJson(Map<String, dynamic> json) => _$OAuthVerificationRequestFromJson(json);
}

View File

@@ -1,23 +1,27 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'oauth_verification_request_response.freezed.dart';
part 'oauth_verification_request_response.g.dart';
@freezed
abstract class OAuthVerificationRequestResponse with _$OAuthVerificationRequestResponse {
const factory OAuthVerificationRequestResponse({required String email, required String status}) = _OAuthVerificationRequestResponse;
factory OAuthVerificationRequestResponse.fromJson(Map<String, dynamic> json) => _$OAuthVerificationRequestResponseFromJson(json);
}
import 'package:freezed_annotation/freezed_annotation.dart';
part 'oauth_verification_request_response.freezed.dart';
part 'oauth_verification_request_response.g.dart';
@freezed
abstract class OAuthVerificationRequestResponse with _$OAuthVerificationRequestResponse {
const factory OAuthVerificationRequestResponse({required String email, required String status}) = _OAuthVerificationRequestResponse;
factory OAuthVerificationRequestResponse.fromJson(Map<String, dynamic> json) => _$OAuthVerificationRequestResponseFromJson(json);
}

View File

@@ -1,17 +1,21 @@
import 'package:dio/dio.dart';
import 'package:eatvio_app/features/barcode/models/barcode_product_model.dart';
import 'package:retrofit/retrofit.dart';
part 'barcode_service.g.dart';
@RestApi()
abstract class BarcodeService {
factory BarcodeService(Dio dio, {String baseUrl}) = _BarcodeService;
@GET('/api/gsone/barcode/{barcode}')
Future<BarcodeProductModel> getProductByBarcode({@Path('barcode') required String barcode});
@GET('/api/gsone/barcode/status/{task_id}')
Future<BarcodeTaskStatusModel> getTaskStatus({@Path('task_id') required String taskId});
}
import 'package:dio/dio.dart';
import 'package:eatvio_app/features/barcode/models/barcode_product_model.dart';
import 'package:retrofit/retrofit.dart';
part 'barcode_service.g.dart';
@RestApi()
abstract class BarcodeService {
factory BarcodeService(Dio dio, {String baseUrl}) = _BarcodeService;
@GET('/api/gsone/barcode/{barcode}')
Future<BarcodeProductModel> getProductByBarcode({@Path('barcode') required String barcode});
@GET('/api/gsone/barcode/status/{task_id}')
Future<BarcodeTaskStatusModel> getTaskStatus({@Path('task_id') required String taskId});
}

View File

@@ -1,176 +1,178 @@
import 'package:eatvio_app/core/theme/custom_text_style.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/utils/date_time_utils.dart';
import 'package:eatvio_app/core/widgets/custom_outlined_button.dart';
import 'package:eatvio_app/core/widgets/custom_text_form_field.dart';
import 'package:eatvio_app/features/create_diet/presentation/widgets/error_widget.dart';
import 'package:eatvio_app/features/registration_v2/cubit/registration_cubit.dart';
import 'package:eatvio_app/features/registration_v2/cubit/registration_state.dart';
import 'package:eatvio_app/features/registration_v2/presentation/widgets/sex_widget.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:mask_text_input_formatter/mask_text_input_formatter.dart';
class FirstStepContent extends StatefulWidget {
const FirstStepContent({super.key});
@override
State<FirstStepContent> createState() => _FirstStepContentState();
}
class _FirstStepContentState extends State<FirstStepContent> {
final maskFormatterForBirthday = MaskTextInputFormatter(mask: '##.##.####', filter: {"#": RegExp(r'[0-9]')}, type: MaskAutoCompletionType.lazy);
final firstNameController = TextEditingController();
final lastNameController = TextEditingController();
final emailController = TextEditingController();
final phoneController = TextEditingController();
final dateController = TextEditingController();
@override
void initState() {
super.initState();
firstNameController.text = context.read<RegistrationCubitV2>().state.firstName;
lastNameController.text = context.read<RegistrationCubitV2>().state.lastName;
emailController.text = context.read<RegistrationCubitV2>().state.email;
phoneController.text = context.read<RegistrationCubitV2>().state.phone;
dateController.text = context.read<RegistrationCubitV2>().state.birthday?.format('dd.MM.yyyy') ?? '';
}
@override
Widget build(BuildContext context) {
final s = S.of(context);
return BlocBuilder<RegistrationCubitV2, RegistrationStateV2>(
builder: (context, state) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(s.first_name, style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
const SizedBox(height: 4),
CustomTextFormField(
hintText: s.your_name,
hasError: !state.isFirstNameValid,
controller: firstNameController,
onChanged: (val) {
context.read<RegistrationCubitV2>().setFirstName(val);
},
),
if (!state.isFirstNameValid) ...[const SizedBox(height: 4), ValidationErrorWidget(error: s.first_name_validation_error)],
],
),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(s.last_name, style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
const SizedBox(height: 4),
CustomTextFormField(
hintText: s.your_last_name,
hasError: !state.isLastNameValid,
controller: lastNameController,
onChanged: (val) {
context.read<RegistrationCubitV2>().setLastName(val);
},
),
if (!state.isLastNameValid) ...[const SizedBox(height: 4), ValidationErrorWidget(error: s.last_name_error)],
],
),
),
],
),
const SizedBox(height: 12),
Text(s.email, style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
CustomTextFormField(
hintText: s.type_email,
hasError: !state.isEmailValid,
controller: emailController,
onChanged: (val) {
context.read<RegistrationCubitV2>().setEmail(val);
},
),
if (!state.isEmailValid) ...[
const SizedBox(height: 4),
ValidationErrorWidget(error: state.emailDisplayError.isEmpty ? s.email_error : state.emailDisplayError),
],
const SizedBox(height: 12),
Text(s.phone, style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
Column(
children: [
CustomTextFormField(
hintText: '+7 (999) 999 99 99',
controller: phoneController,
hasError: !state.isPhoneValid,
onChanged: (val) {
context.read<RegistrationCubitV2>().setPhone(val);
},
),
if (!state.isPhoneValid) ...[
const SizedBox(height: 4),
ValidationErrorWidget(error: state.phoneDisplayError.isEmpty ? s.phone_error : state.phoneDisplayError),
],
],
),
const SizedBox(height: 12),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(s.date_of_birth, style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
const SizedBox(height: 4),
CustomTextFormField(
textInputAction: TextInputAction.done,
hintText: '01.01.2000',
keyboardType: TextInputType.number,
inputFormatters: [maskFormatterForBirthday],
hasError: !state.isBirthdayValid,
controller: dateController,
onChanged: (val) {
final dateArray = val.split('.');
if (dateArray.length != 3) return;
final date = DateTime(int.parse(dateArray[2]), int.parse(dateArray[1]), int.parse(dateArray[0]));
context.read<RegistrationCubitV2>().setBirthday(date);
},
),
if (!state.isBirthdayValid) ...[
const SizedBox(height: 4),
ValidationErrorWidget(error: state.dateOfBirthDisplayError.isEmpty ? s.date_of_birth_error : state.dateOfBirthDisplayError),
],
],
),
),
const SizedBox(width: 12),
const Expanded(child: SexWidget()),
],
),
const Spacer(),
CustomOutlinedButton(
onPressed: () {
context.read<RegistrationCubitV2>().nextStep();
},
text: s.next,
height: 52,
buttonTextStyle: TextStyles.textSSemibold.copyWith(color: appTheme.whiteA700),
buttonStyle: ButtonStyle(side: const WidgetStatePropertyAll(BorderSide.none), backgroundColor: WidgetStatePropertyAll(appTheme.blueA400)),
),
const SizedBox(height: 20),
],
);
},
);
}
}
import 'package:eatvio_app/core/theme/custom_text_style.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/utils/date_time_utils.dart';
import 'package:eatvio_app/core/widgets/custom_outlined_button.dart';
import 'package:eatvio_app/core/widgets/custom_text_form_field.dart';
import 'package:eatvio_app/features/create_diet/presentation/widgets/error_widget.dart';
import 'package:eatvio_app/features/registration_v2/cubit/registration_cubit.dart';
import 'package:eatvio_app/features/registration_v2/cubit/registration_state.dart';
import 'package:eatvio_app/features/registration_v2/presentation/widgets/sex_widget.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:mask_text_input_formatter/mask_text_input_formatter.dart';
class FirstStepContent extends StatefulWidget {
const FirstStepContent({super.key});
@override
State<FirstStepContent> createState() => _FirstStepContentState();
}
class _FirstStepContentState extends State<FirstStepContent> {
final maskFormatterForBirthday = MaskTextInputFormatter(mask: '##.##.####', filter: {"#": RegExp(r'[0-9]')}, type: MaskAutoCompletionType.lazy);
final firstNameController = TextEditingController();
final lastNameController = TextEditingController();
final emailController = TextEditingController();
final phoneController = TextEditingController();
final dateController = TextEditingController();
@override
void initState() {
super.initState();
firstNameController.text = context.read<RegistrationCubitV2>().state.firstName;
lastNameController.text = context.read<RegistrationCubitV2>().state.lastName;
emailController.text = context.read<RegistrationCubitV2>().state.email;
phoneController.text = context.read<RegistrationCubitV2>().state.phone;
dateController.text = context.read<RegistrationCubitV2>().state.birthday?.format('dd.MM.yyyy') ?? '';
}
@override
Widget build(BuildContext context) {
final s = S.of(context);
return BlocBuilder<RegistrationCubitV2, RegistrationStateV2>(
builder: (context, state) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(s.first_name, style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
const SizedBox(height: 4),
CustomTextFormField(
hintText: s.your_name,
hasError: !state.isFirstNameValid,
controller: firstNameController,
onChanged: (val) {
context.read<RegistrationCubitV2>().setFirstName(val);
},
),
if (!state.isFirstNameValid) ...[const SizedBox(height: 4), ValidationErrorWidget(error: s.first_name_validation_error)],
],
),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(s.last_name, style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
const SizedBox(height: 4),
CustomTextFormField(
hintText: s.your_last_name,
hasError: !state.isLastNameValid,
controller: lastNameController,
onChanged: (val) {
context.read<RegistrationCubitV2>().setLastName(val);
},
),
if (!state.isLastNameValid) ...[const SizedBox(height: 4), ValidationErrorWidget(error: s.last_name_error)],
],
),
),
],
),
const SizedBox(height: 12),
Text(s.email, style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
CustomTextFormField(
hintText: s.type_email,
hasError: !state.isEmailValid,
keyboardType: TextInputType.emailAddress,
controller: emailController,
onChanged: (val) {
context.read<RegistrationCubitV2>().setEmail(val);
},
),
if (!state.isEmailValid) ...[
const SizedBox(height: 4),
ValidationErrorWidget(error: state.emailDisplayError.isEmpty ? s.email_error : state.emailDisplayError),
],
const SizedBox(height: 12),
Text(s.phone, style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
Column(
children: [
CustomTextFormField(
hintText: '+7 (999) 999 99 99',
controller: phoneController,
hasError: !state.isPhoneValid,
keyboardType: TextInputType.phone,
onChanged: (val) {
context.read<RegistrationCubitV2>().setPhone(val);
},
),
if (!state.isPhoneValid) ...[
const SizedBox(height: 4),
ValidationErrorWidget(error: state.phoneDisplayError.isEmpty ? s.phone_error : state.phoneDisplayError),
],
],
),
const SizedBox(height: 12),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(s.date_of_birth, style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
const SizedBox(height: 4),
CustomTextFormField(
textInputAction: TextInputAction.done,
hintText: '01.01.2000',
keyboardType: TextInputType.number,
inputFormatters: [maskFormatterForBirthday],
hasError: !state.isBirthdayValid,
controller: dateController,
onChanged: (val) {
final dateArray = val.split('.');
if (dateArray.length != 3) return;
final date = DateTime(int.parse(dateArray[2]), int.parse(dateArray[1]), int.parse(dateArray[0]));
context.read<RegistrationCubitV2>().setBirthday(date);
},
),
if (!state.isBirthdayValid) ...[
const SizedBox(height: 4),
ValidationErrorWidget(error: state.dateOfBirthDisplayError.isEmpty ? s.date_of_birth_error : state.dateOfBirthDisplayError),
],
],
),
),
const SizedBox(width: 12),
const Expanded(child: SexWidget()),
],
),
const Spacer(),
CustomOutlinedButton(
onPressed: () {
context.read<RegistrationCubitV2>().nextStep();
},
text: s.next,
height: 52,
buttonTextStyle: TextStyles.textSSemibold.copyWith(color: appTheme.whiteA700),
buttonStyle: ButtonStyle(side: const WidgetStatePropertyAll(BorderSide.none), backgroundColor: WidgetStatePropertyAll(appTheme.blueA400)),
),
const SizedBox(height: 20),
],
);
},
);
}
}

View File

@@ -1,175 +1,181 @@
import 'package:eatvio_app/core/app_config.dart';
import 'package:eatvio_app/core/const.dart';
import 'package:eatvio_app/core/locator_service.dart';
import 'package:eatvio_app/core/theme/custom_text_style.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/custom_outlined_button.dart';
import 'package:eatvio_app/core/widgets/custom_text_form_field.dart';
import 'package:eatvio_app/core/widgets/loader.dart';
import 'package:eatvio_app/features/create_diet/presentation/widgets/error_widget.dart';
import 'package:eatvio_app/features/registration_v2/cubit/registration_cubit.dart';
import 'package:eatvio_app/features/registration_v2/cubit/registration_state.dart';
import 'package:eatvio_app/features/registration_v2/presentation/widgets/phisical_activity.dart';
import 'package:eatvio_app/features/registration_v2/presentation/widgets/show_successful_registration_bottom_sheet.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:url_launcher/url_launcher.dart';
class SecondStepContent extends StatefulWidget {
const SecondStepContent({super.key});
@override
State<SecondStepContent> createState() => _SecondStepContentState();
}
class _SecondStepContentState extends State<SecondStepContent> {
bool isLoading = false;
final weightController = TextEditingController();
final heightController = TextEditingController();
@override
void initState() {
super.initState();
heightController.text = context.read<RegistrationCubitV2>().state.height.toString();
weightController.text = context.read<RegistrationCubitV2>().state.weight.toString();
}
@override
Widget build(BuildContext context) {
final s = S.of(context);
return BlocBuilder<RegistrationCubitV2, RegistrationStateV2>(
builder: (context, state) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(s.last_step, style: TextStyles.textFS24FW700.copyWith(color: appTheme.black)),
const SizedBox(height: 12),
Text(s.user_data_desc, style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
const SizedBox(height: 16),
Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(s.height, style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
const SizedBox(height: 4),
CustomTextFormField(
hintText: s.type_height,
hasError: !state.isHeightValid,
controller: heightController,
textInputType: const TextInputType.numberWithOptions(),
onChanged: (val) {
context.read<RegistrationCubitV2>().setHeight(int.parse(val));
},
),
if (!state.isHeightValid) ValidationErrorWidget(error: s.height_error),
],
),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(s.weight, style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
const SizedBox(height: 4),
CustomTextFormField(
hintText: s.type_weight,
hasError: !state.isWeightValid,
controller: weightController,
textInputType: const TextInputType.numberWithOptions(),
onChanged: (val) {
context.read<RegistrationCubitV2>().setWeight(int.parse(val));
},
),
if (!state.isWeightValid) ValidationErrorWidget(error: s.weight_error),
],
),
),
],
),
const SizedBox(height: 12),
Text(s.phisical_activity, style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
const PhisicalActivity(),
const SizedBox(height: 12),
const Spacer(),
Row(
children: [
InkWell(
onTap: () {
context.read<RegistrationCubitV2>().prevStep();
},
borderRadius: BorderRadius.circular(20),
child: Ink(
height: 52,
width: 52,
decoration: BoxDecoration(color: appTheme.gray50, borderRadius: BorderRadius.circular(20)),
child: Center(child: Icon(Icons.arrow_back_ios_new_rounded, color: appTheme.blueA400, size: 24)),
),
),
const SizedBox(width: 4),
isLoading
? const Expanded(child: Center(child: Loader()))
: Expanded(
child: CustomOutlinedButton(
onPressed: () async {
setState(() {
isLoading = true;
});
final cubit = context.read<RegistrationCubitV2>();
final (commonResult, hasValidationError) = await cubit.register();
setState(() {
isLoading = false;
});
if (context.mounted && !hasValidationError) {
showRegistrationBottomSheet(context, cubit, commonResult);
}
},
text: s.register,
height: 52,
buttonTextStyle: TextStyles.textSSemibold.copyWith(color: appTheme.whiteA700),
buttonStyle: ButtonStyle(
side: const WidgetStatePropertyAll(BorderSide.none),
backgroundColor: WidgetStatePropertyAll(appTheme.blueA400),
),
),
),
],
),
const SizedBox(height: 12),
Center(
child: RichText(
textAlign: TextAlign.center,
text: TextSpan(
text: 'Нажимая “Зарегистрироваться”, Вы соглашаетесь \n',
style: const TextStyle(fontSize: 12, color: Colors.black),
children: [
const TextSpan(text: 'c '),
if (!hidePlans) ...[
TextSpan(
text: ' Публичной офертой',
style: TextStyle(fontSize: 12, color: appTheme.blueA400, decorationColor: appTheme.blueA400, decoration: TextDecoration.underline),
recognizer: TapGestureRecognizer()..onTap = () async => await launchUrl(Uri.parse('${sl<AppConfig>().baseUrl}/oferta_bs.pdf')),
),
const TextSpan(text: ' и '),
],
TextSpan(
text: 'Политикой конфиденциальности\nи защитой персональных данных',
style: TextStyle(fontSize: 12, color: appTheme.blueA400, decorationColor: appTheme.blueA400, decoration: TextDecoration.underline),
recognizer: TapGestureRecognizer()..onTap = () async => await launchUrl(Uri.parse('${sl<AppConfig>().baseUrl}/docs/privacy.pdf')),
),
],
),
),
),
const SizedBox(height: 30),
],
);
},
);
}
}
import 'package:eatvio_app/core/app_config.dart';
import 'package:eatvio_app/core/const.dart';
import 'package:eatvio_app/core/locator_service.dart';
import 'package:eatvio_app/core/theme/custom_text_style.dart';
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/custom_outlined_button.dart';
import 'package:eatvio_app/core/widgets/custom_text_form_field.dart';
import 'package:eatvio_app/core/widgets/loader.dart';
import 'package:eatvio_app/features/create_diet/presentation/widgets/error_widget.dart';
import 'package:eatvio_app/features/registration_v2/cubit/registration_cubit.dart';
import 'package:eatvio_app/features/registration_v2/cubit/registration_state.dart';
import 'package:eatvio_app/features/registration_v2/presentation/widgets/phisical_activity.dart';
import 'package:eatvio_app/features/registration_v2/presentation/widgets/show_successful_registration_bottom_sheet.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:url_launcher/url_launcher.dart';
class SecondStepContent extends StatefulWidget {
const SecondStepContent({super.key});
@override
State<SecondStepContent> createState() => _SecondStepContentState();
}
class _SecondStepContentState extends State<SecondStepContent> {
bool isLoading = false;
final weightController = TextEditingController();
final heightController = TextEditingController();
@override
void initState() {
super.initState();
heightController.text = context.read<RegistrationCubitV2>().state.height.toString() == '0'
? ''
: context.read<RegistrationCubitV2>().state.height.toString();
weightController.text = context.read<RegistrationCubitV2>().state.weight.toString() == '0'
? ''
: context.read<RegistrationCubitV2>().state.weight.toString();
}
@override
Widget build(BuildContext context) {
final s = S.of(context);
return BlocBuilder<RegistrationCubitV2, RegistrationStateV2>(
builder: (context, state) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(s.last_step, style: TextStyles.textFS24FW700.copyWith(color: appTheme.black)),
const SizedBox(height: 12),
Text(s.user_data_desc, style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
const SizedBox(height: 16),
Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(s.height, style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
const SizedBox(height: 4),
CustomTextFormField(
hintText: s.type_height,
hasError: !state.isHeightValid,
controller: heightController,
keyboardType: TextInputType.number,
textInputType: const TextInputType.numberWithOptions(),
onChanged: (val) {
context.read<RegistrationCubitV2>().setHeight(int.parse(val));
},
),
if (!state.isHeightValid) ValidationErrorWidget(error: s.height_error),
],
),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(s.weight, style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
const SizedBox(height: 4),
CustomTextFormField(
hintText: s.type_weight,
hasError: !state.isWeightValid,
controller: weightController,
keyboardType: TextInputType.number,
textInputType: const TextInputType.numberWithOptions(),
onChanged: (val) {
context.read<RegistrationCubitV2>().setWeight(int.parse(val));
},
),
if (!state.isWeightValid) ValidationErrorWidget(error: s.weight_error),
],
),
),
],
),
const SizedBox(height: 12),
Text(s.phisical_activity, style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
const PhisicalActivity(),
const SizedBox(height: 12),
const Spacer(),
Row(
children: [
InkWell(
onTap: () {
context.read<RegistrationCubitV2>().prevStep();
},
borderRadius: BorderRadius.circular(20),
child: Ink(
height: 52,
width: 52,
decoration: BoxDecoration(color: appTheme.gray50, borderRadius: BorderRadius.circular(20)),
child: Center(child: Icon(Icons.arrow_back_ios_new_rounded, color: appTheme.blueA400, size: 24)),
),
),
const SizedBox(width: 4),
isLoading
? const Expanded(child: Center(child: Loader()))
: Expanded(
child: CustomOutlinedButton(
onPressed: () async {
setState(() {
isLoading = true;
});
final cubit = context.read<RegistrationCubitV2>();
final (commonResult, hasValidationError) = await cubit.register();
setState(() {
isLoading = false;
});
if (context.mounted && !hasValidationError) {
showRegistrationBottomSheet(context, cubit, commonResult);
}
},
text: s.register,
height: 52,
buttonTextStyle: TextStyles.textSSemibold.copyWith(color: appTheme.whiteA700),
buttonStyle: ButtonStyle(
side: const WidgetStatePropertyAll(BorderSide.none),
backgroundColor: WidgetStatePropertyAll(appTheme.blueA400),
),
),
),
],
),
const SizedBox(height: 12),
Center(
child: RichText(
textAlign: TextAlign.center,
text: TextSpan(
text: 'Нажимая “Зарегистрироваться”, Вы соглашаетесь \n',
style: const TextStyle(fontSize: 12, color: Colors.black),
children: [
const TextSpan(text: 'c '),
if (!hidePlans) ...[
TextSpan(
text: ' Публичной офертой',
style: TextStyle(fontSize: 12, color: appTheme.blueA400, decorationColor: appTheme.blueA400, decoration: TextDecoration.underline),
recognizer: TapGestureRecognizer()..onTap = () async => await launchUrl(Uri.parse('${sl<AppConfig>().baseUrl}/oferta_bs.pdf')),
),
const TextSpan(text: ' и '),
],
TextSpan(
text: 'Политикой конфиденциальности\nи защитой персональных данных',
style: TextStyle(fontSize: 12, color: appTheme.blueA400, decorationColor: appTheme.blueA400, decoration: TextDecoration.underline),
recognizer: TapGestureRecognizer()..onTap = () async => await launchUrl(Uri.parse('${sl<AppConfig>().baseUrl}/docs/privacy.pdf')),
),
],
),
),
),
const SizedBox(height: 30),
],
);
},
);
}
}

View File

@@ -4,7 +4,7 @@ version: 1.3.10+90
publish_to: 'none'
environment:
sdk: '>=3.8.0 <4.0.0'
sdk: ^3.10.4
dependencies:
flutter:
@@ -15,7 +15,7 @@ dependencies:
flutter_bloc: ^9.1.1
cached_network_image: ^3.4.1
flutter_svg: ^2.2.0
flutter_svg: ^2.2.3
equatable: ^2.0.7
freezed_annotation: ^3.1.0
json_annotation: ^4.9.0
@@ -23,12 +23,12 @@ dependencies:
path_provider: ^2.1.5
carousel_slider_plus: ^7.1.1
flutter_form_builder: ^10.2.0
image_picker: ^1.2.0
image_picker: ^1.2.1
flutter_typeahead: ^5.2.0
go_router: ^17.0.0
go_router: ^17.0.1
keyboard_dismisser: ^3.0.0
retrofit: ^4.7.1
get_it: ^9.0.5
retrofit: 4.7.2
get_it: ^9.2.0
dio: ^5.9.0
dart_pusher_channels: ^1.2.3
photo_view: ^0.15.0
@@ -36,60 +36,60 @@ dependencies:
url_launcher: ^6.3.2
easy_debounce: ^2.0.3
badges: ^3.1.2
google_fonts: ^6.3.0
syncfusion_flutter_charts: ^31.2.10
syncfusion_flutter_gauges: ^31.2.10
google_fonts: ^6.3.3
syncfusion_flutter_charts: ^32.1.20
syncfusion_flutter_gauges: ^32.1.20
table_calendar: ^3.2.0
flutter_keyboard_visibility: ^6.0.0
share_plus: ^12.0.1
flutter_html: ^3.0.0
file_picker: ^10.3.1
audioplayers: ^6.5.0
file_picker: ^10.3.8
audioplayers: ^6.5.1
intl: ^0.20.2
mask_text_input_formatter: ^2.9.0
lottie: ^3.3.1
lottie: ^3.3.2
flutter_portal: ^1.1.4
fluttertoast: ^9.0.0
flutter_rating_bar: ^4.0.1
flutter_image_compress: ^2.4.0
image: ^4.5.4
image: ^4.7.2
dotted_border: ^3.1.0
http: ^1.5.0
flutter_native_splash: ^2.4.6
http: ^1.6.0
flutter_native_splash: ^2.4.7
webview_flutter: ^4.13.0
sentry_flutter: ^9.8.0
sentry_flutter: ^9.9.1
connectivity_plus: ^7.0.0
visibility_detector: ^0.4.0+2
firebase_core: ^4.0.0
firebase_messaging: ^16.0.0
firebase_core: ^4.3.0
firebase_messaging: ^16.1.0
http_parser: ^4.1.2
path: ^1.9.1
collection: ^1.19.1
shared_preferences: ^2.5.3
shared_preferences: ^2.5.4
version: ^3.0.2
package_info_plus: ^9.0.0
device_info_plus: ^12.2.0
device_info_plus: ^12.3.0
permission_handler: ^12.0.1
qr_code_scanner_plus: ^2.0.10+1
qr_code_scanner_plus: ^2.0.14
flutter_dotenv: ^6.0.0
uuid: ^4.5.2
appmetrica_plugin: ^3.3.0
vk_id: ^1.0.3
appmetrica_plugin: ^3.4.0
vk_id: ^1.0.4
flutter_login_yandex: ^0.0.5
markdown: ^7.3.0
flutter_password_generator: ^1.0.3
mobile_scanner: ^7.1.3
material_symbols_icons: ^4.2874.0
mobile_scanner: ^7.1.4
material_symbols_icons: ^4.2892.0
rxdart: ^0.27.7
gpassword: ^1.0.0
webview_flutter_platform_interface: ^2.14.0
dev_dependencies:
build_runner: ^2.7.0
build_runner: ^2.10.4
freezed: ^3.2.0
json_serializable: ^6.10.0
retrofit_generator: ^10.0.2
mockito: ^5.5.0
json_serializable: ^6.11.2
retrofit_generator: 10.0.6
mockito: ^5.6.1
mocktail: ^1.0.4
network_image_mock: ^2.1.1

View File

@@ -1,153 +1,157 @@
import 'package:eatvio_app/core/constants/app_constants.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('AppConstants', () {
group('Sizes', () {
test('has correct padding values', () {
expect(AppConstants.defaultPadding, 16.0);
expect(AppConstants.smallPadding, 8.0);
expect(AppConstants.largePadding, 24.0);
expect(AppConstants.extraLargePadding, 32.0);
});
test('has correct border radius values', () {
expect(AppConstants.defaultBorderRadius, 8.0);
expect(AppConstants.smallBorderRadius, 4.0);
expect(AppConstants.largeBorderRadius, 16.0);
});
test('has correct button height values', () {
expect(AppConstants.defaultButtonHeight, 48.0);
expect(AppConstants.smallButtonHeight, 36.0);
expect(AppConstants.largeButtonHeight, 56.0);
});
test('has correct content width values', () {
expect(AppConstants.maxContentWidth, 400.0);
expect(AppConstants.minContentWidth, 280.0);
});
});
group('Animations', () {
test('has correct animation durations', () {
expect(AppConstants.defaultAnimationDuration, const Duration(milliseconds: 300));
expect(AppConstants.fastAnimationDuration, const Duration(milliseconds: 150));
expect(AppConstants.slowAnimationDuration, const Duration(milliseconds: 500));
});
});
group('Timeouts', () {
test('has correct timeout durations', () {
expect(AppConstants.defaultTimeout, const Duration(seconds: 30));
expect(AppConstants.shortTimeout, const Duration(seconds: 10));
expect(AppConstants.longTimeout, const Duration(minutes: 2));
});
});
group('Limits', () {
test('has correct size limits', () {
expect(AppConstants.maxImageSize, 5 * 1024 * 1024);
expect(AppConstants.maxVideoSize, 100 * 1024 * 1024);
});
test('has correct text length limits', () {
expect(AppConstants.maxTextLength, 1000);
expect(AppConstants.maxTitleLength, 100);
expect(AppConstants.maxDescriptionLength, 500);
});
});
group('Pagination', () {
test('has correct page sizes', () {
expect(AppConstants.defaultPageSize, 20);
expect(AppConstants.smallPageSize, 10);
expect(AppConstants.largePageSize, 50);
});
});
group('Formats', () {
test('has supported image formats', () {
expect(AppConstants.supportedImageFormats, contains('jpg'));
expect(AppConstants.supportedImageFormats, contains('jpeg'));
expect(AppConstants.supportedImageFormats, contains('png'));
expect(AppConstants.supportedImageFormats, contains('webp'));
});
test('has supported video formats', () {
expect(AppConstants.supportedVideoFormats, contains('mp4'));
expect(AppConstants.supportedVideoFormats, contains('mov'));
expect(AppConstants.supportedVideoFormats, contains('avi'));
});
});
group('Regex', () {
test('has email regex', () {
expect(AppConstants.emailRegex, isA<String>());
expect(AppConstants.emailRegex.isNotEmpty, isTrue);
});
test('has phone regex', () {
expect(AppConstants.phoneRegex, isA<String>());
expect(AppConstants.phoneRegex.isNotEmpty, isTrue);
});
test('has URL regex', () {
expect(AppConstants.urlRegex, isA<String>());
expect(AppConstants.urlRegex.isNotEmpty, isTrue);
});
});
group('Messages', () {
test('has error messages', () {
expect(AppConstants.defaultErrorMessage, isA<String>());
expect(AppConstants.networkErrorMessage, isA<String>());
expect(AppConstants.timeoutErrorMessage, isA<String>());
expect(AppConstants.unknownErrorMessage, isA<String>());
});
});
group('Keys', () {
test('has SharedPreferences keys', () {
expect(AppConstants.welcomeScreenShownKey, isA<String>());
expect(AppConstants.userTokenKey, isA<String>());
expect(AppConstants.userDataKey, isA<String>());
expect(AppConstants.settingsKey, isA<String>());
});
});
group('API Endpoints', () {
test('has API endpoints', () {
expect(AppConstants.apiVersion, '/api');
expect(AppConstants.authEndpoint, '/auth');
expect(AppConstants.usersEndpoint, '/users');
expect(AppConstants.postsEndpoint, '/posts');
expect(AppConstants.commentsEndpoint, '/comments');
});
});
});
}
import 'package:eatvio_app/core/constants/app_constants.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('AppConstants', () {
group('Sizes', () {
test('has correct padding values', () {
expect(AppConstants.defaultPadding, 16.0);
expect(AppConstants.smallPadding, 8.0);
expect(AppConstants.largePadding, 24.0);
expect(AppConstants.extraLargePadding, 32.0);
});
test('has correct border radius values', () {
expect(AppConstants.defaultBorderRadius, 8.0);
expect(AppConstants.smallBorderRadius, 4.0);
expect(AppConstants.largeBorderRadius, 16.0);
});
test('has correct button height values', () {
expect(AppConstants.defaultButtonHeight, 48.0);
expect(AppConstants.smallButtonHeight, 36.0);
expect(AppConstants.largeButtonHeight, 56.0);
});
test('has correct content width values', () {
expect(AppConstants.maxContentWidth, 400.0);
expect(AppConstants.minContentWidth, 280.0);
});
});
group('Animations', () {
test('has correct animation durations', () {
expect(AppConstants.defaultAnimationDuration, const Duration(milliseconds: 300));
expect(AppConstants.fastAnimationDuration, const Duration(milliseconds: 150));
expect(AppConstants.slowAnimationDuration, const Duration(milliseconds: 500));
});
});
group('Timeouts', () {
test('has correct timeout durations', () {
expect(AppConstants.defaultTimeout, const Duration(seconds: 30));
expect(AppConstants.shortTimeout, const Duration(seconds: 10));
expect(AppConstants.longTimeout, const Duration(minutes: 2));
});
});
group('Limits', () {
test('has correct size limits', () {
expect(AppConstants.maxImageSize, 5 * 1024 * 1024);
expect(AppConstants.maxVideoSize, 100 * 1024 * 1024);
});
test('has correct text length limits', () {
expect(AppConstants.maxTextLength, 1000);
expect(AppConstants.maxTitleLength, 100);
expect(AppConstants.maxDescriptionLength, 500);
});
});
group('Pagination', () {
test('has correct page sizes', () {
expect(AppConstants.defaultPageSize, 20);
expect(AppConstants.smallPageSize, 10);
expect(AppConstants.largePageSize, 50);
});
});
group('Formats', () {
test('has supported image formats', () {
expect(AppConstants.supportedImageFormats, contains('jpg'));
expect(AppConstants.supportedImageFormats, contains('jpeg'));
expect(AppConstants.supportedImageFormats, contains('png'));
expect(AppConstants.supportedImageFormats, contains('webp'));
});
test('has supported video formats', () {
expect(AppConstants.supportedVideoFormats, contains('mp4'));
expect(AppConstants.supportedVideoFormats, contains('mov'));
expect(AppConstants.supportedVideoFormats, contains('avi'));
});
});
group('Regex', () {
test('has email regex', () {
expect(AppConstants.emailRegex, isA<String>());
expect(AppConstants.emailRegex.isNotEmpty, isTrue);
});
test('has phone regex', () {
expect(AppConstants.phoneRegex, isA<String>());
expect(AppConstants.phoneRegex.isNotEmpty, isTrue);
});
test('has URL regex', () {
expect(AppConstants.urlRegex, isA<String>());
expect(AppConstants.urlRegex.isNotEmpty, isTrue);
});
});
group('Messages', () {
test('has error messages', () {
expect(AppConstants.defaultErrorMessage, isA<String>());
expect(AppConstants.networkErrorMessage, isA<String>());
expect(AppConstants.timeoutErrorMessage, isA<String>());
expect(AppConstants.unknownErrorMessage, isA<String>());
});
});
group('Keys', () {
test('has SharedPreferences keys', () {
expect(AppConstants.welcomeScreenShownKey, isA<String>());
expect(AppConstants.userTokenKey, isA<String>());
expect(AppConstants.userDataKey, isA<String>());
expect(AppConstants.settingsKey, isA<String>());
});
});
group('API Endpoints', () {
test('has API endpoints', () {
expect(AppConstants.apiVersion, '/api');
expect(AppConstants.authEndpoint, '/auth');
expect(AppConstants.usersEndpoint, '/users');
expect(AppConstants.postsEndpoint, '/posts');
expect(AppConstants.commentsEndpoint, '/comments');
});
});
});
}

View File

@@ -1,88 +1,92 @@
import 'package:eatvio_app/core/cubit/state_utils.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('StateUtils', () {
test('isLoading returns true for loading state', () {
expect(StateUtils.isLoading('loading'), isTrue);
expect(StateUtils.isLoading('Loading'), isTrue);
expect(StateUtils.isLoading('StateLoading'), isTrue);
expect(StateUtils.isLoading('state_loading'), isTrue);
});
test('isLoading returns false for non-loading state', () {
expect(StateUtils.isLoading('loaded'), isFalse);
expect(StateUtils.isLoading('error'), isFalse);
expect(StateUtils.isLoading('success'), isFalse);
});
test('isLoaded returns true for loaded state', () {
expect(StateUtils.isLoaded('loaded'), isTrue);
expect(StateUtils.isLoaded('Loaded'), isTrue);
expect(StateUtils.isLoaded('StateLoaded'), isTrue);
expect(StateUtils.isLoaded('state_loaded'), isTrue);
});
test('isLoaded returns false for non-loaded state', () {
expect(StateUtils.isLoaded('loading'), isFalse);
expect(StateUtils.isLoaded('error'), isFalse);
expect(StateUtils.isLoaded('initial'), isFalse);
});
test('isError returns true for error state', () {
expect(StateUtils.isError('error'), isTrue);
expect(StateUtils.isError('Error'), isTrue);
expect(StateUtils.isError('StateError'), isTrue);
expect(StateUtils.isError('state_error'), isTrue);
});
test('isError returns false for non-error state', () {
expect(StateUtils.isError('loading'), isFalse);
expect(StateUtils.isError('loaded'), isFalse);
expect(StateUtils.isError('success'), isFalse);
});
test('getErrorMessage returns null for non-error state', () {
expect(StateUtils.getErrorMessage('loading'), isNull);
expect(StateUtils.getErrorMessage('loaded'), isNull);
expect(StateUtils.getErrorMessage('success'), isNull);
});
test('getErrorMessage extracts error message from error state', () {
const errorState = 'error: Something went wrong';
final message = StateUtils.getErrorMessage(errorState);
expect(message, isNotNull);
expect(message, contains('Something'));
});
test('getErrorMessage handles various error state formats', () {
expect(StateUtils.getErrorMessage('error: test'), isNotNull);
expect(StateUtils.getErrorMessage('Error: test message'), isNotNull);
});
});
}
import 'package:eatvio_app/core/cubit/state_utils.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('StateUtils', () {
test('isLoading returns true for loading state', () {
expect(StateUtils.isLoading('loading'), isTrue);
expect(StateUtils.isLoading('Loading'), isTrue);
expect(StateUtils.isLoading('StateLoading'), isTrue);
expect(StateUtils.isLoading('state_loading'), isTrue);
});
test('isLoading returns false for non-loading state', () {
expect(StateUtils.isLoading('loaded'), isFalse);
expect(StateUtils.isLoading('error'), isFalse);
expect(StateUtils.isLoading('success'), isFalse);
});
test('isLoaded returns true for loaded state', () {
expect(StateUtils.isLoaded('loaded'), isTrue);
expect(StateUtils.isLoaded('Loaded'), isTrue);
expect(StateUtils.isLoaded('StateLoaded'), isTrue);
expect(StateUtils.isLoaded('state_loaded'), isTrue);
});
test('isLoaded returns false for non-loaded state', () {
expect(StateUtils.isLoaded('loading'), isFalse);
expect(StateUtils.isLoaded('error'), isFalse);
expect(StateUtils.isLoaded('initial'), isFalse);
});
test('isError returns true for error state', () {
expect(StateUtils.isError('error'), isTrue);
expect(StateUtils.isError('Error'), isTrue);
expect(StateUtils.isError('StateError'), isTrue);
expect(StateUtils.isError('state_error'), isTrue);
});
test('isError returns false for non-error state', () {
expect(StateUtils.isError('loading'), isFalse);
expect(StateUtils.isError('loaded'), isFalse);
expect(StateUtils.isError('success'), isFalse);
});
test('getErrorMessage returns null for non-error state', () {
expect(StateUtils.getErrorMessage('loading'), isNull);
expect(StateUtils.getErrorMessage('loaded'), isNull);
expect(StateUtils.getErrorMessage('success'), isNull);
});
test('getErrorMessage extracts error message from error state', () {
const errorState = 'error: Something went wrong';
final message = StateUtils.getErrorMessage(errorState);
expect(message, isNotNull);
expect(message, contains('Something'));
});
test('getErrorMessage handles various error state formats', () {
expect(StateUtils.getErrorMessage('error: test'), isNotNull);
expect(StateUtils.getErrorMessage('Error: test message'), isNotNull);
});
});
}

View File

@@ -1,102 +1,106 @@
import 'package:eatvio_app/core/data/selectionPopupModel/selection_popup_model.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('SelectionPopupModel', () {
test('creates model with all parameters', () {
const model = SelectionPopupModel(
id: 1,
title: 'Test Title',
value: 'Test Value',
isSelected: true,
);
expect(model.id, 1);
expect(model.title, 'Test Title');
expect(model.value, 'Test Value');
expect(model.isSelected, true);
});
test('creates model with default isSelected value', () {
const model = SelectionPopupModel(
title: 'Test Title',
value: 'Test Value',
);
expect(model.isSelected, false);
});
test('creates model with null id', () {
const model = SelectionPopupModel(
id: null,
title: 'Test Title',
value: 'Test Value',
);
expect(model.id, null);
expect(model.title, 'Test Title');
});
test('creates model with different value types', () {
const model1 = SelectionPopupModel(
title: 'Test',
value: 123,
);
const model2 = SelectionPopupModel(
title: 'Test',
value: 'String Value',
);
const model3 = SelectionPopupModel(
title: 'Test',
value: true,
);
expect(model1.value, 123);
expect(model2.value, 'String Value');
expect(model3.value, true);
});
test('can be compared', () {
const model1 = SelectionPopupModel(
id: 1,
title: 'Test',
value: 'Value',
);
const model2 = SelectionPopupModel(
id: 1,
title: 'Test',
value: 'Value',
);
expect(model1 == model2, true);
});
});
}
import 'package:eatvio_app/core/data/selectionPopupModel/selection_popup_model.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('SelectionPopupModel', () {
test('creates model with all parameters', () {
const model = SelectionPopupModel(
id: 1,
title: 'Test Title',
value: 'Test Value',
isSelected: true,
);
expect(model.id, 1);
expect(model.title, 'Test Title');
expect(model.value, 'Test Value');
expect(model.isSelected, true);
});
test('creates model with default isSelected value', () {
const model = SelectionPopupModel(
title: 'Test Title',
value: 'Test Value',
);
expect(model.isSelected, false);
});
test('creates model with null id', () {
const model = SelectionPopupModel(
id: null,
title: 'Test Title',
value: 'Test Value',
);
expect(model.id, null);
expect(model.title, 'Test Title');
});
test('creates model with different value types', () {
const model1 = SelectionPopupModel(
title: 'Test',
value: 123,
);
const model2 = SelectionPopupModel(
title: 'Test',
value: 'String Value',
);
const model3 = SelectionPopupModel(
title: 'Test',
value: true,
);
expect(model1.value, 123);
expect(model2.value, 'String Value');
expect(model3.value, true);
});
test('can be compared', () {
const model1 = SelectionPopupModel(
id: 1,
title: 'Test',
value: 'Value',
);
const model2 = SelectionPopupModel(
id: 1,
title: 'Test',
value: 'Value',
);
expect(model1 == model2, true);
});
});
}

View File

@@ -1,51 +1,55 @@
import 'package:eatvio_app/core/prefs_keys.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('PrefsKeys', () {
test('has all expected values', () {
expect(PrefsKeys.values.length, 4);
expect(PrefsKeys.values, contains(PrefsKeys.hasAnonymousTokenBeenSent));
expect(PrefsKeys.values, contains(PrefsKeys.welcomeScreenWasShowed));
expect(PrefsKeys.values, contains(PrefsKeys.registrationDate));
expect(PrefsKeys.values, contains(PrefsKeys.marketingBottomSheetHasBeenShown));
});
test('can be compared', () {
expect(PrefsKeys.hasAnonymousTokenBeenSent == PrefsKeys.hasAnonymousTokenBeenSent, true);
expect(PrefsKeys.hasAnonymousTokenBeenSent == PrefsKeys.welcomeScreenWasShowed, false);
});
test('has correct name property', () {
expect(PrefsKeys.hasAnonymousTokenBeenSent.name, 'hasAnonymousTokenBeenSent');
expect(PrefsKeys.welcomeScreenWasShowed.name, 'welcomeScreenWasShowed');
expect(PrefsKeys.registrationDate.name, 'registrationDate');
expect(PrefsKeys.marketingBottomSheetHasBeenShown.name, 'marketingBottomSheetHasBeenShown');
});
});
}
import 'package:eatvio_app/core/prefs_keys.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('PrefsKeys', () {
test('has all expected values', () {
expect(PrefsKeys.values.length, 4);
expect(PrefsKeys.values, contains(PrefsKeys.hasAnonymousTokenBeenSent));
expect(PrefsKeys.values, contains(PrefsKeys.welcomeScreenWasShowed));
expect(PrefsKeys.values, contains(PrefsKeys.registrationDate));
expect(PrefsKeys.values, contains(PrefsKeys.marketingBottomSheetHasBeenShown));
});
test('can be compared', () {
expect(PrefsKeys.hasAnonymousTokenBeenSent == PrefsKeys.hasAnonymousTokenBeenSent, true);
expect(PrefsKeys.hasAnonymousTokenBeenSent == PrefsKeys.welcomeScreenWasShowed, false);
});
test('has correct name property', () {
expect(PrefsKeys.hasAnonymousTokenBeenSent.name, 'hasAnonymousTokenBeenSent');
expect(PrefsKeys.welcomeScreenWasShowed.name, 'welcomeScreenWasShowed');
expect(PrefsKeys.registrationDate.name, 'registrationDate');
expect(PrefsKeys.marketingBottomSheetHasBeenShown.name, 'marketingBottomSheetHasBeenShown');
});
});
}

View File

@@ -1,77 +1,81 @@
import 'package:eatvio_app/core/internet_connection_cubit/internet_connection_state.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('InternetConnectionState', () {
test('creates state with default isInternetAvailable value', () {
final state = InternetConnectionState();
expect(state.isInternetAvailable, true);
});
test('creates state with isInternetAvailable set to false', () {
final state = InternetConnectionState(
isInternetAvailable: false,
);
expect(state.isInternetAvailable, false);
});
test('creates state with isInternetAvailable set to true', () {
final state = InternetConnectionState(
isInternetAvailable: true,
);
expect(state.isInternetAvailable, true);
});
test('can be compared', () {
final state1 = InternetConnectionState(
isInternetAvailable: true,
);
final state2 = InternetConnectionState(
isInternetAvailable: true,
);
expect(state1 == state2, true);
});
test('different states are not equal', () {
final state1 = InternetConnectionState(
isInternetAvailable: true,
);
final state2 = InternetConnectionState(
isInternetAvailable: false,
);
expect(state1 == state2, false);
});
});
}
import 'package:eatvio_app/core/internet_connection_cubit/internet_connection_state.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('InternetConnectionState', () {
test('creates state with default isInternetAvailable value', () {
final state = InternetConnectionState();
expect(state.isInternetAvailable, true);
});
test('creates state with isInternetAvailable set to false', () {
final state = InternetConnectionState(
isInternetAvailable: false,
);
expect(state.isInternetAvailable, false);
});
test('creates state with isInternetAvailable set to true', () {
final state = InternetConnectionState(
isInternetAvailable: true,
);
expect(state.isInternetAvailable, true);
});
test('can be compared', () {
final state1 = InternetConnectionState(
isInternetAvailable: true,
);
final state2 = InternetConnectionState(
isInternetAvailable: true,
);
expect(state1 == state2, true);
});
test('different states are not equal', () {
final state1 = InternetConnectionState(
isInternetAvailable: true,
);
final state2 = InternetConnectionState(
isInternetAvailable: false,
);
expect(state1 == state2, false);
});
});
}

View File

@@ -1,47 +1,51 @@
import 'package:eatvio_app/core/prefs_keys.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('PrefsKeys', () {
test('все значения enum определены', () {
expect(PrefsKeys.values.length, 4);
expect(PrefsKeys.values, contains(PrefsKeys.hasAnonymousTokenBeenSent));
expect(PrefsKeys.values, contains(PrefsKeys.welcomeScreenWasShowed));
expect(PrefsKeys.values, contains(PrefsKeys.registrationDate));
expect(PrefsKeys.values, contains(PrefsKeys.marketingBottomSheetHasBeenShown));
});
test('имена ключей корректны', () {
expect(PrefsKeys.hasAnonymousTokenBeenSent.name, 'hasAnonymousTokenBeenSent');
expect(PrefsKeys.welcomeScreenWasShowed.name, 'welcomeScreenWasShowed');
expect(PrefsKeys.registrationDate.name, 'registrationDate');
expect(PrefsKeys.marketingBottomSheetHasBeenShown.name, 'marketingBottomSheetHasBeenShown');
});
});
}
import 'package:eatvio_app/core/prefs_keys.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('PrefsKeys', () {
test('все значения enum определены', () {
expect(PrefsKeys.values.length, 4);
expect(PrefsKeys.values, contains(PrefsKeys.hasAnonymousTokenBeenSent));
expect(PrefsKeys.values, contains(PrefsKeys.welcomeScreenWasShowed));
expect(PrefsKeys.values, contains(PrefsKeys.registrationDate));
expect(PrefsKeys.values, contains(PrefsKeys.marketingBottomSheetHasBeenShown));
});
test('имена ключей корректны', () {
expect(PrefsKeys.hasAnonymousTokenBeenSent.name, 'hasAnonymousTokenBeenSent');
expect(PrefsKeys.welcomeScreenWasShowed.name, 'welcomeScreenWasShowed');
expect(PrefsKeys.registrationDate.name, 'registrationDate');
expect(PrefsKeys.marketingBottomSheetHasBeenShown.name, 'marketingBottomSheetHasBeenShown');
});
});
}

View File

@@ -1,44 +1,48 @@
import 'package:eatvio_app/core/routing/main_navigation_routes.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:go_router/go_router.dart';
void main() {
group('MainNavigationRoutes', () {
test('createRoutes возвращает список маршрутов', () {
final routes = MainNavigationRoutes.createRoutes();
expect(routes, isNotEmpty);
expect(routes, isA<List<RouteBase>>());
});
test('createRoutes содержит ShellRoute', () {
final routes = MainNavigationRoutes.createRoutes();
expect(routes.first, isA<ShellRoute>());
});
});
}
import 'package:eatvio_app/core/routing/main_navigation_routes.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:go_router/go_router.dart';
void main() {
group('MainNavigationRoutes', () {
test('createRoutes возвращает список маршрутов', () {
final routes = MainNavigationRoutes.createRoutes();
expect(routes, isNotEmpty);
expect(routes, isA<List<RouteBase>>());
});
test('createRoutes содержит ShellRoute', () {
final routes = MainNavigationRoutes.createRoutes();
expect(routes.first, isA<ShellRoute>());
});
});
}

View File

@@ -1,48 +1,52 @@
import 'package:eatvio_app/core/routing/other_routes.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:go_router/go_router.dart';
void main() {
group('OtherRoutes', () {
test('createRoutes возвращает список маршрутов', () {
final routes = OtherRoutes.createRoutes();
expect(routes, isNotEmpty);
expect(routes, isA<List<RouteBase>>());
});
test('createRoutes содержит маршрут welcomeScreen', () {
final routes = OtherRoutes.createRoutes();
final welcomeRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/welcome-screen',
orElse: () => throw Exception('Route not found'),
);
expect(welcomeRoute, isA<GoRoute>());
});
});
}
import 'package:eatvio_app/core/routing/other_routes.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:go_router/go_router.dart';
void main() {
group('OtherRoutes', () {
test('createRoutes возвращает список маршрутов', () {
final routes = OtherRoutes.createRoutes();
expect(routes, isNotEmpty);
expect(routes, isA<List<RouteBase>>());
});
test('createRoutes содержит маршрут welcomeScreen', () {
final routes = OtherRoutes.createRoutes();
final welcomeRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/welcome-screen',
orElse: () => throw Exception('Route not found'),
);
expect(welcomeRoute, isA<GoRoute>());
});
});
}

View File

@@ -1,127 +1,131 @@
import 'package:eatvio_app/core/routing/route_constants.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('RouteConstants', () {
test('has all auth routes defined', () {
expect(RouteConstants.authScreen, '/auth-screen');
expect(RouteConstants.registrationScreen, 'registration-screen');
expect(RouteConstants.registrationScreenV2, 'registration-screen-v2');
expect(RouteConstants.forgetPasswordScreen, 'forget-password-screen');
expect(RouteConstants.scanQRCodeScreen, 'scan-qr-code-screen');
expect(RouteConstants.verifyScreen, '/verify-screen');
expect(RouteConstants.verifyEmailScreen, '/verify-email-screen');
expect(RouteConstants.registerViaSocialScreen, '/register-via-social-screen');
});
test('has all main navigation routes defined', () {
expect(RouteConstants.myProfileScreen, '/my-profile-screen');
expect(RouteConstants.feedScreen, '/feed-screen');
expect(RouteConstants.diaryScreen, '/diary-screen');
expect(RouteConstants.consultationsScreen, '/consultations-screen');
expect(RouteConstants.chatSelectScreen, '/chat-select-screen');
expect(RouteConstants.notificationsScreen, '/notifications-screen');
expect(RouteConstants.menuScreen, '/menu-screen');
});
test('has all content routes defined', () {
expect(RouteConstants.aboutPlanScreen, '/about-plan-screen');
expect(RouteConstants.aboutRecipesScreen, '/about-recipes-screen');
expect(RouteConstants.aboutDietScreen, '/about-diet-screen');
expect(RouteConstants.blogPostScreen, '/blog-post-screen');
expect(RouteConstants.blogPostCreateScreen, '/blog-post-create-screen');
});
test('has all profile routes defined', () {
expect(RouteConstants.profileScreen, '/profile-screen');
expect(RouteConstants.subsScreen, '/subs-screen');
});
test('has all settings routes defined', () {
expect(RouteConstants.settingsScreen, '/settings-screen');
expect(RouteConstants.generalInfoScreen, 'general-info-screen');
expect(RouteConstants.otherInfoScreen, 'other-info-screen');
expect(RouteConstants.physicalActivityScreen, 'physical-activity-screen');
expect(RouteConstants.physicalFormScreen, 'physical-form-screen');
expect(RouteConstants.pressureScreen, 'pressure-screen');
expect(RouteConstants.changePasswordScreen, 'change-password-screen');
expect(RouteConstants.changeEmailScreen, 'change-email-screen');
});
test('has all consultant routes defined', () {
expect(RouteConstants.becomeConsultantScreen, '/become-consultant-screen');
expect(RouteConstants.stepperBecomeConsultantScreen, '/stepper-become-consultant-screen');
expect(RouteConstants.consultantRatingScreen, '/consultant-rating-screen');
});
test('has all other routes defined', () {
expect(RouteConstants.welcomeScreen, '/welcome-screen');
expect(RouteConstants.updateScreen, '/update-screen');
expect(RouteConstants.calendarScreen, '/calendar-screen');
expect(RouteConstants.supportScreen, '/support-screen');
expect(RouteConstants.photoViewScreen, '/photo-view-screen');
expect(RouteConstants.chatScreen, '/chat-screen');
expect(RouteConstants.emptyChatScreen, '/empty-chat-screen');
expect(RouteConstants.glossaryScreen, '/glossary-screen');
expect(RouteConstants.blockedUsersScreen, '/blocked-users-screen');
expect(RouteConstants.notificationsSettingsScreen, '/notifications-settings-screen');
});
test('has all finance routes defined', () {
expect(RouteConstants.userFinanceScreen, '/user-finance-screen');
expect(RouteConstants.cardSettingsScreen, '/card-settings-screen');
expect(RouteConstants.orderInfoScreen, '/order-info-screen');
expect(RouteConstants.paymentScreen, '/payment-screen');
});
test('has all content creation routes defined', () {
expect(RouteConstants.recipeCreateScreen, '/recipe-create-screen');
expect(RouteConstants.createDietScreen, '/create-diet-screen');
expect(RouteConstants.dietPreviewScreen, '/diet-preview-screen');
expect(RouteConstants.createPlanScreen, '/create-plan-screen');
expect(RouteConstants.myDietsScreen, '/my-diets-screen');
expect(RouteConstants.myPlansScreen, '/my-plans-screen');
expect(RouteConstants.myRecipesScreen, '/my-recipes-screen');
});
test('has all user details routes defined', () {
expect(RouteConstants.userDetailsScreen, '/user-details-screen');
expect(RouteConstants.userDiaryScreen, '/user-diary-screen');
});
test('has dev tools route defined', () {
expect(RouteConstants.devToolsScreen, '/dev-tools-screen');
});
test('has all archive routes defined', () {
expect(RouteConstants.consultationsArchiveScreen, '/consultations-archive-screen');
expect(RouteConstants.consultantFinancesScreen, '/consultant-finances-screen');
expect(RouteConstants.userPurchasesScreen, '/user-purchases-screen');
});
});
}
import 'package:eatvio_app/core/routing/route_constants.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('RouteConstants', () {
test('has all auth routes defined', () {
expect(RouteConstants.authScreen, '/auth-screen');
expect(RouteConstants.registrationScreen, 'registration-screen');
expect(RouteConstants.registrationScreenV2, 'registration-screen-v2');
expect(RouteConstants.forgetPasswordScreen, 'forget-password-screen');
expect(RouteConstants.scanQRCodeScreen, 'scan-qr-code-screen');
expect(RouteConstants.verifyScreen, '/verify-screen');
expect(RouteConstants.verifyEmailScreen, '/verify-email-screen');
expect(RouteConstants.registerViaSocialScreen, '/register-via-social-screen');
});
test('has all main navigation routes defined', () {
expect(RouteConstants.myProfileScreen, '/my-profile-screen');
expect(RouteConstants.feedScreen, '/feed-screen');
expect(RouteConstants.diaryScreen, '/diary-screen');
expect(RouteConstants.consultationsScreen, '/consultations-screen');
expect(RouteConstants.chatSelectScreen, '/chat-select-screen');
expect(RouteConstants.notificationsScreen, '/notifications-screen');
expect(RouteConstants.menuScreen, '/menu-screen');
});
test('has all content routes defined', () {
expect(RouteConstants.aboutPlanScreen, '/about-plan-screen');
expect(RouteConstants.aboutRecipesScreen, '/about-recipes-screen');
expect(RouteConstants.aboutDietScreen, '/about-diet-screen');
expect(RouteConstants.blogPostScreen, '/blog-post-screen');
expect(RouteConstants.blogPostCreateScreen, '/blog-post-create-screen');
});
test('has all profile routes defined', () {
expect(RouteConstants.profileScreen, '/profile-screen');
expect(RouteConstants.subsScreen, '/subs-screen');
});
test('has all settings routes defined', () {
expect(RouteConstants.settingsScreen, '/settings-screen');
expect(RouteConstants.generalInfoScreen, 'general-info-screen');
expect(RouteConstants.otherInfoScreen, 'other-info-screen');
expect(RouteConstants.physicalActivityScreen, 'physical-activity-screen');
expect(RouteConstants.physicalFormScreen, 'physical-form-screen');
expect(RouteConstants.pressureScreen, 'pressure-screen');
expect(RouteConstants.changePasswordScreen, 'change-password-screen');
expect(RouteConstants.changeEmailScreen, 'change-email-screen');
});
test('has all consultant routes defined', () {
expect(RouteConstants.becomeConsultantScreen, '/become-consultant-screen');
expect(RouteConstants.stepperBecomeConsultantScreen, '/stepper-become-consultant-screen');
expect(RouteConstants.consultantRatingScreen, '/consultant-rating-screen');
});
test('has all other routes defined', () {
expect(RouteConstants.welcomeScreen, '/welcome-screen');
expect(RouteConstants.updateScreen, '/update-screen');
expect(RouteConstants.calendarScreen, '/calendar-screen');
expect(RouteConstants.supportScreen, '/support-screen');
expect(RouteConstants.photoViewScreen, '/photo-view-screen');
expect(RouteConstants.chatScreen, '/chat-screen');
expect(RouteConstants.emptyChatScreen, '/empty-chat-screen');
expect(RouteConstants.glossaryScreen, '/glossary-screen');
expect(RouteConstants.blockedUsersScreen, '/blocked-users-screen');
expect(RouteConstants.notificationsSettingsScreen, '/notifications-settings-screen');
});
test('has all finance routes defined', () {
expect(RouteConstants.userFinanceScreen, '/user-finance-screen');
expect(RouteConstants.cardSettingsScreen, '/card-settings-screen');
expect(RouteConstants.orderInfoScreen, '/order-info-screen');
expect(RouteConstants.paymentScreen, '/payment-screen');
});
test('has all content creation routes defined', () {
expect(RouteConstants.recipeCreateScreen, '/recipe-create-screen');
expect(RouteConstants.createDietScreen, '/create-diet-screen');
expect(RouteConstants.dietPreviewScreen, '/diet-preview-screen');
expect(RouteConstants.createPlanScreen, '/create-plan-screen');
expect(RouteConstants.myDietsScreen, '/my-diets-screen');
expect(RouteConstants.myPlansScreen, '/my-plans-screen');
expect(RouteConstants.myRecipesScreen, '/my-recipes-screen');
});
test('has all user details routes defined', () {
expect(RouteConstants.userDetailsScreen, '/user-details-screen');
expect(RouteConstants.userDiaryScreen, '/user-diary-screen');
});
test('has dev tools route defined', () {
expect(RouteConstants.devToolsScreen, '/dev-tools-screen');
});
test('has all archive routes defined', () {
expect(RouteConstants.consultationsArchiveScreen, '/consultations-archive-screen');
expect(RouteConstants.consultantFinancesScreen, '/consultant-finances-screen');
expect(RouteConstants.userPurchasesScreen, '/user-purchases-screen');
});
});
}

View File

@@ -1,51 +1,55 @@
import 'package:eatvio_app/core/routing/settings_routes.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:go_router/go_router.dart';
void main() {
group('SettingsRoutes', () {
test('createRoutes возвращает список маршрутов', () {
final routes = SettingsRoutes.createRoutes();
expect(routes, isNotEmpty);
expect(routes, isA<List<RouteBase>>());
});
test('createRoutes содержит маршрут settingsScreen', () {
final routes = SettingsRoutes.createRoutes();
final settingsRoute = routes.first as GoRoute;
expect(settingsRoute.path, '/settings-screen');
});
test('createRoutes содержит вложенные маршруты', () {
final routes = SettingsRoutes.createRoutes();
final settingsRoute = routes.first as GoRoute;
expect(settingsRoute.routes, isNotEmpty);
});
});
}
import 'package:eatvio_app/core/routing/settings_routes.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:go_router/go_router.dart';
void main() {
group('SettingsRoutes', () {
test('createRoutes возвращает список маршрутов', () {
final routes = SettingsRoutes.createRoutes();
expect(routes, isNotEmpty);
expect(routes, isA<List<RouteBase>>());
});
test('createRoutes содержит маршрут settingsScreen', () {
final routes = SettingsRoutes.createRoutes();
final settingsRoute = routes.first as GoRoute;
expect(settingsRoute.path, '/settings-screen');
});
test('createRoutes содержит вложенные маршруты', () {
final routes = SettingsRoutes.createRoutes();
final settingsRoute = routes.first as GoRoute;
expect(settingsRoute.routes, isNotEmpty);
});
});
}

View File

@@ -1,45 +1,49 @@
import 'package:eatvio_app/core/views/cubit/views_state.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('ViewsCubitState', () {
test('creates initial state', () {
final state = ViewsCubitState();
expect(state, isA<ViewsCubitState>());
});
test('can create multiple instances', () {
final state1 = ViewsCubitState();
final state2 = ViewsCubitState();
expect(state1, isA<ViewsCubitState>());
expect(state2, isA<ViewsCubitState>());
});
});
}
import 'package:eatvio_app/core/views/cubit/views_state.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('ViewsCubitState', () {
test('creates initial state', () {
final state = ViewsCubitState();
expect(state, isA<ViewsCubitState>());
});
test('can create multiple instances', () {
final state1 = ViewsCubitState();
final state2 = ViewsCubitState();
expect(state1, isA<ViewsCubitState>());
expect(state2, isA<ViewsCubitState>());
});
});
}

View File

@@ -1,81 +1,85 @@
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/add_item_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('AddItemButton', () {
testWidgets('displays add button', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: AddItemButton(),
),
),
);
expect(find.byType(AddItemButton), findsOneWidget);
expect(find.byIcon(Icons.add_rounded), findsOneWidget);
});
testWidgets('calls onTap when provided', (tester) async {
bool wasCalled = false;
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: AddItemButton(
onTap: () {
wasCalled = true;
},
),
),
),
);
await tester.tap(find.byType(AddItemButton));
await tester.pump();
expect(wasCalled, isTrue);
});
testWidgets('has circular shape', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: AddItemButton(),
),
),
);
expect(find.byType(AddItemButton), findsOneWidget);
});
});
}
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/add_item_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('AddItemButton', () {
testWidgets('displays add button', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: AddItemButton(),
),
),
);
expect(find.byType(AddItemButton), findsOneWidget);
expect(find.byIcon(Icons.add_rounded), findsOneWidget);
});
testWidgets('calls onTap when provided', (tester) async {
bool wasCalled = false;
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: AddItemButton(
onTap: () {
wasCalled = true;
},
),
),
),
);
await tester.tap(find.byType(AddItemButton));
await tester.pump();
expect(wasCalled, isTrue);
});
testWidgets('has circular shape', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: AddItemButton(),
),
),
);
expect(find.byType(AddItemButton), findsOneWidget);
});
});
}

View File

@@ -1,133 +1,137 @@
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/animated_option_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('AnimatedOptionButton', () {
testWidgets('displays animated option button', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: AnimatedOptionButton(
text: 'Option 1',
isSelected: false,
onTap: () {},
),
),
),
);
expect(find.byType(AnimatedOptionButton), findsOneWidget);
expect(find.text('Option 1'), findsOneWidget);
});
testWidgets('displays selected state', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: AnimatedOptionButton(
text: 'Option 1',
isSelected: true,
onTap: () {},
),
),
),
);
expect(find.byType(AnimatedOptionButton), findsOneWidget);
expect(find.text('Option 1'), findsOneWidget);
});
testWidgets('calls onTap when tapped', (tester) async {
bool tapped = false;
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: AnimatedOptionButton(
text: 'Option 1',
isSelected: false,
onTap: () {
tapped = true;
},
),
),
),
);
await tester.tap(find.byType(AnimatedOptionButton));
await tester.pump();
expect(tapped, true);
});
testWidgets('accepts custom text style', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: AnimatedOptionButton(
text: 'Option 1',
isSelected: false,
onTap: () {},
textStyle: const TextStyle(fontSize: 20),
),
),
),
);
expect(find.byType(AnimatedOptionButton), findsOneWidget);
});
testWidgets('animates between selected and unselected states', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: StatefulBuilder(
builder: (context, setState) {
return Scaffold(
body: AnimatedOptionButton(
text: 'Option 1',
isSelected: false,
onTap: () {
setState(() {});
},
),
);
},
),
),
);
expect(find.byType(AnimatedOptionButton), findsOneWidget);
});
});
}
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/animated_option_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('AnimatedOptionButton', () {
testWidgets('displays animated option button', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: AnimatedOptionButton(
text: 'Option 1',
isSelected: false,
onTap: () {},
),
),
),
);
expect(find.byType(AnimatedOptionButton), findsOneWidget);
expect(find.text('Option 1'), findsOneWidget);
});
testWidgets('displays selected state', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: AnimatedOptionButton(
text: 'Option 1',
isSelected: true,
onTap: () {},
),
),
),
);
expect(find.byType(AnimatedOptionButton), findsOneWidget);
expect(find.text('Option 1'), findsOneWidget);
});
testWidgets('calls onTap when tapped', (tester) async {
bool tapped = false;
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: AnimatedOptionButton(
text: 'Option 1',
isSelected: false,
onTap: () {
tapped = true;
},
),
),
),
);
await tester.tap(find.byType(AnimatedOptionButton));
await tester.pump();
expect(tapped, true);
});
testWidgets('accepts custom text style', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: AnimatedOptionButton(
text: 'Option 1',
isSelected: false,
onTap: () {},
textStyle: const TextStyle(fontSize: 20),
),
),
),
);
expect(find.byType(AnimatedOptionButton), findsOneWidget);
});
testWidgets('animates between selected and unselected states', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: StatefulBuilder(
builder: (context, setState) {
return Scaffold(
body: AnimatedOptionButton(
text: 'Option 1',
isSelected: false,
onTap: () {
setState(() {});
},
),
);
},
),
),
);
expect(find.byType(AnimatedOptionButton), findsOneWidget);
});
});
}

View File

@@ -1,70 +1,74 @@
import 'package:eatvio_app/core/widgets/base_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('BaseButton', () {
testWidgets('renders as SizedBox.shrink', (tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: BaseButton(
text: 'Test Button',
onPressed: () {},
),
),
),
);
expect(find.byType(BaseButton), findsOneWidget);
expect(find.byType(SizedBox), findsWidgets);
});
testWidgets('accepts all parameters', (tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: BaseButton(
text: 'Test Button',
onPressed: () {},
buttonStyle: const ButtonStyle(),
buttonTextStyle: const TextStyle(),
isDisabled: false,
height: 50.0,
width: 100.0,
margin: const EdgeInsets.all(10),
alignment: Alignment.center,
),
),
),
);
expect(find.byType(BaseButton), findsOneWidget);
});
});
}
import 'package:eatvio_app/core/widgets/base_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('BaseButton', () {
testWidgets('renders as SizedBox.shrink', (tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: BaseButton(
text: 'Test Button',
onPressed: () {},
),
),
),
);
expect(find.byType(BaseButton), findsOneWidget);
expect(find.byType(SizedBox), findsWidgets);
});
testWidgets('accepts all parameters', (tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: BaseButton(
text: 'Test Button',
onPressed: () {},
buttonStyle: const ButtonStyle(),
buttonTextStyle: const TextStyle(),
isDisabled: false,
height: 50.0,
width: 100.0,
margin: const EdgeInsets.all(10),
alignment: Alignment.center,
),
),
),
);
expect(find.byType(BaseButton), findsOneWidget);
});
});
}

View File

@@ -1,152 +1,156 @@
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/bottom_sheet_with_blur.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('showBottomSheetWithBlur', () {
testWidgets('shows bottom sheet with blur', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Builder(
builder: (context) {
return Scaffold(
body: ElevatedButton(
onPressed: () {
showBottomSheetWithBlur(
context: context,
child: const Text('Test Content'),
);
},
child: const Text('Show Bottom Sheet'),
),
);
},
),
),
);
await tester.tap(find.text('Show Bottom Sheet'));
await tester.pumpAndSettle();
expect(find.text('Test Content'), findsOneWidget);
});
testWidgets('shows bottom sheet without blur when hasBlur is false', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Builder(
builder: (context) {
return Scaffold(
body: ElevatedButton(
onPressed: () {
showBottomSheetWithBlur(
context: context,
child: const Text('Test Content'),
hasBlur: false,
);
},
child: const Text('Show Bottom Sheet'),
),
);
},
),
),
);
await tester.tap(find.text('Show Bottom Sheet'));
await tester.pumpAndSettle();
expect(find.text('Test Content'), findsOneWidget);
});
testWidgets('accepts custom height', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Builder(
builder: (context) {
return Scaffold(
body: ElevatedButton(
onPressed: () {
showBottomSheetWithBlur(
context: context,
child: const Text('Test Content'),
height: 300.0,
);
},
child: const Text('Show Bottom Sheet'),
),
);
},
),
),
);
await tester.tap(find.text('Show Bottom Sheet'));
await tester.pumpAndSettle();
expect(find.text('Test Content'), findsOneWidget);
});
testWidgets('can be dismissed', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Builder(
builder: (context) {
return Scaffold(
body: ElevatedButton(
onPressed: () {
showBottomSheetWithBlur(
context: context,
child: const Text('Test Content'),
);
},
child: const Text('Show Bottom Sheet'),
),
);
},
),
),
);
await tester.tap(find.text('Show Bottom Sheet'));
await tester.pumpAndSettle();
expect(find.text('Test Content'), findsOneWidget);
await tester.tapAt(const Offset(0, 0));
await tester.pumpAndSettle();
expect(find.text('Test Content'), findsNothing);
});
});
}
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/bottom_sheet_with_blur.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('showBottomSheetWithBlur', () {
testWidgets('shows bottom sheet with blur', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Builder(
builder: (context) {
return Scaffold(
body: ElevatedButton(
onPressed: () {
showBottomSheetWithBlur(
context: context,
child: const Text('Test Content'),
);
},
child: const Text('Show Bottom Sheet'),
),
);
},
),
),
);
await tester.tap(find.text('Show Bottom Sheet'));
await tester.pumpAndSettle();
expect(find.text('Test Content'), findsOneWidget);
});
testWidgets('shows bottom sheet without blur when hasBlur is false', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Builder(
builder: (context) {
return Scaffold(
body: ElevatedButton(
onPressed: () {
showBottomSheetWithBlur(
context: context,
child: const Text('Test Content'),
hasBlur: false,
);
},
child: const Text('Show Bottom Sheet'),
),
);
},
),
),
);
await tester.tap(find.text('Show Bottom Sheet'));
await tester.pumpAndSettle();
expect(find.text('Test Content'), findsOneWidget);
});
testWidgets('accepts custom height', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Builder(
builder: (context) {
return Scaffold(
body: ElevatedButton(
onPressed: () {
showBottomSheetWithBlur(
context: context,
child: const Text('Test Content'),
height: 300.0,
);
},
child: const Text('Show Bottom Sheet'),
),
);
},
),
),
);
await tester.tap(find.text('Show Bottom Sheet'));
await tester.pumpAndSettle();
expect(find.text('Test Content'), findsOneWidget);
});
testWidgets('can be dismissed', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Builder(
builder: (context) {
return Scaffold(
body: ElevatedButton(
onPressed: () {
showBottomSheetWithBlur(
context: context,
child: const Text('Test Content'),
);
},
child: const Text('Show Bottom Sheet'),
),
);
},
),
),
);
await tester.tap(find.text('Show Bottom Sheet'));
await tester.pumpAndSettle();
expect(find.text('Test Content'), findsOneWidget);
await tester.tapAt(const Offset(0, 0));
await tester.pumpAndSettle();
expect(find.text('Test Content'), findsNothing);
});
});
}

View File

@@ -1,113 +1,117 @@
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/cpfc_container.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('CpfcContainer', () {
Widget createTestWidget({
required double calories,
required double proteins,
required double fats,
required double carbohydrates,
}) {
return MaterialApp(
theme: ThemeHelper().themeData(),
localizationsDelegates: const [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: const [Locale('ru'), Locale('en')],
locale: const Locale('ru'),
home: Scaffold(
body: CpfcContainer(
calories: calories,
proteins: proteins,
fats: fats,
carbohydrates: carbohydrates,
),
),
);
}
testWidgets('displays calories, proteins, fats, and carbohydrates', (tester) async {
await tester.pumpWidget(
createTestWidget(
calories: 2000.0,
proteins: 150.0,
fats: 65.0,
carbohydrates: 250.0,
),
);
await tester.pumpAndSettle();
expect(find.byType(CpfcContainer), findsOneWidget);
expect(find.text('2000.0'), findsOneWidget);
expect(find.text('150.0'), findsOneWidget);
expect(find.text('65.0'), findsOneWidget);
expect(find.text('250.0'), findsOneWidget);
});
testWidgets('displays zero values', (tester) async {
await tester.pumpWidget(
createTestWidget(
calories: 0.0,
proteins: 0.0,
fats: 0.0,
carbohydrates: 0.0,
),
);
await tester.pumpAndSettle();
expect(find.byType(CpfcContainer), findsOneWidget);
expect(find.text('0.0'), findsNWidgets(4));
});
testWidgets('displays decimal values correctly', (tester) async {
await tester.pumpWidget(
createTestWidget(
calories: 1234.567,
proteins: 98.765,
fats: 45.321,
carbohydrates: 234.567,
),
);
await tester.pumpAndSettle();
expect(find.byType(CpfcContainer), findsOneWidget);
expect(find.text('1234.6'), findsOneWidget);
expect(find.text('98.8'), findsOneWidget);
expect(find.text('45.3'), findsOneWidget);
expect(find.text('234.6'), findsOneWidget);
});
});
}
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/cpfc_container.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('CpfcContainer', () {
Widget createTestWidget({
required double calories,
required double proteins,
required double fats,
required double carbohydrates,
}) {
return MaterialApp(
theme: ThemeHelper().themeData(),
localizationsDelegates: const [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: const [Locale('ru'), Locale('en')],
locale: const Locale('ru'),
home: Scaffold(
body: CpfcContainer(
calories: calories,
proteins: proteins,
fats: fats,
carbohydrates: carbohydrates,
),
),
);
}
testWidgets('displays calories, proteins, fats, and carbohydrates', (tester) async {
await tester.pumpWidget(
createTestWidget(
calories: 2000.0,
proteins: 150.0,
fats: 65.0,
carbohydrates: 250.0,
),
);
await tester.pumpAndSettle();
expect(find.byType(CpfcContainer), findsOneWidget);
expect(find.text('2000.0'), findsOneWidget);
expect(find.text('150.0'), findsOneWidget);
expect(find.text('65.0'), findsOneWidget);
expect(find.text('250.0'), findsOneWidget);
});
testWidgets('displays zero values', (tester) async {
await tester.pumpWidget(
createTestWidget(
calories: 0.0,
proteins: 0.0,
fats: 0.0,
carbohydrates: 0.0,
),
);
await tester.pumpAndSettle();
expect(find.byType(CpfcContainer), findsOneWidget);
expect(find.text('0.0'), findsNWidgets(4));
});
testWidgets('displays decimal values correctly', (tester) async {
await tester.pumpWidget(
createTestWidget(
calories: 1234.567,
proteins: 98.765,
fats: 45.321,
carbohydrates: 234.567,
),
);
await tester.pumpAndSettle();
expect(find.byType(CpfcContainer), findsOneWidget);
expect(find.text('1234.6'), findsOneWidget);
expect(find.text('98.8'), findsOneWidget);
expect(find.text('45.3'), findsOneWidget);
expect(find.text('234.6'), findsOneWidget);
});
});
}

View File

@@ -1,181 +1,185 @@
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/custom_search_bar.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('CustomSearchBar', () {
testWidgets('displays custom search bar', (tester) async {
final controller = TextEditingController();
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: CustomSearchBar(
searchController: controller,
onChanged: (value) {},
),
),
),
);
expect(find.byType(CustomSearchBar), findsOneWidget);
expect(find.byType(TextFormField), findsOneWidget);
});
testWidgets('displays search icon when enableIcon is true', (tester) async {
final controller = TextEditingController();
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: CustomSearchBar(
searchController: controller,
onChanged: (value) {},
enableIcon: true,
),
),
),
);
expect(find.byIcon(Icons.search), findsOneWidget);
});
testWidgets('does not display search icon when enableIcon is false', (tester) async {
final controller = TextEditingController();
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: CustomSearchBar(
searchController: controller,
onChanged: (value) {},
enableIcon: false,
),
),
),
);
expect(find.byIcon(Icons.search), findsNothing);
});
testWidgets('calls onChanged when text is entered', (tester) async {
final controller = TextEditingController();
String? changedValue;
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: CustomSearchBar(
searchController: controller,
onChanged: (value) {
changedValue = value;
},
),
),
),
);
await tester.enterText(find.byType(TextFormField), 'test');
await tester.pump();
expect(changedValue, 'test');
});
testWidgets('displays hint text', (tester) async {
final controller = TextEditingController();
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: CustomSearchBar(
searchController: controller,
onChanged: (value) {},
),
),
),
);
expect(find.text('Поиск'), findsOneWidget);
});
testWidgets('accepts custom width', (tester) async {
final controller = TextEditingController();
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: CustomSearchBar(
searchController: controller,
onChanged: (value) {},
width: 200.0,
),
),
),
);
expect(find.byType(CustomSearchBar), findsOneWidget);
});
testWidgets('accepts custom backgroundColor', (tester) async {
final controller = TextEditingController();
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: CustomSearchBar(
searchController: controller,
onChanged: (value) {},
backgroundColor: Colors.red,
),
),
),
);
expect(find.byType(CustomSearchBar), findsOneWidget);
});
testWidgets('accepts custom borderRadius', (tester) async {
final controller = TextEditingController();
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: CustomSearchBar(
searchController: controller,
onChanged: (value) {},
borderRadius: 20.0,
),
),
),
);
expect(find.byType(CustomSearchBar), findsOneWidget);
});
});
}
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/custom_search_bar.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('CustomSearchBar', () {
testWidgets('displays custom search bar', (tester) async {
final controller = TextEditingController();
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: CustomSearchBar(
searchController: controller,
onChanged: (value) {},
),
),
),
);
expect(find.byType(CustomSearchBar), findsOneWidget);
expect(find.byType(TextFormField), findsOneWidget);
});
testWidgets('displays search icon when enableIcon is true', (tester) async {
final controller = TextEditingController();
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: CustomSearchBar(
searchController: controller,
onChanged: (value) {},
enableIcon: true,
),
),
),
);
expect(find.byIcon(Icons.search), findsOneWidget);
});
testWidgets('does not display search icon when enableIcon is false', (tester) async {
final controller = TextEditingController();
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: CustomSearchBar(
searchController: controller,
onChanged: (value) {},
enableIcon: false,
),
),
),
);
expect(find.byIcon(Icons.search), findsNothing);
});
testWidgets('calls onChanged when text is entered', (tester) async {
final controller = TextEditingController();
String? changedValue;
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: CustomSearchBar(
searchController: controller,
onChanged: (value) {
changedValue = value;
},
),
),
),
);
await tester.enterText(find.byType(TextFormField), 'test');
await tester.pump();
expect(changedValue, 'test');
});
testWidgets('displays hint text', (tester) async {
final controller = TextEditingController();
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: CustomSearchBar(
searchController: controller,
onChanged: (value) {},
),
),
),
);
expect(find.text('Поиск'), findsOneWidget);
});
testWidgets('accepts custom width', (tester) async {
final controller = TextEditingController();
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: CustomSearchBar(
searchController: controller,
onChanged: (value) {},
width: 200.0,
),
),
),
);
expect(find.byType(CustomSearchBar), findsOneWidget);
});
testWidgets('accepts custom backgroundColor', (tester) async {
final controller = TextEditingController();
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: CustomSearchBar(
searchController: controller,
onChanged: (value) {},
backgroundColor: Colors.red,
),
),
),
);
expect(find.byType(CustomSearchBar), findsOneWidget);
});
testWidgets('accepts custom borderRadius', (tester) async {
final controller = TextEditingController();
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: CustomSearchBar(
searchController: controller,
onChanged: (value) {},
borderRadius: 20.0,
),
),
),
);
expect(find.byType(CustomSearchBar), findsOneWidget);
});
});
}

View File

@@ -1,74 +1,78 @@
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/item_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('ItemWidget', () {
testWidgets('displays text with icon', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: ItemWidget(text: 'Test item'),
),
),
);
expect(find.byType(ItemWidget), findsOneWidget);
expect(find.text('Test item'), findsOneWidget);
});
testWidgets('displays reversed layout when reversed is true', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: ItemWidget(text: 'Test item', reversed: true),
),
),
);
expect(find.byType(ItemWidget), findsOneWidget);
expect(find.text('Test item'), findsOneWidget);
});
testWidgets('applies custom icon size', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: ItemWidget(text: 'Test item', iconSize: 30),
),
),
);
expect(find.byType(ItemWidget), findsOneWidget);
});
});
}
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/item_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('ItemWidget', () {
testWidgets('displays text with icon', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: ItemWidget(text: 'Test item'),
),
),
);
expect(find.byType(ItemWidget), findsOneWidget);
expect(find.text('Test item'), findsOneWidget);
});
testWidgets('displays reversed layout when reversed is true', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: ItemWidget(text: 'Test item', reversed: true),
),
),
);
expect(find.byType(ItemWidget), findsOneWidget);
expect(find.text('Test item'), findsOneWidget);
});
testWidgets('applies custom icon size', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: ItemWidget(text: 'Test item', iconSize: 30),
),
),
);
expect(find.byType(ItemWidget), findsOneWidget);
});
});
}

View File

@@ -1,59 +1,63 @@
import 'package:eatvio_app/core/widgets/loader.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('Loader', () {
testWidgets('displays loader widget', (tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: Loader(),
),
),
);
expect(find.byType(Loader), findsOneWidget);
expect(find.byType(Center), findsOneWidget);
});
testWidgets('has correct dimensions', (tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: Loader(),
),
),
);
final sizedBox = tester.widget<SizedBox>(find.byType(SizedBox));
expect(sizedBox.height, 42);
expect(sizedBox.width, 42);
});
});
}
import 'package:eatvio_app/core/widgets/loader.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('Loader', () {
testWidgets('displays loader widget', (tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: Loader(),
),
),
);
expect(find.byType(Loader), findsOneWidget);
expect(find.byType(Center), findsOneWidget);
});
testWidgets('has correct dimensions', (tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: Loader(),
),
),
);
final sizedBox = tester.widget<SizedBox>(find.byType(SizedBox));
expect(sizedBox.height, 42);
expect(sizedBox.width, 42);
});
});
}

View File

@@ -1,113 +1,117 @@
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/main_background_bouble.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('MainBackgroundBouble', () {
testWidgets('displays child widget', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: MainBackgroundBouble(
child: Text('Test'),
),
),
),
);
expect(find.byType(MainBackgroundBouble), findsOneWidget);
expect(find.text('Test'), findsOneWidget);
});
testWidgets('applies custom width', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: MainBackgroundBouble(
width: 200,
child: Text('Test'),
),
),
),
);
expect(find.byType(MainBackgroundBouble), findsOneWidget);
});
testWidgets('applies shadow when enableShadow is true', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: MainBackgroundBouble(
enableShadow: true,
child: Text('Test'),
),
),
),
);
expect(find.byType(MainBackgroundBouble), findsOneWidget);
});
testWidgets('applies error border when hasError is true', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: MainBackgroundBouble(
hasError: true,
child: Text('Test'),
),
),
),
);
expect(find.byType(MainBackgroundBouble), findsOneWidget);
});
testWidgets('applies custom padding', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: MainBackgroundBouble(
padding: EdgeInsets.all(16),
child: Text('Test'),
),
),
),
);
expect(find.byType(MainBackgroundBouble), findsOneWidget);
});
});
}
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/main_background_bouble.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('MainBackgroundBouble', () {
testWidgets('displays child widget', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: MainBackgroundBouble(
child: Text('Test'),
),
),
),
);
expect(find.byType(MainBackgroundBouble), findsOneWidget);
expect(find.text('Test'), findsOneWidget);
});
testWidgets('applies custom width', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: MainBackgroundBouble(
width: 200,
child: Text('Test'),
),
),
),
);
expect(find.byType(MainBackgroundBouble), findsOneWidget);
});
testWidgets('applies shadow when enableShadow is true', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: MainBackgroundBouble(
enableShadow: true,
child: Text('Test'),
),
),
),
);
expect(find.byType(MainBackgroundBouble), findsOneWidget);
});
testWidgets('applies error border when hasError is true', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: MainBackgroundBouble(
hasError: true,
child: Text('Test'),
),
),
),
);
expect(find.byType(MainBackgroundBouble), findsOneWidget);
});
testWidgets('applies custom padding', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: MainBackgroundBouble(
padding: EdgeInsets.all(16),
child: Text('Test'),
),
),
),
);
expect(find.byType(MainBackgroundBouble), findsOneWidget);
});
});
}

View File

@@ -1,93 +1,97 @@
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/marketing_bottom_sheet.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('MarketingBottomSheet', () {
Widget createTestWidget(Widget child) {
return MaterialApp(
theme: ThemeHelper().themeData(),
localizationsDelegates: const [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: S.delegate.supportedLocales,
home: Scaffold(
body: child,
),
);
}
testWidgets('displays marketing bottom sheet', (tester) async {
await tester.pumpWidget(
createTestWidget(
const MarketingBottomSheet(),
),
);
expect(find.byType(MarketingBottomSheet), findsOneWidget);
});
testWidgets('shows marketing bottom sheet via function', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
localizationsDelegates: const [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: S.delegate.supportedLocales,
home: Builder(
builder: (context) {
return Scaffold(
body: ElevatedButton(
onPressed: () {
showMarketingBottomSheet(context);
},
child: const Text('Show'),
),
);
},
),
),
);
await tester.tap(find.text('Show'));
await tester.pumpAndSettle();
expect(find.byType(MarketingBottomSheet), findsOneWidget);
});
});
}
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/marketing_bottom_sheet.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('MarketingBottomSheet', () {
Widget createTestWidget(Widget child) {
return MaterialApp(
theme: ThemeHelper().themeData(),
localizationsDelegates: const [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: S.delegate.supportedLocales,
home: Scaffold(
body: child,
),
);
}
testWidgets('displays marketing bottom sheet', (tester) async {
await tester.pumpWidget(
createTestWidget(
const MarketingBottomSheet(),
),
);
expect(find.byType(MarketingBottomSheet), findsOneWidget);
});
testWidgets('shows marketing bottom sheet via function', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
localizationsDelegates: const [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: S.delegate.supportedLocales,
home: Builder(
builder: (context) {
return Scaffold(
body: ElevatedButton(
onPressed: () {
showMarketingBottomSheet(context);
},
child: const Text('Show'),
),
);
},
),
),
);
await tester.tap(find.text('Show'));
await tester.pumpAndSettle();
expect(find.byType(MarketingBottomSheet), findsOneWidget);
});
});
}

View File

@@ -1,82 +1,86 @@
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/option_widget.dart';
import 'package:eatvio_app/features/feed/models/plan_pagination_model.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('OptionWidget', () {
Widget createTestWidget(Widget child) {
return MaterialApp(
theme: ThemeHelper().themeData(),
localizationsDelegates: const [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: S.delegate.supportedLocales,
home: Scaffold(body: child),
);
}
testWidgets('returns SizedBox.shrink when option is null', (tester) async {
await tester.pumpWidget(createTestWidget(const OptionWidget(option: null, duration: 7)));
expect(find.byType(OptionWidget), findsOneWidget);
expect(find.byType(SizedBox), findsWidgets);
});
testWidgets('displays option widget with option', (tester) async {
const option = PacketOptions(items: ['Item 1', 'Item 2'], price: 1000.0, short: 'Short', description: 'Description', hasPersonalDiet: false);
await tester.pumpWidget(createTestWidget(const OptionWidget(option: option, duration: 7)));
expect(find.byType(OptionWidget), findsOneWidget);
expect(find.text('Short'), findsOneWidget);
expect(find.text('Description'), findsOneWidget);
});
testWidgets('displays option widget with personal diet', (tester) async {
const option = PacketOptions(items: ['Item 1'], price: 1000.0, short: 'Short', description: 'Description', hasPersonalDiet: true);
await tester.pumpWidget(createTestWidget(const OptionWidget(option: option, duration: 7)));
expect(find.byType(OptionWidget), findsOneWidget);
});
testWidgets('hides duration when disableDuration is true', (tester) async {
const option = PacketOptions(items: ['Item 1'], price: 1000.0, short: 'Short', description: 'Description', hasPersonalDiet: false);
await tester.pumpWidget(createTestWidget(const OptionWidget(option: option, duration: 7, disableDuration: true)));
expect(find.byType(OptionWidget), findsOneWidget);
});
});
}
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/widgets/option_widget.dart';
import 'package:eatvio_app/features/feed/models/plan_pagination_model.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('OptionWidget', () {
Widget createTestWidget(Widget child) {
return MaterialApp(
theme: ThemeHelper().themeData(),
localizationsDelegates: const [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: S.delegate.supportedLocales,
home: Scaffold(body: child),
);
}
testWidgets('returns SizedBox.shrink when option is null', (tester) async {
await tester.pumpWidget(createTestWidget(const OptionWidget(option: null, duration: 7)));
expect(find.byType(OptionWidget), findsOneWidget);
expect(find.byType(SizedBox), findsWidgets);
});
testWidgets('displays option widget with option', (tester) async {
const option = PacketOptions(items: ['Item 1', 'Item 2'], price: 1000.0, short: 'Short', description: 'Description', hasPersonalDiet: false);
await tester.pumpWidget(createTestWidget(const OptionWidget(option: option, duration: 7)));
expect(find.byType(OptionWidget), findsOneWidget);
expect(find.text('Short'), findsOneWidget);
expect(find.text('Description'), findsOneWidget);
});
testWidgets('displays option widget with personal diet', (tester) async {
const option = PacketOptions(items: ['Item 1'], price: 1000.0, short: 'Short', description: 'Description', hasPersonalDiet: true);
await tester.pumpWidget(createTestWidget(const OptionWidget(option: option, duration: 7)));
expect(find.byType(OptionWidget), findsOneWidget);
});
testWidgets('hides duration when disableDuration is true', (tester) async {
const option = PacketOptions(items: ['Item 1'], price: 1000.0, short: 'Short', description: 'Description', hasPersonalDiet: false);
await tester.pumpWidget(createTestWidget(const OptionWidget(option: option, duration: 7, disableDuration: true)));
expect(find.byType(OptionWidget), findsOneWidget);
});
});
}

View File

@@ -1,88 +1,92 @@
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/create_diet/presentation/widgets/error_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('ValidationErrorWidget', () {
testWidgets('displays error message', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: ValidationErrorWidget(error: 'Test error message'),
),
),
);
expect(find.byType(ValidationErrorWidget), findsOneWidget);
expect(find.text('Test error message'), findsOneWidget);
});
testWidgets('displays error icon', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: ValidationErrorWidget(error: 'Test error'),
),
),
);
expect(find.byType(ValidationErrorWidget), findsOneWidget);
});
testWidgets('handles long error messages', (tester) async {
final longError = 'A' * 100;
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: ValidationErrorWidget(error: longError),
),
),
);
expect(find.byType(ValidationErrorWidget), findsOneWidget);
expect(find.text(longError), findsOneWidget);
});
testWidgets('displays empty error message', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: ValidationErrorWidget(error: ''),
),
),
);
expect(find.byType(ValidationErrorWidget), findsOneWidget);
});
});
}
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/create_diet/presentation/widgets/error_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('ValidationErrorWidget', () {
testWidgets('displays error message', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: ValidationErrorWidget(error: 'Test error message'),
),
),
);
expect(find.byType(ValidationErrorWidget), findsOneWidget);
expect(find.text('Test error message'), findsOneWidget);
});
testWidgets('displays error icon', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: ValidationErrorWidget(error: 'Test error'),
),
),
);
expect(find.byType(ValidationErrorWidget), findsOneWidget);
});
testWidgets('handles long error messages', (tester) async {
final longError = 'A' * 100;
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: ValidationErrorWidget(error: longError),
),
),
);
expect(find.byType(ValidationErrorWidget), findsOneWidget);
expect(find.text(longError), findsOneWidget);
});
testWidgets('displays empty error message', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: ValidationErrorWidget(error: ''),
),
),
);
expect(find.byType(ValidationErrorWidget), findsOneWidget);
});
});
}

View File

@@ -1,97 +1,101 @@
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/diary/presentation/widgets/chosen_diet_widget.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('ChosenDietWidgetContent', () {
Widget createTestWidget(Widget child) {
return MaterialApp(
theme: ThemeHelper().themeData(),
localizationsDelegates: const [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: S.delegate.supportedLocales,
home: Scaffold(
body: child,
),
);
}
testWidgets('displays chosen diet widget content', (tester) async {
await tester.pumpWidget(
createTestWidget(
const ChosenDietWidgetContent(
currentDietDay: 5,
dietName: 'Test Diet',
dietDuration: 14,
dietId: 1,
),
),
);
expect(find.byType(ChosenDietWidgetContent), findsOneWidget);
expect(find.text('Test Diet'), findsOneWidget);
});
testWidgets('displays current day and duration', (tester) async {
await tester.pumpWidget(
createTestWidget(
const ChosenDietWidgetContent(
currentDietDay: 7,
dietName: 'Test Diet',
dietDuration: 21,
dietId: 1,
),
),
);
expect(find.byType(ChosenDietWidgetContent), findsOneWidget);
});
testWidgets('displays diet name with underline', (tester) async {
await tester.pumpWidget(
createTestWidget(
const ChosenDietWidgetContent(
currentDietDay: 1,
dietName: 'My Diet',
dietDuration: 7,
dietId: 1,
),
),
);
expect(find.text('My Diet'), findsOneWidget);
});
});
}
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/diary/presentation/widgets/chosen_diet_widget.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('ChosenDietWidgetContent', () {
Widget createTestWidget(Widget child) {
return MaterialApp(
theme: ThemeHelper().themeData(),
localizationsDelegates: const [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: S.delegate.supportedLocales,
home: Scaffold(
body: child,
),
);
}
testWidgets('displays chosen diet widget content', (tester) async {
await tester.pumpWidget(
createTestWidget(
const ChosenDietWidgetContent(
currentDietDay: 5,
dietName: 'Test Diet',
dietDuration: 14,
dietId: 1,
),
),
);
expect(find.byType(ChosenDietWidgetContent), findsOneWidget);
expect(find.text('Test Diet'), findsOneWidget);
});
testWidgets('displays current day and duration', (tester) async {
await tester.pumpWidget(
createTestWidget(
const ChosenDietWidgetContent(
currentDietDay: 7,
dietName: 'Test Diet',
dietDuration: 21,
dietId: 1,
),
),
);
expect(find.byType(ChosenDietWidgetContent), findsOneWidget);
});
testWidgets('displays diet name with underline', (tester) async {
await tester.pumpWidget(
createTestWidget(
const ChosenDietWidgetContent(
currentDietDay: 1,
dietName: 'My Diet',
dietDuration: 7,
dietId: 1,
),
),
);
expect(find.text('My Diet'), findsOneWidget);
});
});
}

View File

@@ -1,75 +1,79 @@
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/diary/presentation/widgets/comment_container.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('CommentContainer', () {
testWidgets('displays comment text', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: CommentContainer(comment: 'Test comment'),
),
),
);
expect(find.byType(CommentContainer), findsOneWidget);
expect(find.text('Test comment'), findsOneWidget);
});
testWidgets('displays empty comment', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: CommentContainer(comment: ''),
),
),
);
expect(find.byType(CommentContainer), findsOneWidget);
});
testWidgets('displays long comment', (tester) async {
const longComment = 'This is a very long comment that should be displayed properly in the container';
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: CommentContainer(comment: longComment),
),
),
);
expect(find.byType(CommentContainer), findsOneWidget);
expect(find.text(longComment), findsOneWidget);
});
});
}
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/diary/presentation/widgets/comment_container.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('CommentContainer', () {
testWidgets('displays comment text', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: CommentContainer(comment: 'Test comment'),
),
),
);
expect(find.byType(CommentContainer), findsOneWidget);
expect(find.text('Test comment'), findsOneWidget);
});
testWidgets('displays empty comment', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: CommentContainer(comment: ''),
),
),
);
expect(find.byType(CommentContainer), findsOneWidget);
});
testWidgets('displays long comment', (tester) async {
const longComment = 'This is a very long comment that should be displayed properly in the container';
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: CommentContainer(comment: longComment),
),
),
);
expect(find.byType(CommentContainer), findsOneWidget);
expect(find.text(longComment), findsOneWidget);
});
});
}

View File

@@ -1,70 +1,74 @@
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/diary/presentation/widgets/finish_day_button_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('FinishDayButtonWidget', () {
testWidgets('displays finish day button', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: FinishDayButtonWidget(
onPressed: () async {},
),
),
),
);
expect(find.byType(FinishDayButtonWidget), findsOneWidget);
expect(find.text('Закончить день'), findsOneWidget);
});
testWidgets('calls onPressed when tapped', (tester) async {
bool wasCalled = false;
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: FinishDayButtonWidget(
onPressed: () async {
wasCalled = true;
},
),
),
),
);
await tester.tap(find.text('Закончить день'));
await tester.pump();
expect(wasCalled, isTrue);
});
});
}
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/diary/presentation/widgets/finish_day_button_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('FinishDayButtonWidget', () {
testWidgets('displays finish day button', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: FinishDayButtonWidget(
onPressed: () async {},
),
),
),
);
expect(find.byType(FinishDayButtonWidget), findsOneWidget);
expect(find.text('Закончить день'), findsOneWidget);
});
testWidgets('calls onPressed when tapped', (tester) async {
bool wasCalled = false;
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: FinishDayButtonWidget(
onPressed: () async {
wasCalled = true;
},
),
),
),
);
await tester.tap(find.text('Закончить день'));
await tester.pump();
expect(wasCalled, isTrue);
});
});
}

View File

@@ -1,107 +1,111 @@
import 'package:eatvio_app/features/diary/models/diary_day_model.dart';
import 'package:eatvio_app/features/diary/presentation/widgets/meal_summary_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('MealSummaryWidget', () {
testWidgets('displays meal summary with totals', (tester) async {
final portions = <PortionModel>[];
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: MealSummaryWidget(
portions: portions,
mealNumber: 1,
),
),
),
);
expect(find.byType(MealSummaryWidget), findsOneWidget);
});
testWidgets('hides when all totals are zero', (tester) async {
final portions = <PortionModel>[];
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: MealSummaryWidget(
portions: portions,
mealNumber: 1,
),
),
),
);
await tester.pumpAndSettle();
// Widget should be hidden (SizedBox.shrink) when totals are zero
expect(find.byType(MealSummaryWidget), findsOneWidget);
});
testWidgets('displays meal number', (tester) async {
final portions = <PortionModel>[];
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: MealSummaryWidget(
portions: portions,
mealNumber: 3,
),
),
),
);
expect(find.byType(MealSummaryWidget), findsOneWidget);
});
});
group('MealSummaryWidget.calculateMealTotals', () {
test('returns zero totals for empty portions list', () {
final result = MealSummaryWidget.calculateMealTotals([]);
expect(result['calories'], 0.0);
expect(result['proteins'], 0.0);
expect(result['fats'], 0.0);
expect(result['carbohydrates'], 0.0);
});
test('returns correct map structure', () {
final result = MealSummaryWidget.calculateMealTotals([]);
expect(result.containsKey('calories'), isTrue);
expect(result.containsKey('proteins'), isTrue);
expect(result.containsKey('fats'), isTrue);
expect(result.containsKey('carbohydrates'), isTrue);
});
});
}
import 'package:eatvio_app/features/diary/models/diary_day_model.dart';
import 'package:eatvio_app/features/diary/presentation/widgets/meal_summary_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('MealSummaryWidget', () {
testWidgets('displays meal summary with totals', (tester) async {
final portions = <PortionModel>[];
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: MealSummaryWidget(
portions: portions,
mealNumber: 1,
),
),
),
);
expect(find.byType(MealSummaryWidget), findsOneWidget);
});
testWidgets('hides when all totals are zero', (tester) async {
final portions = <PortionModel>[];
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: MealSummaryWidget(
portions: portions,
mealNumber: 1,
),
),
),
);
await tester.pumpAndSettle();
// Widget should be hidden (SizedBox.shrink) when totals are zero
expect(find.byType(MealSummaryWidget), findsOneWidget);
});
testWidgets('displays meal number', (tester) async {
final portions = <PortionModel>[];
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: MealSummaryWidget(
portions: portions,
mealNumber: 3,
),
),
),
);
expect(find.byType(MealSummaryWidget), findsOneWidget);
});
});
group('MealSummaryWidget.calculateMealTotals', () {
test('returns zero totals for empty portions list', () {
final result = MealSummaryWidget.calculateMealTotals([]);
expect(result['calories'], 0.0);
expect(result['proteins'], 0.0);
expect(result['fats'], 0.0);
expect(result['carbohydrates'], 0.0);
});
test('returns correct map structure', () {
final result = MealSummaryWidget.calculateMealTotals([]);
expect(result.containsKey('calories'), isTrue);
expect(result.containsKey('proteins'), isTrue);
expect(result.containsKey('fats'), isTrue);
expect(result.containsKey('carbohydrates'), isTrue);
});
});
}

View File

@@ -1,59 +1,63 @@
import 'package:eatvio_app/features/diary/presentation/widgets/product_loader_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('ProductLoaderWidget', () {
testWidgets('displays product loader widget', (tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: ProductLoaderWidget(),
),
),
);
expect(find.byType(ProductLoaderWidget), findsOneWidget);
expect(find.byType(CupertinoActivityIndicator), findsOneWidget);
});
testWidgets('displays ListTile with activity indicator', (tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: ProductLoaderWidget(),
),
),
);
expect(find.byType(ListTile), findsOneWidget);
expect(find.byType(CupertinoActivityIndicator), findsOneWidget);
});
});
}
import 'package:eatvio_app/features/diary/presentation/widgets/product_loader_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('ProductLoaderWidget', () {
testWidgets('displays product loader widget', (tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: ProductLoaderWidget(),
),
),
);
expect(find.byType(ProductLoaderWidget), findsOneWidget);
expect(find.byType(CupertinoActivityIndicator), findsOneWidget);
});
testWidgets('displays ListTile with activity indicator', (tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: ProductLoaderWidget(),
),
),
);
expect(find.byType(ListTile), findsOneWidget);
expect(find.byType(CupertinoActivityIndicator), findsOneWidget);
});
});
}

View File

@@ -1,125 +1,129 @@
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/diets/presentation/widgets/info_bouble.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('InfoBouble', () {
testWidgets('displays info bouble with children', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: InfoBouble(
children: [
Text('Test'),
Icon(Icons.star),
],
),
),
),
);
expect(find.byType(InfoBouble), findsOneWidget);
expect(find.text('Test'), findsOneWidget);
expect(find.byIcon(Icons.star), findsOneWidget);
});
testWidgets('displays with custom background color', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: InfoBouble(
backgroundColor: Colors.blue,
children: [
Text('Test'),
],
),
),
),
);
expect(find.byType(InfoBouble), findsOneWidget);
});
testWidgets('displays with custom radius', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: InfoBouble(
radius: 20,
children: [
Text('Test'),
],
),
),
),
);
expect(find.byType(InfoBouble), findsOneWidget);
});
testWidgets('displays with custom padding', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: InfoBouble(
padding: EdgeInsets.all(16),
children: [
Text('Test'),
],
),
),
),
);
expect(find.byType(InfoBouble), findsOneWidget);
});
testWidgets('displays with custom mainAxisAlignment', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: InfoBouble(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Test'),
],
),
),
),
);
expect(find.byType(InfoBouble), findsOneWidget);
});
});
}
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/diets/presentation/widgets/info_bouble.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('InfoBouble', () {
testWidgets('displays info bouble with children', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: InfoBouble(
children: [
Text('Test'),
Icon(Icons.star),
],
),
),
),
);
expect(find.byType(InfoBouble), findsOneWidget);
expect(find.text('Test'), findsOneWidget);
expect(find.byIcon(Icons.star), findsOneWidget);
});
testWidgets('displays with custom background color', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: InfoBouble(
backgroundColor: Colors.blue,
children: [
Text('Test'),
],
),
),
),
);
expect(find.byType(InfoBouble), findsOneWidget);
});
testWidgets('displays with custom radius', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: InfoBouble(
radius: 20,
children: [
Text('Test'),
],
),
),
),
);
expect(find.byType(InfoBouble), findsOneWidget);
});
testWidgets('displays with custom padding', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: InfoBouble(
padding: EdgeInsets.all(16),
children: [
Text('Test'),
],
),
),
),
);
expect(find.byType(InfoBouble), findsOneWidget);
});
testWidgets('displays with custom mainAxisAlignment', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: InfoBouble(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Test'),
],
),
),
),
);
expect(find.byType(InfoBouble), findsOneWidget);
});
});
}

View File

@@ -1,155 +1,159 @@
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/feed/presentation/widgets/choice_chip_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('ChoiceChipWidget', () {
testWidgets('displays chip with label', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: ChoiceChipWidget(
chipsLabelList: const ['Option 1', 'Option 2'],
index: 0,
selectedChipIndex: 0,
onSelected: (selected) {},
),
),
),
);
expect(find.byType(ChoiceChipWidget), findsOneWidget);
expect(find.text('Option 1'), findsOneWidget);
});
testWidgets('shows selected state when index matches selectedChipIndex', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: ChoiceChipWidget(
chipsLabelList: const ['Option 1', 'Option 2'],
index: 0,
selectedChipIndex: 0,
onSelected: (selected) {},
),
),
),
);
expect(find.byType(ChoiceChipWidget), findsOneWidget);
final chip = tester.widget<ChoiceChip>(find.byType(ChoiceChip));
expect(chip.selected, isTrue);
});
testWidgets('shows unselected state when index does not match', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: ChoiceChipWidget(
chipsLabelList: const ['Option 1', 'Option 2'],
index: 1,
selectedChipIndex: 0,
onSelected: (selected) {},
),
),
),
);
expect(find.byType(ChoiceChipWidget), findsOneWidget);
final chip = tester.widget<ChoiceChip>(find.byType(ChoiceChip));
expect(chip.selected, isFalse);
});
testWidgets('applies custom padding', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: ChoiceChipWidget(
chipsLabelList: const ['Option 1'],
index: 0,
selectedChipIndex: 0,
padding: const EdgeInsets.all(16),
onSelected: (selected) {},
),
),
),
);
expect(find.byType(ChoiceChipWidget), findsOneWidget);
});
testWidgets('applies custom colors', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: ChoiceChipWidget(
chipsLabelList: const ['Option 1'],
index: 0,
selectedChipIndex: 0,
activeColor: Colors.blue,
inactiveColor: Colors.grey,
onSelected: (selected) {},
),
),
),
);
expect(find.byType(ChoiceChipWidget), findsOneWidget);
});
testWidgets('calls onSelected when tapped', (tester) async {
bool wasCalled = false;
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: ChoiceChipWidget(
chipsLabelList: const ['Option 1'],
index: 0,
selectedChipIndex: 0,
onSelected: (selected) {
wasCalled = true;
},
),
),
),
);
await tester.tap(find.byType(ChoiceChip));
await tester.pump();
expect(wasCalled, isTrue);
});
});
}
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/feed/presentation/widgets/choice_chip_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('ChoiceChipWidget', () {
testWidgets('displays chip with label', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: ChoiceChipWidget(
chipsLabelList: const ['Option 1', 'Option 2'],
index: 0,
selectedChipIndex: 0,
onSelected: (selected) {},
),
),
),
);
expect(find.byType(ChoiceChipWidget), findsOneWidget);
expect(find.text('Option 1'), findsOneWidget);
});
testWidgets('shows selected state when index matches selectedChipIndex', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: ChoiceChipWidget(
chipsLabelList: const ['Option 1', 'Option 2'],
index: 0,
selectedChipIndex: 0,
onSelected: (selected) {},
),
),
),
);
expect(find.byType(ChoiceChipWidget), findsOneWidget);
final chip = tester.widget<ChoiceChip>(find.byType(ChoiceChip));
expect(chip.selected, isTrue);
});
testWidgets('shows unselected state when index does not match', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: ChoiceChipWidget(
chipsLabelList: const ['Option 1', 'Option 2'],
index: 1,
selectedChipIndex: 0,
onSelected: (selected) {},
),
),
),
);
expect(find.byType(ChoiceChipWidget), findsOneWidget);
final chip = tester.widget<ChoiceChip>(find.byType(ChoiceChip));
expect(chip.selected, isFalse);
});
testWidgets('applies custom padding', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: ChoiceChipWidget(
chipsLabelList: const ['Option 1'],
index: 0,
selectedChipIndex: 0,
padding: const EdgeInsets.all(16),
onSelected: (selected) {},
),
),
),
);
expect(find.byType(ChoiceChipWidget), findsOneWidget);
});
testWidgets('applies custom colors', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: ChoiceChipWidget(
chipsLabelList: const ['Option 1'],
index: 0,
selectedChipIndex: 0,
activeColor: Colors.blue,
inactiveColor: Colors.grey,
onSelected: (selected) {},
),
),
),
);
expect(find.byType(ChoiceChipWidget), findsOneWidget);
});
testWidgets('calls onSelected when tapped', (tester) async {
bool wasCalled = false;
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: Scaffold(
body: ChoiceChipWidget(
chipsLabelList: const ['Option 1'],
index: 0,
selectedChipIndex: 0,
onSelected: (selected) {
wasCalled = true;
},
),
),
),
);
await tester.tap(find.byType(ChoiceChip));
await tester.pump();
expect(wasCalled, isTrue);
});
});
}

View File

@@ -1,67 +1,71 @@
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/feed/presentation/widgets/filter_badge.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('FilterBadge', () {
testWidgets('displays filter badge widget', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: FilterBadge(
filterBottomSheet: Text('Filter Bottom Sheet'),
),
),
),
);
expect(find.byType(FilterBadge), findsOneWidget);
expect(find.byType(GestureDetector), findsOneWidget);
});
testWidgets('opens bottom sheet when tapped', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: FilterBadge(
filterBottomSheet: Text('Filter Bottom Sheet'),
),
),
),
);
await tester.tap(find.byType(FilterBadge));
await tester.pumpAndSettle();
expect(find.text('Filter Bottom Sheet'), findsOneWidget);
});
});
}
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/feed/presentation/widgets/filter_badge.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('FilterBadge', () {
testWidgets('displays filter badge widget', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: FilterBadge(
filterBottomSheet: Text('Filter Bottom Sheet'),
),
),
),
);
expect(find.byType(FilterBadge), findsOneWidget);
expect(find.byType(GestureDetector), findsOneWidget);
});
testWidgets('opens bottom sheet when tapped', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: FilterBadge(
filterBottomSheet: Text('Filter Bottom Sheet'),
),
),
),
);
await tester.tap(find.byType(FilterBadge));
await tester.pumpAndSettle();
expect(find.text('Filter Bottom Sheet'), findsOneWidget);
});
});
}

View File

@@ -1,75 +1,79 @@
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/finances_and_consultations_archive/presentation/widgets/status_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('StatusWidget', () {
testWidgets('displays canceled status', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: StatusWidget(status: Status.canceled),
),
),
);
expect(find.byType(StatusWidget), findsOneWidget);
expect(find.text('Отменён'), findsOneWidget);
});
testWidgets('displays success status', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: StatusWidget(status: Status.success),
),
),
);
expect(find.byType(StatusWidget), findsOneWidget);
expect(find.text('Успешно'), findsOneWidget);
});
testWidgets('displays inProgress status', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: StatusWidget(status: Status.inProgress),
),
),
);
expect(find.byType(StatusWidget), findsOneWidget);
expect(find.text('В процессе'), findsOneWidget);
});
});
}
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/finances_and_consultations_archive/presentation/widgets/status_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('StatusWidget', () {
testWidgets('displays canceled status', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: StatusWidget(status: Status.canceled),
),
),
);
expect(find.byType(StatusWidget), findsOneWidget);
expect(find.text('Отменён'), findsOneWidget);
});
testWidgets('displays success status', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: StatusWidget(status: Status.success),
),
),
);
expect(find.byType(StatusWidget), findsOneWidget);
expect(find.text('Успешно'), findsOneWidget);
});
testWidgets('displays inProgress status', (tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeHelper().themeData(),
home: const Scaffold(
body: StatusWidget(status: Status.inProgress),
),
),
);
expect(find.byType(StatusWidget), findsOneWidget);
expect(find.text('В процессе'), findsOneWidget);
});
});
}

View File

@@ -1,68 +1,72 @@
import 'package:eatvio_app/features/glossary/models/glossary_model.dart';
import 'package:eatvio_app/features/glossary/repositories/glossary_repository.dart';
import 'package:eatvio_app/features/glossary/services/glossary_service.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mocktail/mocktail.dart';
class MockGlossaryService extends Mock implements GlossaryService {}
void main() {
group('GlossaryRepository', () {
late GlossaryRepository repository;
late MockGlossaryService mockService;
setUp(() {
mockService = MockGlossaryService();
repository = GlossaryRepository(glossaryService: mockService);
});
test('getGlossaryListByQuery - успешный запрос', () async {
const query = 'test';
final mockGlossaries = <GlossaryModel>[];
final mockPagination = GlossaryPaginationModel(glossariesList: mockGlossaries);
when(() => mockService.getGlossaryByQuery(query: query))
.thenAnswer((_) async => mockPagination);
final result = await repository.getGlossaryListByQuery(query);
expect(result, mockGlossaries);
verify(() => mockService.getGlossaryByQuery(query: query)).called(1);
});
test('getGlossaryListByQuery - пробрасывает ошибку', () async {
const query = 'test';
when(() => mockService.getGlossaryByQuery(query: query))
.thenThrow(Exception('Error'));
expect(() => repository.getGlossaryListByQuery(query), throwsException);
});
});
}
import 'package:eatvio_app/features/glossary/models/glossary_model.dart';
import 'package:eatvio_app/features/glossary/repositories/glossary_repository.dart';
import 'package:eatvio_app/features/glossary/services/glossary_service.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mocktail/mocktail.dart';
class MockGlossaryService extends Mock implements GlossaryService {}
void main() {
group('GlossaryRepository', () {
late GlossaryRepository repository;
late MockGlossaryService mockService;
setUp(() {
mockService = MockGlossaryService();
repository = GlossaryRepository(glossaryService: mockService);
});
test('getGlossaryListByQuery - успешный запрос', () async {
const query = 'test';
final mockGlossaries = <GlossaryModel>[];
final mockPagination = GlossaryPaginationModel(glossariesList: mockGlossaries);
when(() => mockService.getGlossaryByQuery(query: query))
.thenAnswer((_) async => mockPagination);
final result = await repository.getGlossaryListByQuery(query);
expect(result, mockGlossaries);
verify(() => mockService.getGlossaryByQuery(query: query)).called(1);
});
test('getGlossaryListByQuery - пробрасывает ошибку', () async {
const query = 'test';
when(() => mockService.getGlossaryByQuery(query: query))
.thenThrow(Exception('Error'));
expect(() => repository.getGlossaryListByQuery(query), throwsException);
});
});
}

View File

@@ -1,77 +1,81 @@
import 'package:dio/dio.dart';
import 'package:eatvio_app/features/notifications/service/notifications_service.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import '../../../fixtures/fixture_reader.dart';
import 'notifications_service_test.mocks.dart';
@GenerateNiceMocks([MockSpec<Dio>()])
void main() {
group('NotificationsService', () {
late NotificationsService notificationsService;
late MockDio mockDio;
setUp(() {
mockDio = MockDio();
notificationsService = NotificationsService(mockDio);
});
test('getNotifications - возвращает уведомления', () async {
const page = 1;
final json = FixtureReader.readAsMap('notifications/notifications_response.json');
final response = Response(
data: {
'data': json['notifications'],
'current_page': json['pagination']['current_page'],
'last_page': json['pagination']['last_page'],
'per_page': 10,
'total': 1,
},
statusCode: 200,
requestOptions: RequestOptions(path: '/api/profile/notifications'),
);
when(mockDio.get(any))
.thenAnswer((_) async => response);
final result = await notificationsService.getNotifications(page: page);
expect(result, isA<Map<String, dynamic>?>());
expect(result, isNotNull);
expect(result!['notifications'], isA<List>());
verify(mockDio.get(any)).called(1);
});
test('markNotificationsAsRead - помечает уведомления как прочитанные', () async {
final response = Response(
data: {},
statusCode: 200,
requestOptions: RequestOptions(path: '/api/profile/mark_notifications_as_readed'),
);
when(mockDio.post(any))
.thenAnswer((_) async => response);
await notificationsService.markNotificationsAsRead();
verify(mockDio.post(any)).called(1);
});
});
}
import 'package:dio/dio.dart';
import 'package:eatvio_app/features/notifications/service/notifications_service.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import '../../../fixtures/fixture_reader.dart';
import 'notifications_service_test.mocks.dart';
@GenerateNiceMocks([MockSpec<Dio>()])
void main() {
group('NotificationsService', () {
late NotificationsService notificationsService;
late MockDio mockDio;
setUp(() {
mockDio = MockDio();
notificationsService = NotificationsService(mockDio);
});
test('getNotifications - возвращает уведомления', () async {
const page = 1;
final json = FixtureReader.readAsMap('notifications/notifications_response.json');
final response = Response(
data: {
'data': json['notifications'],
'current_page': json['pagination']['current_page'],
'last_page': json['pagination']['last_page'],
'per_page': 10,
'total': 1,
},
statusCode: 200,
requestOptions: RequestOptions(path: '/api/profile/notifications'),
);
when(mockDio.get(any))
.thenAnswer((_) async => response);
final result = await notificationsService.getNotifications(page: page);
expect(result, isA<Map<String, dynamic>?>());
expect(result, isNotNull);
expect(result!['notifications'], isA<List>());
verify(mockDio.get(any)).called(1);
});
test('markNotificationsAsRead - помечает уведомления как прочитанные', () async {
final response = Response(
data: {},
statusCode: 200,
requestOptions: RequestOptions(path: '/api/profile/mark_notifications_as_readed'),
);
when(mockDio.post(any))
.thenAnswer((_) async => response);
await notificationsService.markNotificationsAsRead();
verify(mockDio.post(any)).called(1);
});
});
}