From 9c7ca140179864d836e353306e51d694ab562173 Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Tue, 23 Dec 2025 10:21:15 +0300 Subject: [PATCH 1/4] chore: update Flutter version in CI workflow from 3.38.1 to 3.38.5 --- .gitea/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index d41230f4..0921f560 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -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/" From a792dcd1637624a9f935fc17d7af229b2fd42a1b Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Tue, 23 Dec 2025 10:37:41 +0300 Subject: [PATCH 2/4] chore: update dependencies in pubspec.yaml for retrofit and development tools --- pubspec.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index b861f083..d02315db 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -27,7 +27,7 @@ dependencies: flutter_typeahead: ^5.2.0 go_router: ^17.0.0 keyboard_dismisser: ^3.0.0 - retrofit: ^4.7.1 + retrofit: ^4.9.1 get_it: ^9.0.5 dio: ^5.9.0 dart_pusher_channels: ^1.2.3 @@ -85,11 +85,11 @@ dependencies: webview_flutter_platform_interface: ^2.14.0 dev_dependencies: - build_runner: ^2.7.0 - freezed: ^3.2.0 - json_serializable: ^6.10.0 - retrofit_generator: ^10.0.2 - mockito: ^5.5.0 + build_runner: ^2.10.4 + freezed: ^3.2.3 + json_serializable: ^6.11.2 + retrofit_generator: ">=10.1.0 <10.2.0" + mockito: ^5.6.1 mocktail: ^1.0.4 network_image_mock: ^2.1.1 From 3d774267ca092aa1bda69f6ee1ee476719ec902b Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Wed, 24 Dec 2025 14:52:51 +0300 Subject: [PATCH 3/4] chore: update pubspec.yaml dependencies and Flutter SDK version; add blank lines in various files for improved readability --- .../oauth_verification_confirm_response.dart | 2 + .../models/oauth_verification_request.dart | 2 + .../oauth_verification_request_response.dart | 2 + .../barcode/services/barcode_service.dart | 2 + pubspec.yaml | 54 +++++++++---------- test/core/constants/app_constants_test.dart | 2 + test/core/cubit/state_utils_test.dart | 2 + .../core/data/selection_popup_model_test.dart | 2 + test/core/enums/prefs_keys_test.dart | 2 + .../internet_connection_state_test.dart | 2 + test/core/prefs_keys_test.dart | 2 + .../routing/main_navigation_routes_test.dart | 2 + test/core/routing/other_routes_test.dart | 2 + test/core/routing/route_constants_test.dart | 2 + test/core/routing/settings_routes_test.dart | 2 + test/core/views/cubit/views_state_test.dart | 2 + test/core/widgets/add_item_button_test.dart | 2 + .../widgets/animated_option_button_test.dart | 2 + test/core/widgets/base_button_test.dart | 2 + .../widgets/bottom_sheet_with_blur_test.dart | 2 + test/core/widgets/cpfc_container_test.dart | 2 + test/core/widgets/custom_search_bar_test.dart | 2 + test/core/widgets/item_widget_test.dart | 2 + test/core/widgets/loader_test.dart | 2 + .../widgets/main_background_bouble_test.dart | 2 + .../widgets/marketing_bottom_sheet_test.dart | 2 + test/core/widgets/option_widget_test.dart | 2 + .../widgets/error_widget_test.dart | 2 + .../chosen_diet_widget_content_test.dart | 2 + .../widgets/comment_container_test.dart | 2 + .../finish_day_button_widget_test.dart | 2 + .../widgets/meal_summary_widget_test.dart | 2 + .../widgets/product_loader_widget_test.dart | 2 + .../widgets/info_bouble_test.dart | 2 + .../widgets/choice_chip_widget_test.dart | 2 + .../widgets/filter_badge_test.dart | 2 + .../widgets/status_widget_test.dart | 2 + .../glossary_repository_test.dart | 2 + .../widgets/notification_widget_test.dart | 2 + .../service/notifications_service_test.dart | 2 + 40 files changed, 105 insertions(+), 27 deletions(-) diff --git a/lib/features/auth/models/oauth_verification_confirm_response.dart b/lib/features/auth/models/oauth_verification_confirm_response.dart index f079f11c..2bfa7033 100644 --- a/lib/features/auth/models/oauth_verification_confirm_response.dart +++ b/lib/features/auth/models/oauth_verification_confirm_response.dart @@ -27,3 +27,5 @@ abstract class OAuthVerificationConfirmResponse with _$OAuthVerificationConfirmR + + diff --git a/lib/features/auth/models/oauth_verification_request.dart b/lib/features/auth/models/oauth_verification_request.dart index 041791d6..c8cb0d89 100644 --- a/lib/features/auth/models/oauth_verification_request.dart +++ b/lib/features/auth/models/oauth_verification_request.dart @@ -21,3 +21,5 @@ abstract class OAuthVerificationRequest with _$OAuthVerificationRequest { + + diff --git a/lib/features/auth/models/oauth_verification_request_response.dart b/lib/features/auth/models/oauth_verification_request_response.dart index 262d400d..986906b8 100644 --- a/lib/features/auth/models/oauth_verification_request_response.dart +++ b/lib/features/auth/models/oauth_verification_request_response.dart @@ -21,3 +21,5 @@ abstract class OAuthVerificationRequestResponse with _$OAuthVerificationRequestR + + diff --git a/lib/features/barcode/services/barcode_service.dart b/lib/features/barcode/services/barcode_service.dart index 56b41eae..ebb256d3 100644 --- a/lib/features/barcode/services/barcode_service.dart +++ b/lib/features/barcode/services/barcode_service.dart @@ -15,3 +15,5 @@ abstract class BarcodeService { Future getTaskStatus({@Path('task_id') required String taskId}); } + + diff --git a/pubspec.yaml b/pubspec.yaml index d02315db..b0f1ec1d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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.9.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,59 +36,59 @@ 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.10.4 - freezed: ^3.2.3 + freezed: ^3.2.0 json_serializable: ^6.11.2 - retrofit_generator: ">=10.1.0 <10.2.0" + retrofit_generator: 10.0.6 mockito: ^5.6.1 mocktail: ^1.0.4 network_image_mock: ^2.1.1 diff --git a/test/core/constants/app_constants_test.dart b/test/core/constants/app_constants_test.dart index 85f13a4e..820bca4a 100644 --- a/test/core/constants/app_constants_test.dart +++ b/test/core/constants/app_constants_test.dart @@ -148,6 +148,8 @@ void main() { + + diff --git a/test/core/cubit/state_utils_test.dart b/test/core/cubit/state_utils_test.dart index 3021d44a..87c8f3b1 100644 --- a/test/core/cubit/state_utils_test.dart +++ b/test/core/cubit/state_utils_test.dart @@ -83,6 +83,8 @@ void main() { + + diff --git a/test/core/data/selection_popup_model_test.dart b/test/core/data/selection_popup_model_test.dart index 1e2914f7..a7819b70 100644 --- a/test/core/data/selection_popup_model_test.dart +++ b/test/core/data/selection_popup_model_test.dart @@ -97,6 +97,8 @@ void main() { + + diff --git a/test/core/enums/prefs_keys_test.dart b/test/core/enums/prefs_keys_test.dart index 066d5f5a..0f1ed00b 100644 --- a/test/core/enums/prefs_keys_test.dart +++ b/test/core/enums/prefs_keys_test.dart @@ -46,6 +46,8 @@ void main() { + + diff --git a/test/core/internet_connection_cubit/internet_connection_state_test.dart b/test/core/internet_connection_cubit/internet_connection_state_test.dart index 4fe26817..7e251ab1 100644 --- a/test/core/internet_connection_cubit/internet_connection_state_test.dart +++ b/test/core/internet_connection_cubit/internet_connection_state_test.dart @@ -72,6 +72,8 @@ void main() { + + diff --git a/test/core/prefs_keys_test.dart b/test/core/prefs_keys_test.dart index 433b1c75..fe40872d 100644 --- a/test/core/prefs_keys_test.dart +++ b/test/core/prefs_keys_test.dart @@ -42,6 +42,8 @@ void main() { + + diff --git a/test/core/routing/main_navigation_routes_test.dart b/test/core/routing/main_navigation_routes_test.dart index c6fe27ea..09efd3c7 100644 --- a/test/core/routing/main_navigation_routes_test.dart +++ b/test/core/routing/main_navigation_routes_test.dart @@ -39,6 +39,8 @@ void main() { + + diff --git a/test/core/routing/other_routes_test.dart b/test/core/routing/other_routes_test.dart index 09ae2261..a02452dd 100644 --- a/test/core/routing/other_routes_test.dart +++ b/test/core/routing/other_routes_test.dart @@ -43,6 +43,8 @@ void main() { + + diff --git a/test/core/routing/route_constants_test.dart b/test/core/routing/route_constants_test.dart index 99076a7d..81c98c2e 100644 --- a/test/core/routing/route_constants_test.dart +++ b/test/core/routing/route_constants_test.dart @@ -122,6 +122,8 @@ void main() { + + diff --git a/test/core/routing/settings_routes_test.dart b/test/core/routing/settings_routes_test.dart index 6d96f91d..b27535ac 100644 --- a/test/core/routing/settings_routes_test.dart +++ b/test/core/routing/settings_routes_test.dart @@ -46,6 +46,8 @@ void main() { + + diff --git a/test/core/views/cubit/views_state_test.dart b/test/core/views/cubit/views_state_test.dart index 80837cb7..15fae695 100644 --- a/test/core/views/cubit/views_state_test.dart +++ b/test/core/views/cubit/views_state_test.dart @@ -40,6 +40,8 @@ void main() { + + diff --git a/test/core/widgets/add_item_button_test.dart b/test/core/widgets/add_item_button_test.dart index 3bcfbd0b..a42e23ac 100644 --- a/test/core/widgets/add_item_button_test.dart +++ b/test/core/widgets/add_item_button_test.dart @@ -76,6 +76,8 @@ void main() { + + diff --git a/test/core/widgets/animated_option_button_test.dart b/test/core/widgets/animated_option_button_test.dart index ea7d573a..ad4e149a 100644 --- a/test/core/widgets/animated_option_button_test.dart +++ b/test/core/widgets/animated_option_button_test.dart @@ -128,6 +128,8 @@ void main() { + + diff --git a/test/core/widgets/base_button_test.dart b/test/core/widgets/base_button_test.dart index a8763ccc..491d0abc 100644 --- a/test/core/widgets/base_button_test.dart +++ b/test/core/widgets/base_button_test.dart @@ -65,6 +65,8 @@ void main() { + + diff --git a/test/core/widgets/bottom_sheet_with_blur_test.dart b/test/core/widgets/bottom_sheet_with_blur_test.dart index cbec65dd..fb407c4a 100644 --- a/test/core/widgets/bottom_sheet_with_blur_test.dart +++ b/test/core/widgets/bottom_sheet_with_blur_test.dart @@ -147,6 +147,8 @@ void main() { + + diff --git a/test/core/widgets/cpfc_container_test.dart b/test/core/widgets/cpfc_container_test.dart index 344acacd..f7082019 100644 --- a/test/core/widgets/cpfc_container_test.dart +++ b/test/core/widgets/cpfc_container_test.dart @@ -108,6 +108,8 @@ void main() { + + diff --git a/test/core/widgets/custom_search_bar_test.dart b/test/core/widgets/custom_search_bar_test.dart index ff0b258b..4c133c04 100644 --- a/test/core/widgets/custom_search_bar_test.dart +++ b/test/core/widgets/custom_search_bar_test.dart @@ -176,6 +176,8 @@ void main() { + + diff --git a/test/core/widgets/item_widget_test.dart b/test/core/widgets/item_widget_test.dart index c2076e46..8a09136f 100644 --- a/test/core/widgets/item_widget_test.dart +++ b/test/core/widgets/item_widget_test.dart @@ -69,6 +69,8 @@ void main() { + + diff --git a/test/core/widgets/loader_test.dart b/test/core/widgets/loader_test.dart index 7ff7ff7c..39989613 100644 --- a/test/core/widgets/loader_test.dart +++ b/test/core/widgets/loader_test.dart @@ -54,6 +54,8 @@ void main() { + + diff --git a/test/core/widgets/main_background_bouble_test.dart b/test/core/widgets/main_background_bouble_test.dart index e7c0fd78..4dcb4bf6 100644 --- a/test/core/widgets/main_background_bouble_test.dart +++ b/test/core/widgets/main_background_bouble_test.dart @@ -108,6 +108,8 @@ void main() { + + diff --git a/test/core/widgets/marketing_bottom_sheet_test.dart b/test/core/widgets/marketing_bottom_sheet_test.dart index bda701ed..85e8ae9d 100644 --- a/test/core/widgets/marketing_bottom_sheet_test.dart +++ b/test/core/widgets/marketing_bottom_sheet_test.dart @@ -88,6 +88,8 @@ void main() { + + diff --git a/test/core/widgets/option_widget_test.dart b/test/core/widgets/option_widget_test.dart index 0d932449..a22dcb76 100644 --- a/test/core/widgets/option_widget_test.dart +++ b/test/core/widgets/option_widget_test.dart @@ -77,6 +77,8 @@ void main() { + + diff --git a/test/features/create_diet/presentation/widgets/error_widget_test.dart b/test/features/create_diet/presentation/widgets/error_widget_test.dart index e918ee44..4b2b692c 100644 --- a/test/features/create_diet/presentation/widgets/error_widget_test.dart +++ b/test/features/create_diet/presentation/widgets/error_widget_test.dart @@ -83,6 +83,8 @@ void main() { + + diff --git a/test/features/diary/presentation/widgets/chosen_diet_widget_content_test.dart b/test/features/diary/presentation/widgets/chosen_diet_widget_content_test.dart index 410c00c8..ce3ee6fb 100644 --- a/test/features/diary/presentation/widgets/chosen_diet_widget_content_test.dart +++ b/test/features/diary/presentation/widgets/chosen_diet_widget_content_test.dart @@ -92,6 +92,8 @@ void main() { + + diff --git a/test/features/diary/presentation/widgets/comment_container_test.dart b/test/features/diary/presentation/widgets/comment_container_test.dart index 3a9d8e92..b69f696a 100644 --- a/test/features/diary/presentation/widgets/comment_container_test.dart +++ b/test/features/diary/presentation/widgets/comment_container_test.dart @@ -70,6 +70,8 @@ void main() { + + diff --git a/test/features/diary/presentation/widgets/finish_day_button_widget_test.dart b/test/features/diary/presentation/widgets/finish_day_button_widget_test.dart index d4fda847..0d68a53f 100644 --- a/test/features/diary/presentation/widgets/finish_day_button_widget_test.dart +++ b/test/features/diary/presentation/widgets/finish_day_button_widget_test.dart @@ -65,6 +65,8 @@ void main() { + + diff --git a/test/features/diary/presentation/widgets/meal_summary_widget_test.dart b/test/features/diary/presentation/widgets/meal_summary_widget_test.dart index c5fed4a8..a5c53bbb 100644 --- a/test/features/diary/presentation/widgets/meal_summary_widget_test.dart +++ b/test/features/diary/presentation/widgets/meal_summary_widget_test.dart @@ -102,6 +102,8 @@ void main() { + + diff --git a/test/features/diary/presentation/widgets/product_loader_widget_test.dart b/test/features/diary/presentation/widgets/product_loader_widget_test.dart index fdb02efd..c02642fe 100644 --- a/test/features/diary/presentation/widgets/product_loader_widget_test.dart +++ b/test/features/diary/presentation/widgets/product_loader_widget_test.dart @@ -54,6 +54,8 @@ void main() { + + diff --git a/test/features/diets/presentation/widgets/info_bouble_test.dart b/test/features/diets/presentation/widgets/info_bouble_test.dart index 692e2d8c..31f338f8 100644 --- a/test/features/diets/presentation/widgets/info_bouble_test.dart +++ b/test/features/diets/presentation/widgets/info_bouble_test.dart @@ -120,6 +120,8 @@ void main() { + + diff --git a/test/features/feed/presentation/widgets/choice_chip_widget_test.dart b/test/features/feed/presentation/widgets/choice_chip_widget_test.dart index ed8ef25e..eff81187 100644 --- a/test/features/feed/presentation/widgets/choice_chip_widget_test.dart +++ b/test/features/feed/presentation/widgets/choice_chip_widget_test.dart @@ -150,6 +150,8 @@ void main() { + + diff --git a/test/features/feed/presentation/widgets/filter_badge_test.dart b/test/features/feed/presentation/widgets/filter_badge_test.dart index fd204766..4cbd9a96 100644 --- a/test/features/feed/presentation/widgets/filter_badge_test.dart +++ b/test/features/feed/presentation/widgets/filter_badge_test.dart @@ -62,6 +62,8 @@ void main() { + + diff --git a/test/features/finances_and_consultations_archive/presentation/widgets/status_widget_test.dart b/test/features/finances_and_consultations_archive/presentation/widgets/status_widget_test.dart index af9099fc..25b7af9a 100644 --- a/test/features/finances_and_consultations_archive/presentation/widgets/status_widget_test.dart +++ b/test/features/finances_and_consultations_archive/presentation/widgets/status_widget_test.dart @@ -70,6 +70,8 @@ void main() { + + diff --git a/test/features/glossary/repositories/glossary_repository_test.dart b/test/features/glossary/repositories/glossary_repository_test.dart index 67514a78..c61cd0a3 100644 --- a/test/features/glossary/repositories/glossary_repository_test.dart +++ b/test/features/glossary/repositories/glossary_repository_test.dart @@ -63,6 +63,8 @@ void main() { + + diff --git a/test/features/notifications/presentation/widgets/notification_widget_test.dart b/test/features/notifications/presentation/widgets/notification_widget_test.dart index 6094e398..6a9a49b8 100644 --- a/test/features/notifications/presentation/widgets/notification_widget_test.dart +++ b/test/features/notifications/presentation/widgets/notification_widget_test.dart @@ -1040,6 +1040,8 @@ void main() { + + diff --git a/test/features/notifications/service/notifications_service_test.dart b/test/features/notifications/service/notifications_service_test.dart index e644bd23..59a6ae76 100644 --- a/test/features/notifications/service/notifications_service_test.dart +++ b/test/features/notifications/service/notifications_service_test.dart @@ -75,3 +75,5 @@ void main() { + + From e158d812e4c0acb934ed140d65b91dcff050e927 Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Wed, 24 Dec 2025 17:54:35 +0300 Subject: [PATCH 4/4] refactor: clean up imports and improve code readability across various files --- .../oauth_verification_confirm_response.dart | 64 +- .../models/oauth_verification_request.dart | 52 +- .../oauth_verification_request_response.dart | 52 +- .../barcode/services/barcode_service.dart | 40 +- .../widgets/first_step_content.dart | 354 +-- .../widgets/second_step_content.dart | 356 +-- test/core/constants/app_constants_test.dart | 312 +-- test/core/cubit/state_utils_test.dart | 182 +- .../core/data/selection_popup_model_test.dart | 210 +- test/core/enums/prefs_keys_test.dart | 108 +- .../internet_connection_state_test.dart | 160 +- test/core/prefs_keys_test.dart | 100 +- .../routing/main_navigation_routes_test.dart | 94 +- test/core/routing/other_routes_test.dart | 102 +- test/core/routing/route_constants_test.dart | 260 +- test/core/routing/settings_routes_test.dart | 108 +- test/core/views/cubit/views_state_test.dart | 96 +- test/core/widgets/add_item_button_test.dart | 168 +- .../widgets/animated_option_button_test.dart | 272 +-- test/core/widgets/base_button_test.dart | 146 +- .../widgets/bottom_sheet_with_blur_test.dart | 310 +-- test/core/widgets/cpfc_container_test.dart | 232 +- test/core/widgets/custom_search_bar_test.dart | 368 +-- test/core/widgets/item_widget_test.dart | 154 +- test/core/widgets/loader_test.dart | 124 +- .../widgets/main_background_bouble_test.dart | 232 +- .../widgets/marketing_bottom_sheet_test.dart | 192 +- test/core/widgets/option_widget_test.dart | 170 +- .../widgets/error_widget_test.dart | 182 +- .../chosen_diet_widget_content_test.dart | 200 +- .../widgets/comment_container_test.dart | 156 +- .../finish_day_button_widget_test.dart | 146 +- .../widgets/meal_summary_widget_test.dart | 220 +- .../widgets/product_loader_widget_test.dart | 124 +- .../widgets/info_bouble_test.dart | 256 +- .../widgets/choice_chip_widget_test.dart | 316 +-- .../widgets/filter_badge_test.dart | 140 +- .../widgets/status_widget_test.dart | 156 +- .../glossary_repository_test.dart | 142 +- .../widgets/notification_widget_test.dart | 2096 +++++++++-------- .../service/notifications_service_test.dart | 160 +- 41 files changed, 4699 insertions(+), 4613 deletions(-) diff --git a/lib/features/auth/models/oauth_verification_confirm_response.dart b/lib/features/auth/models/oauth_verification_confirm_response.dart index 2bfa7033..5f86f75e 100644 --- a/lib/features/auth/models/oauth_verification_confirm_response.dart +++ b/lib/features/auth/models/oauth_verification_confirm_response.dart @@ -1,31 +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 user, - @JsonKey(name: 'is_new_user') required bool isNewUser, - }) = _OAuthVerificationConfirmResponse; - - factory OAuthVerificationConfirmResponse.fromJson(Map 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 user, + @JsonKey(name: 'is_new_user') required bool isNewUser, + }) = _OAuthVerificationConfirmResponse; + + factory OAuthVerificationConfirmResponse.fromJson(Map json) => _$OAuthVerificationConfirmResponseFromJson(json); +} + + + + + + + + + + + + + + + + diff --git a/lib/features/auth/models/oauth_verification_request.dart b/lib/features/auth/models/oauth_verification_request.dart index c8cb0d89..8aa40c1c 100644 --- a/lib/features/auth/models/oauth_verification_request.dart +++ b/lib/features/auth/models/oauth_verification_request.dart @@ -1,25 +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 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 json) => _$OAuthVerificationRequestFromJson(json); +} + + + + + + + + + + + + + + + + diff --git a/lib/features/auth/models/oauth_verification_request_response.dart b/lib/features/auth/models/oauth_verification_request_response.dart index 986906b8..062c14da 100644 --- a/lib/features/auth/models/oauth_verification_request_response.dart +++ b/lib/features/auth/models/oauth_verification_request_response.dart @@ -1,25 +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 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 json) => _$OAuthVerificationRequestResponseFromJson(json); +} + + + + + + + + + + + + + + + + diff --git a/lib/features/barcode/services/barcode_service.dart b/lib/features/barcode/services/barcode_service.dart index ebb256d3..4bfc2aa3 100644 --- a/lib/features/barcode/services/barcode_service.dart +++ b/lib/features/barcode/services/barcode_service.dart @@ -1,19 +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 getProductByBarcode({@Path('barcode') required String barcode}); - - @GET('/api/gsone/barcode/status/{task_id}') - Future 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 getProductByBarcode({@Path('barcode') required String barcode}); + + @GET('/api/gsone/barcode/status/{task_id}') + Future getTaskStatus({@Path('task_id') required String taskId}); +} + + + + + diff --git a/lib/features/registration_v2/presentation/widgets/first_step_content.dart b/lib/features/registration_v2/presentation/widgets/first_step_content.dart index 8f4b5372..78244da8 100644 --- a/lib/features/registration_v2/presentation/widgets/first_step_content.dart +++ b/lib/features/registration_v2/presentation/widgets/first_step_content.dart @@ -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 createState() => _FirstStepContentState(); -} - -class _FirstStepContentState extends State { - 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().state.firstName; - lastNameController.text = context.read().state.lastName; - emailController.text = context.read().state.email; - phoneController.text = context.read().state.phone; - dateController.text = context.read().state.birthday?.format('dd.MM.yyyy') ?? ''; - } - - @override - Widget build(BuildContext context) { - final s = S.of(context); - return BlocBuilder( - 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().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().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().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().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().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().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 createState() => _FirstStepContentState(); +} + +class _FirstStepContentState extends State { + 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().state.firstName; + lastNameController.text = context.read().state.lastName; + emailController.text = context.read().state.email; + phoneController.text = context.read().state.phone; + dateController.text = context.read().state.birthday?.format('dd.MM.yyyy') ?? ''; + } + + @override + Widget build(BuildContext context) { + final s = S.of(context); + return BlocBuilder( + 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().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().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().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().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().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().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), + ], + ); + }, + ); + } +} diff --git a/lib/features/registration_v2/presentation/widgets/second_step_content.dart b/lib/features/registration_v2/presentation/widgets/second_step_content.dart index 45efc931..6980dc0d 100644 --- a/lib/features/registration_v2/presentation/widgets/second_step_content.dart +++ b/lib/features/registration_v2/presentation/widgets/second_step_content.dart @@ -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 createState() => _SecondStepContentState(); -} - -class _SecondStepContentState extends State { - bool isLoading = false; - final weightController = TextEditingController(); - final heightController = TextEditingController(); - - @override - void initState() { - super.initState(); - heightController.text = context.read().state.height.toString(); - weightController.text = context.read().state.weight.toString(); - } - - @override - Widget build(BuildContext context) { - final s = S.of(context); - return BlocBuilder( - 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().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().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().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(); - 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().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().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 createState() => _SecondStepContentState(); +} + +class _SecondStepContentState extends State { + bool isLoading = false; + final weightController = TextEditingController(); + final heightController = TextEditingController(); + + @override + void initState() { + super.initState(); + heightController.text = context.read().state.height.toString() == '0' + ? '' + : context.read().state.height.toString(); + weightController.text = context.read().state.weight.toString() == '0' + ? '' + : context.read().state.weight.toString(); + } + + @override + Widget build(BuildContext context) { + final s = S.of(context); + return BlocBuilder( + 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().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().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().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(); + 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().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().baseUrl}/docs/privacy.pdf')), + ), + ], + ), + ), + ), + const SizedBox(height: 30), + ], + ); + }, + ); + } +} diff --git a/test/core/constants/app_constants_test.dart b/test/core/constants/app_constants_test.dart index 820bca4a..212fd279 100644 --- a/test/core/constants/app_constants_test.dart +++ b/test/core/constants/app_constants_test.dart @@ -1,155 +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()); - expect(AppConstants.emailRegex.isNotEmpty, isTrue); - }); - - test('has phone regex', () { - expect(AppConstants.phoneRegex, isA()); - expect(AppConstants.phoneRegex.isNotEmpty, isTrue); - }); - - test('has URL regex', () { - expect(AppConstants.urlRegex, isA()); - expect(AppConstants.urlRegex.isNotEmpty, isTrue); - }); - }); - - group('Messages', () { - test('has error messages', () { - expect(AppConstants.defaultErrorMessage, isA()); - expect(AppConstants.networkErrorMessage, isA()); - expect(AppConstants.timeoutErrorMessage, isA()); - expect(AppConstants.unknownErrorMessage, isA()); - }); - }); - - group('Keys', () { - test('has SharedPreferences keys', () { - expect(AppConstants.welcomeScreenShownKey, isA()); - expect(AppConstants.userTokenKey, isA()); - expect(AppConstants.userDataKey, isA()); - expect(AppConstants.settingsKey, isA()); - }); - }); - - 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()); + expect(AppConstants.emailRegex.isNotEmpty, isTrue); + }); + + test('has phone regex', () { + expect(AppConstants.phoneRegex, isA()); + expect(AppConstants.phoneRegex.isNotEmpty, isTrue); + }); + + test('has URL regex', () { + expect(AppConstants.urlRegex, isA()); + expect(AppConstants.urlRegex.isNotEmpty, isTrue); + }); + }); + + group('Messages', () { + test('has error messages', () { + expect(AppConstants.defaultErrorMessage, isA()); + expect(AppConstants.networkErrorMessage, isA()); + expect(AppConstants.timeoutErrorMessage, isA()); + expect(AppConstants.unknownErrorMessage, isA()); + }); + }); + + group('Keys', () { + test('has SharedPreferences keys', () { + expect(AppConstants.welcomeScreenShownKey, isA()); + expect(AppConstants.userTokenKey, isA()); + expect(AppConstants.userDataKey, isA()); + expect(AppConstants.settingsKey, isA()); + }); + }); + + 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'); + }); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/core/cubit/state_utils_test.dart b/test/core/cubit/state_utils_test.dart index 87c8f3b1..7d66f5c4 100644 --- a/test/core/cubit/state_utils_test.dart +++ b/test/core/cubit/state_utils_test.dart @@ -1,90 +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); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/core/data/selection_popup_model_test.dart b/test/core/data/selection_popup_model_test.dart index a7819b70..f136a109 100644 --- a/test/core/data/selection_popup_model_test.dart +++ b/test/core/data/selection_popup_model_test.dart @@ -1,104 +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); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/core/enums/prefs_keys_test.dart b/test/core/enums/prefs_keys_test.dart index 0f1ed00b..2f05ac74 100644 --- a/test/core/enums/prefs_keys_test.dart +++ b/test/core/enums/prefs_keys_test.dart @@ -1,53 +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'); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/core/internet_connection_cubit/internet_connection_state_test.dart b/test/core/internet_connection_cubit/internet_connection_state_test.dart index 7e251ab1..0d7e4e6a 100644 --- a/test/core/internet_connection_cubit/internet_connection_state_test.dart +++ b/test/core/internet_connection_cubit/internet_connection_state_test.dart @@ -1,79 +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); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/core/prefs_keys_test.dart b/test/core/prefs_keys_test.dart index fe40872d..412178ac 100644 --- a/test/core/prefs_keys_test.dart +++ b/test/core/prefs_keys_test.dart @@ -1,49 +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'); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/core/routing/main_navigation_routes_test.dart b/test/core/routing/main_navigation_routes_test.dart index 09efd3c7..93ef13c0 100644 --- a/test/core/routing/main_navigation_routes_test.dart +++ b/test/core/routing/main_navigation_routes_test.dart @@ -1,46 +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>()); - }); - - test('createRoutes содержит ShellRoute', () { - final routes = MainNavigationRoutes.createRoutes(); - expect(routes.first, isA()); - }); - }); -} - - - - - - - - - - - - - - - - - - - - - - - - - - - - +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>()); + }); + + test('createRoutes содержит ShellRoute', () { + final routes = MainNavigationRoutes.createRoutes(); + expect(routes.first, isA()); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/core/routing/other_routes_test.dart b/test/core/routing/other_routes_test.dart index a02452dd..23e461ae 100644 --- a/test/core/routing/other_routes_test.dart +++ b/test/core/routing/other_routes_test.dart @@ -1,50 +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>()); - }); - - 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()); - }); - }); -} - - - - - - - - - - - - - - - - - - - - - - - - - - - - +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>()); + }); + + 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()); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/core/routing/route_constants_test.dart b/test/core/routing/route_constants_test.dart index 81c98c2e..726a2f37 100644 --- a/test/core/routing/route_constants_test.dart +++ b/test/core/routing/route_constants_test.dart @@ -1,129 +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'); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/core/routing/settings_routes_test.dart b/test/core/routing/settings_routes_test.dart index b27535ac..337495fb 100644 --- a/test/core/routing/settings_routes_test.dart +++ b/test/core/routing/settings_routes_test.dart @@ -1,53 +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>()); - }); - - 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>()); + }); + + 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); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/core/views/cubit/views_state_test.dart b/test/core/views/cubit/views_state_test.dart index 15fae695..0271a905 100644 --- a/test/core/views/cubit/views_state_test.dart +++ b/test/core/views/cubit/views_state_test.dart @@ -1,47 +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()); - }); - - test('can create multiple instances', () { - final state1 = ViewsCubitState(); - final state2 = ViewsCubitState(); - - expect(state1, isA()); - expect(state2, isA()); - }); - }); -} - - - - - - - - - - - - - - - - - - - - - - - - - - - +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()); + }); + + test('can create multiple instances', () { + final state1 = ViewsCubitState(); + final state2 = ViewsCubitState(); + + expect(state1, isA()); + expect(state2, isA()); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/core/widgets/add_item_button_test.dart b/test/core/widgets/add_item_button_test.dart index a42e23ac..2eb83315 100644 --- a/test/core/widgets/add_item_button_test.dart +++ b/test/core/widgets/add_item_button_test.dart @@ -1,83 +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); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/core/widgets/animated_option_button_test.dart b/test/core/widgets/animated_option_button_test.dart index ad4e149a..64688618 100644 --- a/test/core/widgets/animated_option_button_test.dart +++ b/test/core/widgets/animated_option_button_test.dart @@ -1,135 +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); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/core/widgets/base_button_test.dart b/test/core/widgets/base_button_test.dart index 491d0abc..f54cef0f 100644 --- a/test/core/widgets/base_button_test.dart +++ b/test/core/widgets/base_button_test.dart @@ -1,72 +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); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/core/widgets/bottom_sheet_with_blur_test.dart b/test/core/widgets/bottom_sheet_with_blur_test.dart index fb407c4a..e96d327c 100644 --- a/test/core/widgets/bottom_sheet_with_blur_test.dart +++ b/test/core/widgets/bottom_sheet_with_blur_test.dart @@ -1,154 +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); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/core/widgets/cpfc_container_test.dart b/test/core/widgets/cpfc_container_test.dart index f7082019..32ad2f4f 100644 --- a/test/core/widgets/cpfc_container_test.dart +++ b/test/core/widgets/cpfc_container_test.dart @@ -1,115 +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); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/core/widgets/custom_search_bar_test.dart b/test/core/widgets/custom_search_bar_test.dart index 4c133c04..f3a2d382 100644 --- a/test/core/widgets/custom_search_bar_test.dart +++ b/test/core/widgets/custom_search_bar_test.dart @@ -1,183 +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); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/core/widgets/item_widget_test.dart b/test/core/widgets/item_widget_test.dart index 8a09136f..bc486efc 100644 --- a/test/core/widgets/item_widget_test.dart +++ b/test/core/widgets/item_widget_test.dart @@ -1,76 +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); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/core/widgets/loader_test.dart b/test/core/widgets/loader_test.dart index 39989613..c20fcbf1 100644 --- a/test/core/widgets/loader_test.dart +++ b/test/core/widgets/loader_test.dart @@ -1,61 +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(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(find.byType(SizedBox)); + expect(sizedBox.height, 42); + expect(sizedBox.width, 42); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/core/widgets/main_background_bouble_test.dart b/test/core/widgets/main_background_bouble_test.dart index 4dcb4bf6..67253d3d 100644 --- a/test/core/widgets/main_background_bouble_test.dart +++ b/test/core/widgets/main_background_bouble_test.dart @@ -1,115 +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); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/core/widgets/marketing_bottom_sheet_test.dart b/test/core/widgets/marketing_bottom_sheet_test.dart index 85e8ae9d..d68c190d 100644 --- a/test/core/widgets/marketing_bottom_sheet_test.dart +++ b/test/core/widgets/marketing_bottom_sheet_test.dart @@ -1,95 +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); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/core/widgets/option_widget_test.dart b/test/core/widgets/option_widget_test.dart index a22dcb76..54b7bcc6 100644 --- a/test/core/widgets/option_widget_test.dart +++ b/test/core/widgets/option_widget_test.dart @@ -1,84 +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); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/features/create_diet/presentation/widgets/error_widget_test.dart b/test/features/create_diet/presentation/widgets/error_widget_test.dart index 4b2b692c..3859102e 100644 --- a/test/features/create_diet/presentation/widgets/error_widget_test.dart +++ b/test/features/create_diet/presentation/widgets/error_widget_test.dart @@ -1,90 +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); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/features/diary/presentation/widgets/chosen_diet_widget_content_test.dart b/test/features/diary/presentation/widgets/chosen_diet_widget_content_test.dart index ce3ee6fb..f3ac19ba 100644 --- a/test/features/diary/presentation/widgets/chosen_diet_widget_content_test.dart +++ b/test/features/diary/presentation/widgets/chosen_diet_widget_content_test.dart @@ -1,99 +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); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/features/diary/presentation/widgets/comment_container_test.dart b/test/features/diary/presentation/widgets/comment_container_test.dart index b69f696a..5316d64c 100644 --- a/test/features/diary/presentation/widgets/comment_container_test.dart +++ b/test/features/diary/presentation/widgets/comment_container_test.dart @@ -1,77 +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); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/features/diary/presentation/widgets/finish_day_button_widget_test.dart b/test/features/diary/presentation/widgets/finish_day_button_widget_test.dart index 0d68a53f..af39ef8f 100644 --- a/test/features/diary/presentation/widgets/finish_day_button_widget_test.dart +++ b/test/features/diary/presentation/widgets/finish_day_button_widget_test.dart @@ -1,72 +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); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/features/diary/presentation/widgets/meal_summary_widget_test.dart b/test/features/diary/presentation/widgets/meal_summary_widget_test.dart index a5c53bbb..868d865c 100644 --- a/test/features/diary/presentation/widgets/meal_summary_widget_test.dart +++ b/test/features/diary/presentation/widgets/meal_summary_widget_test.dart @@ -1,109 +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 = []; - - 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 = []; - - 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 = []; - - 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 = []; + + 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 = []; + + 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 = []; + + 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); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/features/diary/presentation/widgets/product_loader_widget_test.dart b/test/features/diary/presentation/widgets/product_loader_widget_test.dart index c02642fe..14aab087 100644 --- a/test/features/diary/presentation/widgets/product_loader_widget_test.dart +++ b/test/features/diary/presentation/widgets/product_loader_widget_test.dart @@ -1,61 +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); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/features/diets/presentation/widgets/info_bouble_test.dart b/test/features/diets/presentation/widgets/info_bouble_test.dart index 31f338f8..0423bdb8 100644 --- a/test/features/diets/presentation/widgets/info_bouble_test.dart +++ b/test/features/diets/presentation/widgets/info_bouble_test.dart @@ -1,127 +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); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/features/feed/presentation/widgets/choice_chip_widget_test.dart b/test/features/feed/presentation/widgets/choice_chip_widget_test.dart index eff81187..3bc45c42 100644 --- a/test/features/feed/presentation/widgets/choice_chip_widget_test.dart +++ b/test/features/feed/presentation/widgets/choice_chip_widget_test.dart @@ -1,157 +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(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(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(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(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); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/features/feed/presentation/widgets/filter_badge_test.dart b/test/features/feed/presentation/widgets/filter_badge_test.dart index 4cbd9a96..eaf151ae 100644 --- a/test/features/feed/presentation/widgets/filter_badge_test.dart +++ b/test/features/feed/presentation/widgets/filter_badge_test.dart @@ -1,69 +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); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/features/finances_and_consultations_archive/presentation/widgets/status_widget_test.dart b/test/features/finances_and_consultations_archive/presentation/widgets/status_widget_test.dart index 25b7af9a..6d03fe81 100644 --- a/test/features/finances_and_consultations_archive/presentation/widgets/status_widget_test.dart +++ b/test/features/finances_and_consultations_archive/presentation/widgets/status_widget_test.dart @@ -1,77 +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); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/features/glossary/repositories/glossary_repository_test.dart b/test/features/glossary/repositories/glossary_repository_test.dart index c61cd0a3..338d4006 100644 --- a/test/features/glossary/repositories/glossary_repository_test.dart +++ b/test/features/glossary/repositories/glossary_repository_test.dart @@ -1,70 +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 = []; - 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 = []; + 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); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/features/notifications/presentation/widgets/notification_widget_test.dart b/test/features/notifications/presentation/widgets/notification_widget_test.dart index 6a9a49b8..8ed9da23 100644 --- a/test/features/notifications/presentation/widgets/notification_widget_test.dart +++ b/test/features/notifications/presentation/widgets/notification_widget_test.dart @@ -1,1047 +1,1049 @@ -import 'package:eatvio_app/core/theme/theme_helper.dart'; -import 'package:eatvio_app/features/notifications/models/notification_model.dart'; -import 'package:eatvio_app/features/notifications/presentation/widgets/notification_widget.dart'; -import 'package:eatvio_app/generated/l10n.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:flutter_localizations/flutter_localizations.dart'; - -void main() { - group('NotificationWidget', () { - final testDate = DateTime(2024, 1, 15, 10, 30); - - Widget createTestWidget(BaseNotificationModel notification) { - return MaterialApp( - localizationsDelegates: const [ - S.delegate, - GlobalMaterialLocalizations.delegate, - GlobalWidgetsLocalizations.delegate, - GlobalCupertinoLocalizations.delegate, - ], - supportedLocales: const [Locale('ru'), Locale('en')], - locale: const Locale('ru'), - theme: ThemeHelper().themeData(), - home: Scaffold( - body: NotificationWidget(notification: notification), - ), - ); - } - - testWidgets('displays PlanSubscriptionStartedToAuthorNotification', (tester) async { - final notification = PlanSubscriptionStartedToAuthorNotification( - type: NotificationType.planSubscriptionStartedToAuthor, - planName: 'Test Plan', - customerName: 'Test Customer', - chatId: 'chat123', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays PlanSubscriptionCanceledToAuthorNotification', (tester) async { - final notification = PlanSubscriptionCanceledToAuthorNotification( - type: NotificationType.planSubscriptionCanceledToAuthor, - planName: 'Test Plan', - customerName: 'Test Customer', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ChosenPlanStartedToClientNotification', (tester) async { - final notification = ChosenPlanStartedToClientNotification( - type: NotificationType.chosenPlanStartedToClient, - planName: 'Test Plan', - planId: 1, - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ChosenPlanTomorrowReminderToClientNotification', (tester) async { - final notification = ChosenPlanTomorrowReminderToClientNotification( - type: NotificationType.chosenPlanTomorrowReminderToClient, - planName: 'Test Plan', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays DiaryReminderNotification', (tester) async { - final notification = DiaryReminderNotification( - type: NotificationType.diaryReminderNotification, - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ConsultantLeftCommentNotification', (tester) async { - final notification = ConsultantLeftCommentNotification( - type: NotificationType.consultantLeftComment, - date: testDate, - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays PersonalizedDietIsDefinedNotification', (tester) async { - final notification = PersonalizedDietIsDefinedNotification( - type: NotificationType.personalizedDietIsDefined, - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ChosenPlanFinishedToClientNotification', (tester) async { - final notification = ChosenPlanFinishedToClientNotification( - type: NotificationType.chosenPlanFinishedToClient, - planName: 'Test Plan', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays PlanSubscriptionCanceledToCustomerNotification', (tester) async { - final notification = PlanSubscriptionCanceledToCustomerNotification( - type: NotificationType.planSubscriptionCanceledToCustomer, - planName: 'Test Plan', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ChosenPlanStartedToConsultantNotification', (tester) async { - final notification = ChosenPlanStartedToConsultantNotification( - type: NotificationType.chosenPlanStartedToConsultant, - planName: 'Test Plan', - customerName: 'Test Customer', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ChosenPlanTomorrowReminderToConsultantNotification', (tester) async { - final notification = ChosenPlanTomorrowReminderToConsultantNotification( - type: NotificationType.chosenPlanTomorrowReminderToConsultant, - planName: 'Test Plan', - customerName: 'Test Customer', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays PlanSubscriptionPaidToAuthorNotification', (tester) async { - final notification = PlanSubscriptionPaidToAuthorNotification( - type: NotificationType.planSubscriptionPaidToAuthor, - planName: 'Test Plan', - customerName: 'Test Customer', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ChosenPlanFinishedToConsultantNotification with button', (tester) async { - final notification = ChosenPlanFinishedToConsultantNotification( - type: NotificationType.chosenPlanFinishedToConsultant, - planName: 'Test Plan', - customerName: 'Test Customer', - planId: 1, - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ChosenPlanLastDayFinishedForUser', (tester) async { - final notification = ChosenPlanLastDayFinishedForUser( - type: NotificationType.chosenPlanLastDayFinishedForUser, - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ChosenPlanConsultantLastDayStarted', (tester) async { - final notification = ChosenPlanConsultantLastDayStarted( - type: NotificationType.chosenPlanConsultantLastDayStarted, - planName: 'Test Plan', - planId: 1, - chatId: 'chat123', - chatUrl: 'chat_url', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ComplaintToModerationForUser', (tester) async { - final notification = ComplaintToModerationForUser( - type: NotificationType.complaintToModerationForUser, - message: 'Test message', - entityId: 1, - entityType: 'test', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays CommentReplied', (tester) async { - final notification = CommentReplied( - type: NotificationType.commentReplied, - entityName: 'Test Entity', - commentedEntityId: 1, - commentedEntityType: 'test', - author: 'Test Author', - authorId: 1, - parentCommentId: 1, - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ScoreAdded', (tester) async { - final notification = ScoreAdded( - type: NotificationType.scoreAdded, - scoreKey: 'test_key', - scorableId: 1, - scorableType: 'test', - scorableName: 'Test Name', - scorableSlug: 'test-slug', - scoreValue: 10, - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays EntityCommented', (tester) async { - final notification = EntityCommented( - type: NotificationType.entityCommented, - entityName: 'Test Entity', - entityId: 1, - entityType: 'test', - entityTranslatedType: 'Test Type', - entityUrl: 'test_url', - authorName: 'Test Author', - authorId: 1, - authorSlug: 'test-author', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays PlanSubscriptionExpiredNotification', (tester) async { - final notification = PlanSubscriptionExpiredNotification( - type: NotificationType.planSubscriptionExpired, - planName: 'Test Plan', - customerName: 'Test Customer', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays PlanSubscriptionRenewedNotification', (tester) async { - final notification = PlanSubscriptionRenewedNotification( - type: NotificationType.planSubscriptionRenewed, - planName: 'Test Plan', - customerName: 'Test Customer', - renewalDate: '2024-02-01', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ConsultantAssignedNotification', (tester) async { - final notification = ConsultantAssignedNotification( - type: NotificationType.consultantAssigned, - consultantName: 'Test Consultant', - planName: 'Test Plan', - planId: 1, - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ConsultantUnassignedNotification', (tester) async { - final notification = ConsultantUnassignedNotification( - type: NotificationType.consultantUnassigned, - consultantName: 'Test Consultant', - planName: 'Test Plan', - planId: 1, - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays PaymentFailedNotification', (tester) async { - final notification = PaymentFailedNotification( - type: NotificationType.paymentFailed, - planName: 'Test Plan', - errorMessage: 'Test error', - paymentMethod: 'card', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays PaymentSuccessfulNotification', (tester) async { - final notification = PaymentSuccessfulNotification( - type: NotificationType.paymentSuccessful, - planName: 'Test Plan', - amount: 100.0, - currency: 'USD', - transactionId: 'trans123', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays GoalAchievedNotification', (tester) async { - final notification = GoalAchievedNotification( - type: NotificationType.goalAchieved, - goalName: 'Test Goal', - goalType: 'weight', - achievedValue: 50.0, - targetValue: 100.0, - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays WorkoutReminderNotification', (tester) async { - final notification = WorkoutReminderNotification( - type: NotificationType.workoutReminder, - workoutName: 'Test Workout', - workoutType: 'cardio', - duration: 30, - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays MealReminderNotification', (tester) async { - final notification = MealReminderNotification( - type: NotificationType.mealReminder, - mealName: 'Test Meal', - mealType: 'breakfast', - calories: 500, - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays DietCancelledNotification', (tester) async { - final notification = DietCancelledNotification( - type: NotificationType.dietCancelled, - dietName: 'Test Diet', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays DietStartedNotification', (tester) async { - final notification = DietStartedNotification( - type: NotificationType.dietStarted, - dietName: 'Test Diet', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays DietExpiredNotification', (tester) async { - final notification = DietExpiredNotification( - type: NotificationType.dietExpired, - dietName: 'Test Diet', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays DietWillStartedInNotification', (tester) async { - final notification = DietWillStartedInNotification( - type: NotificationType.dietWillStartedIn, - dietName: 'Test Diet', - startDate: '2024-02-01', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays DietCanNotBeStartedNotification', (tester) async { - final notification = DietCanNotBeStartedNotification( - type: NotificationType.dietCanNotBeStarted, - dietName: 'Test Diet', - reason: 'Test reason', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays PersonalDietCreationNeededNotification', (tester) async { - final notification = PersonalDietCreationNeededNotification( - type: NotificationType.personalDietCreationNeeded, - planName: 'Test Plan', - clientName: 'Test Client', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ChosenPlanClientLastDayFinishedNotification', (tester) async { - final notification = ChosenPlanClientLastDayFinishedNotification( - type: NotificationType.chosenPlanClientLastDayFinished, - planName: 'Test Plan', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ChosenPlanClientLastDayStartedNotification', (tester) async { - final notification = ChosenPlanClientLastDayStartedNotification( - type: NotificationType.chosenPlanClientLastDayStarted, - planName: 'Test Plan', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays StayOnTrackToAuthorNotification', (tester) async { - final notification = StayOnTrackToAuthorNotification( - type: NotificationType.stayOnTrackToAuthor, - planName: 'Test Plan', - clientName: 'Test Client', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ClientStartPlanSubscriptionToSubscriberNotification', (tester) async { - final notification = ClientStartPlanSubscriptionToSubscriberNotification( - type: NotificationType.clientStartPlanSubscriptionToSubscriber, - planName: 'Test Plan', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ConsultantConfirmPlanSubscriptionToSubscriberNotification', (tester) async { - final notification = ConsultantConfirmPlanSubscriptionToSubscriberNotification( - type: NotificationType.consultantConfirmPlanSubscriptionToSubscriber, - planName: 'Test Plan', - consultantName: 'Test Consultant', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ClientPaidPlanSubscriptionToAuthorNotification', (tester) async { - final notification = ClientPaidPlanSubscriptionToAuthorNotification( - type: NotificationType.clientPaidPlanSubscriptionToAuthor, - planName: 'Test Plan', - clientName: 'Test Client', - amount: 100.0, - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ConsultantLeftDiaryCommentNotification', (tester) async { - final notification = ConsultantLeftDiaryCommentNotification( - type: NotificationType.consultantLeftDiaryComment, - planName: 'Test Plan', - consultantName: 'Test Consultant', - diaryDate: testDate, - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ConsultantConfirmPlanSubscriptionToAuthorNotification', (tester) async { - final notification = ConsultantConfirmPlanSubscriptionToAuthorNotification( - type: NotificationType.consultantConfirmPlanSubscriptionToAuthor, - planName: 'Test Plan', - consultantName: 'Test Consultant', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ClientPaidPlanSubscriptionToSubscriberNotification', (tester) async { - final notification = ClientPaidPlanSubscriptionToSubscriberNotification( - type: NotificationType.clientPaidPlanSubscriptionToSubscriber, - planName: 'Test Plan', - amount: 100.0, - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ClientStartPlanSubscriptionToAuthorNotification', (tester) async { - final notification = ClientStartPlanSubscriptionToAuthorNotification( - type: NotificationType.clientStartPlanSubscriptionToAuthor, - planName: 'Test Plan', - clientName: 'Test Client', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ClientCancelPlanSubscriptionToAuthorNotification', (tester) async { - final notification = ClientCancelPlanSubscriptionToAuthorNotification( - type: NotificationType.clientCancelPlanSubscriptionToAuthor, - planName: 'Test Plan', - clientName: 'Test Client', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ClientCancelPlanSubscriptionToSubscriberNotification', (tester) async { - final notification = ClientCancelPlanSubscriptionToSubscriberNotification( - type: NotificationType.clientCancelPlanSubscriptionToSubscriber, - planName: 'Test Plan', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays UserDailyReportCompletedNotification', (tester) async { - final notification = UserDailyReportCompletedNotification( - type: NotificationType.userDailyReportCompleted, - planName: 'Test Plan', - clientName: 'Test Client', - reportDate: testDate, - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays StayOnTrackToCustomerNotification', (tester) async { - final notification = StayOnTrackToCustomerNotification( - type: NotificationType.stayOnTrackToCustomer, - planName: 'Test Plan', - consultantName: 'Test Consultant', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays PhoneChangedNotification', (tester) async { - final notification = PhoneChangedNotification( - type: NotificationType.phoneChanged, - oldPhone: '+1234567890', - newPhone: '+0987654321', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays SubscriptionNotification', (tester) async { - final notification = SubscriptionNotification( - type: NotificationType.subscription, - subscriptionType: 'monthly', - planName: 'Test Plan', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays BadgeAwardedNotification', (tester) async { - final notification = BadgeAwardedNotification( - type: NotificationType.badgeAwarded, - badgeName: 'Test Badge', - badgeDescription: 'Test Description', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays BadgeRevokedNotification', (tester) async { - final notification = BadgeRevokedNotification( - type: NotificationType.badgeRevoked, - badgeName: 'Test Badge', - reason: 'Test reason', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ConsultantRequestStartedNotification', (tester) async { - final notification = ConsultantRequestStartedNotification( - type: NotificationType.consultantRequestStarted, - consultantName: 'Test Consultant', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ClientCloseComplaintSuccessNotification', (tester) async { - final notification = ClientCloseComplaintSuccessNotification( - type: NotificationType.clientCloseComplaintSuccess, - complaintType: 'test', - entityName: 'Test Entity', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ClientRefundSuccessNotification', (tester) async { - final notification = ClientRefundSuccessNotification( - type: NotificationType.clientRefundSuccess, - planName: 'Test Plan', - amount: 100.0, - reason: 'Test reason', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ConsultantRefundSuccessNotification', (tester) async { - final notification = ConsultantRefundSuccessNotification( - type: NotificationType.consultantRefundSuccess, - planName: 'Test Plan', - clientName: 'Test Client', - amount: 100.0, - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ClientRejectSuccessNotification', (tester) async { - final notification = ClientRejectSuccessNotification( - type: NotificationType.clientRejectSuccess, - planName: 'Test Plan', - reason: 'Test reason', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ConsultantRejectSuccessNotification', (tester) async { - final notification = ConsultantRejectSuccessNotification( - type: NotificationType.consultantRejectSuccess, - planName: 'Test Plan', - clientName: 'Test Client', - reason: 'Test reason', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ScoreSubstractedNotification', (tester) async { - final notification = ScoreSubstractedNotification( - type: NotificationType.scoreSubstracted, - scoreKey: 'test_key', - scorableId: 1, - scorableType: 'test', - scorableName: 'Test Name', - scorableSlug: 'test-slug', - scoreValue: 10, - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays ProductStatusUpdatedForAuthorNotification', (tester) async { - final notification = ProductStatusUpdatedForAuthorNotification( - type: NotificationType.productStatusUpdatedForAuthor, - productName: 'Test Product', - oldStatus: 'pending', - newStatus: 'approved', - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays DiaryReminderForUsersNotification', (tester) async { - final notification = DiaryReminderForUsersNotification( - type: NotificationType.diaryReminderForUsers, - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays PersonalDietIsDefinedToCustomerNotification', (tester) async { - final notification = PersonalDietIsDefinedToCustomerNotification( - type: NotificationType.personalDietIsDefinedToCustomer, - isRead: false, - createdAt: testDate, - dietName: 'Test Diet', - dietId: 1, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('displays UnknownNotification', (tester) async { - final notification = UnknownNotification( - type: NotificationType.unknown, - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - - testWidgets('shows unread indicator when isRead is false', (tester) async { - final notification = DiaryReminderNotification( - type: NotificationType.diaryReminderNotification, - isRead: false, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - // Check for unread indicator (blue circle) - expect(find.byType(Container), findsWidgets); - }); - - testWidgets('hides unread indicator when isRead is true', (tester) async { - final notification = DiaryReminderNotification( - type: NotificationType.diaryReminderNotification, - isRead: true, - createdAt: testDate, - ); - - await tester.pumpWidget(createTestWidget(notification)); - await tester.pumpAndSettle(); - - expect(find.byType(NotificationWidget), findsOneWidget); - }); - }); -} - - - - - - - - - - - - - - - - - - - - - - - - - - - +import 'package:eatvio_app/core/theme/theme_helper.dart'; +import 'package:eatvio_app/features/notifications/models/notification_model.dart'; +import 'package:eatvio_app/features/notifications/presentation/widgets/notification_widget.dart'; +import 'package:eatvio_app/generated/l10n.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; + +void main() { + group('NotificationWidget', () { + final testDate = DateTime(2024, 1, 15, 10, 30); + + Widget createTestWidget(BaseNotificationModel notification) { + return MaterialApp( + localizationsDelegates: const [ + S.delegate, + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + ], + supportedLocales: const [Locale('ru'), Locale('en')], + locale: const Locale('ru'), + theme: ThemeHelper().themeData(), + home: Scaffold( + body: NotificationWidget(notification: notification), + ), + ); + } + + testWidgets('displays PlanSubscriptionStartedToAuthorNotification', (tester) async { + final notification = PlanSubscriptionStartedToAuthorNotification( + type: NotificationType.planSubscriptionStartedToAuthor, + planName: 'Test Plan', + customerName: 'Test Customer', + chatId: 'chat123', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays PlanSubscriptionCanceledToAuthorNotification', (tester) async { + final notification = PlanSubscriptionCanceledToAuthorNotification( + type: NotificationType.planSubscriptionCanceledToAuthor, + planName: 'Test Plan', + customerName: 'Test Customer', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ChosenPlanStartedToClientNotification', (tester) async { + final notification = ChosenPlanStartedToClientNotification( + type: NotificationType.chosenPlanStartedToClient, + planName: 'Test Plan', + planId: 1, + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ChosenPlanTomorrowReminderToClientNotification', (tester) async { + final notification = ChosenPlanTomorrowReminderToClientNotification( + type: NotificationType.chosenPlanTomorrowReminderToClient, + planName: 'Test Plan', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays DiaryReminderNotification', (tester) async { + final notification = DiaryReminderNotification( + type: NotificationType.diaryReminderNotification, + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ConsultantLeftCommentNotification', (tester) async { + final notification = ConsultantLeftCommentNotification( + type: NotificationType.consultantLeftComment, + date: testDate, + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays PersonalizedDietIsDefinedNotification', (tester) async { + final notification = PersonalizedDietIsDefinedNotification( + type: NotificationType.personalizedDietIsDefined, + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ChosenPlanFinishedToClientNotification', (tester) async { + final notification = ChosenPlanFinishedToClientNotification( + type: NotificationType.chosenPlanFinishedToClient, + planName: 'Test Plan', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays PlanSubscriptionCanceledToCustomerNotification', (tester) async { + final notification = PlanSubscriptionCanceledToCustomerNotification( + type: NotificationType.planSubscriptionCanceledToCustomer, + planName: 'Test Plan', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ChosenPlanStartedToConsultantNotification', (tester) async { + final notification = ChosenPlanStartedToConsultantNotification( + type: NotificationType.chosenPlanStartedToConsultant, + planName: 'Test Plan', + customerName: 'Test Customer', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ChosenPlanTomorrowReminderToConsultantNotification', (tester) async { + final notification = ChosenPlanTomorrowReminderToConsultantNotification( + type: NotificationType.chosenPlanTomorrowReminderToConsultant, + planName: 'Test Plan', + customerName: 'Test Customer', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays PlanSubscriptionPaidToAuthorNotification', (tester) async { + final notification = PlanSubscriptionPaidToAuthorNotification( + type: NotificationType.planSubscriptionPaidToAuthor, + planName: 'Test Plan', + customerName: 'Test Customer', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ChosenPlanFinishedToConsultantNotification with button', (tester) async { + final notification = ChosenPlanFinishedToConsultantNotification( + type: NotificationType.chosenPlanFinishedToConsultant, + planName: 'Test Plan', + customerName: 'Test Customer', + planId: 1, + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ChosenPlanLastDayFinishedForUser', (tester) async { + final notification = ChosenPlanLastDayFinishedForUser( + type: NotificationType.chosenPlanLastDayFinishedForUser, + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ChosenPlanConsultantLastDayStarted', (tester) async { + final notification = ChosenPlanConsultantLastDayStarted( + type: NotificationType.chosenPlanConsultantLastDayStarted, + planName: 'Test Plan', + planId: 1, + chatId: 'chat123', + chatUrl: 'chat_url', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ComplaintToModerationForUser', (tester) async { + final notification = ComplaintToModerationForUser( + type: NotificationType.complaintToModerationForUser, + message: 'Test message', + entityId: 1, + entityType: 'test', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays CommentReplied', (tester) async { + final notification = CommentReplied( + type: NotificationType.commentReplied, + entityName: 'Test Entity', + commentedEntityId: 1, + commentedEntityType: 'test', + author: 'Test Author', + authorId: 1, + parentCommentId: 1, + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ScoreAdded', (tester) async { + final notification = ScoreAdded( + type: NotificationType.scoreAdded, + scoreKey: 'test_key', + scorableId: 1, + scorableType: 'test', + scorableName: 'Test Name', + scorableSlug: 'test-slug', + scoreValue: 10, + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays EntityCommented', (tester) async { + final notification = EntityCommented( + type: NotificationType.entityCommented, + entityName: 'Test Entity', + entityId: 1, + entityType: 'test', + entityTranslatedType: 'Test Type', + entityUrl: 'test_url', + authorName: 'Test Author', + authorId: 1, + authorSlug: 'test-author', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays PlanSubscriptionExpiredNotification', (tester) async { + final notification = PlanSubscriptionExpiredNotification( + type: NotificationType.planSubscriptionExpired, + planName: 'Test Plan', + customerName: 'Test Customer', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays PlanSubscriptionRenewedNotification', (tester) async { + final notification = PlanSubscriptionRenewedNotification( + type: NotificationType.planSubscriptionRenewed, + planName: 'Test Plan', + customerName: 'Test Customer', + renewalDate: '2024-02-01', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ConsultantAssignedNotification', (tester) async { + final notification = ConsultantAssignedNotification( + type: NotificationType.consultantAssigned, + consultantName: 'Test Consultant', + planName: 'Test Plan', + planId: 1, + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ConsultantUnassignedNotification', (tester) async { + final notification = ConsultantUnassignedNotification( + type: NotificationType.consultantUnassigned, + consultantName: 'Test Consultant', + planName: 'Test Plan', + planId: 1, + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays PaymentFailedNotification', (tester) async { + final notification = PaymentFailedNotification( + type: NotificationType.paymentFailed, + planName: 'Test Plan', + errorMessage: 'Test error', + paymentMethod: 'card', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays PaymentSuccessfulNotification', (tester) async { + final notification = PaymentSuccessfulNotification( + type: NotificationType.paymentSuccessful, + planName: 'Test Plan', + amount: 100.0, + currency: 'USD', + transactionId: 'trans123', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays GoalAchievedNotification', (tester) async { + final notification = GoalAchievedNotification( + type: NotificationType.goalAchieved, + goalName: 'Test Goal', + goalType: 'weight', + achievedValue: 50.0, + targetValue: 100.0, + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays WorkoutReminderNotification', (tester) async { + final notification = WorkoutReminderNotification( + type: NotificationType.workoutReminder, + workoutName: 'Test Workout', + workoutType: 'cardio', + duration: 30, + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays MealReminderNotification', (tester) async { + final notification = MealReminderNotification( + type: NotificationType.mealReminder, + mealName: 'Test Meal', + mealType: 'breakfast', + calories: 500, + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays DietCancelledNotification', (tester) async { + final notification = DietCancelledNotification( + type: NotificationType.dietCancelled, + dietName: 'Test Diet', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays DietStartedNotification', (tester) async { + final notification = DietStartedNotification( + type: NotificationType.dietStarted, + dietName: 'Test Diet', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays DietExpiredNotification', (tester) async { + final notification = DietExpiredNotification( + type: NotificationType.dietExpired, + dietName: 'Test Diet', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays DietWillStartedInNotification', (tester) async { + final notification = DietWillStartedInNotification( + type: NotificationType.dietWillStartedIn, + dietName: 'Test Diet', + startDate: '2024-02-01', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays DietCanNotBeStartedNotification', (tester) async { + final notification = DietCanNotBeStartedNotification( + type: NotificationType.dietCanNotBeStarted, + dietName: 'Test Diet', + reason: 'Test reason', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays PersonalDietCreationNeededNotification', (tester) async { + final notification = PersonalDietCreationNeededNotification( + type: NotificationType.personalDietCreationNeeded, + planName: 'Test Plan', + clientName: 'Test Client', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ChosenPlanClientLastDayFinishedNotification', (tester) async { + final notification = ChosenPlanClientLastDayFinishedNotification( + type: NotificationType.chosenPlanClientLastDayFinished, + planName: 'Test Plan', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ChosenPlanClientLastDayStartedNotification', (tester) async { + final notification = ChosenPlanClientLastDayStartedNotification( + type: NotificationType.chosenPlanClientLastDayStarted, + planName: 'Test Plan', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays StayOnTrackToAuthorNotification', (tester) async { + final notification = StayOnTrackToAuthorNotification( + type: NotificationType.stayOnTrackToAuthor, + planName: 'Test Plan', + clientName: 'Test Client', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ClientStartPlanSubscriptionToSubscriberNotification', (tester) async { + final notification = ClientStartPlanSubscriptionToSubscriberNotification( + type: NotificationType.clientStartPlanSubscriptionToSubscriber, + planName: 'Test Plan', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ConsultantConfirmPlanSubscriptionToSubscriberNotification', (tester) async { + final notification = ConsultantConfirmPlanSubscriptionToSubscriberNotification( + type: NotificationType.consultantConfirmPlanSubscriptionToSubscriber, + planName: 'Test Plan', + consultantName: 'Test Consultant', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ClientPaidPlanSubscriptionToAuthorNotification', (tester) async { + final notification = ClientPaidPlanSubscriptionToAuthorNotification( + type: NotificationType.clientPaidPlanSubscriptionToAuthor, + planName: 'Test Plan', + clientName: 'Test Client', + amount: 100.0, + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ConsultantLeftDiaryCommentNotification', (tester) async { + final notification = ConsultantLeftDiaryCommentNotification( + type: NotificationType.consultantLeftDiaryComment, + planName: 'Test Plan', + consultantName: 'Test Consultant', + diaryDate: testDate, + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ConsultantConfirmPlanSubscriptionToAuthorNotification', (tester) async { + final notification = ConsultantConfirmPlanSubscriptionToAuthorNotification( + type: NotificationType.consultantConfirmPlanSubscriptionToAuthor, + planName: 'Test Plan', + consultantName: 'Test Consultant', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ClientPaidPlanSubscriptionToSubscriberNotification', (tester) async { + final notification = ClientPaidPlanSubscriptionToSubscriberNotification( + type: NotificationType.clientPaidPlanSubscriptionToSubscriber, + planName: 'Test Plan', + amount: 100.0, + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ClientStartPlanSubscriptionToAuthorNotification', (tester) async { + final notification = ClientStartPlanSubscriptionToAuthorNotification( + type: NotificationType.clientStartPlanSubscriptionToAuthor, + planName: 'Test Plan', + clientName: 'Test Client', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ClientCancelPlanSubscriptionToAuthorNotification', (tester) async { + final notification = ClientCancelPlanSubscriptionToAuthorNotification( + type: NotificationType.clientCancelPlanSubscriptionToAuthor, + planName: 'Test Plan', + clientName: 'Test Client', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ClientCancelPlanSubscriptionToSubscriberNotification', (tester) async { + final notification = ClientCancelPlanSubscriptionToSubscriberNotification( + type: NotificationType.clientCancelPlanSubscriptionToSubscriber, + planName: 'Test Plan', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays UserDailyReportCompletedNotification', (tester) async { + final notification = UserDailyReportCompletedNotification( + type: NotificationType.userDailyReportCompleted, + planName: 'Test Plan', + clientName: 'Test Client', + reportDate: testDate, + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays StayOnTrackToCustomerNotification', (tester) async { + final notification = StayOnTrackToCustomerNotification( + type: NotificationType.stayOnTrackToCustomer, + planName: 'Test Plan', + consultantName: 'Test Consultant', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays PhoneChangedNotification', (tester) async { + final notification = PhoneChangedNotification( + type: NotificationType.phoneChanged, + oldPhone: '+1234567890', + newPhone: '+0987654321', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays SubscriptionNotification', (tester) async { + final notification = SubscriptionNotification( + type: NotificationType.subscription, + subscriptionType: 'monthly', + planName: 'Test Plan', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays BadgeAwardedNotification', (tester) async { + final notification = BadgeAwardedNotification( + type: NotificationType.badgeAwarded, + badgeName: 'Test Badge', + badgeDescription: 'Test Description', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays BadgeRevokedNotification', (tester) async { + final notification = BadgeRevokedNotification( + type: NotificationType.badgeRevoked, + badgeName: 'Test Badge', + reason: 'Test reason', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ConsultantRequestStartedNotification', (tester) async { + final notification = ConsultantRequestStartedNotification( + type: NotificationType.consultantRequestStarted, + consultantName: 'Test Consultant', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ClientCloseComplaintSuccessNotification', (tester) async { + final notification = ClientCloseComplaintSuccessNotification( + type: NotificationType.clientCloseComplaintSuccess, + complaintType: 'test', + entityName: 'Test Entity', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ClientRefundSuccessNotification', (tester) async { + final notification = ClientRefundSuccessNotification( + type: NotificationType.clientRefundSuccess, + planName: 'Test Plan', + amount: 100.0, + reason: 'Test reason', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ConsultantRefundSuccessNotification', (tester) async { + final notification = ConsultantRefundSuccessNotification( + type: NotificationType.consultantRefundSuccess, + planName: 'Test Plan', + clientName: 'Test Client', + amount: 100.0, + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ClientRejectSuccessNotification', (tester) async { + final notification = ClientRejectSuccessNotification( + type: NotificationType.clientRejectSuccess, + planName: 'Test Plan', + reason: 'Test reason', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ConsultantRejectSuccessNotification', (tester) async { + final notification = ConsultantRejectSuccessNotification( + type: NotificationType.consultantRejectSuccess, + planName: 'Test Plan', + clientName: 'Test Client', + reason: 'Test reason', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ScoreSubstractedNotification', (tester) async { + final notification = ScoreSubstractedNotification( + type: NotificationType.scoreSubstracted, + scoreKey: 'test_key', + scorableId: 1, + scorableType: 'test', + scorableName: 'Test Name', + scorableSlug: 'test-slug', + scoreValue: 10, + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays ProductStatusUpdatedForAuthorNotification', (tester) async { + final notification = ProductStatusUpdatedForAuthorNotification( + type: NotificationType.productStatusUpdatedForAuthor, + productName: 'Test Product', + oldStatus: 'pending', + newStatus: 'approved', + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays DiaryReminderForUsersNotification', (tester) async { + final notification = DiaryReminderForUsersNotification( + type: NotificationType.diaryReminderForUsers, + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays PersonalDietIsDefinedToCustomerNotification', (tester) async { + final notification = PersonalDietIsDefinedToCustomerNotification( + type: NotificationType.personalDietIsDefinedToCustomer, + isRead: false, + createdAt: testDate, + dietName: 'Test Diet', + dietId: 1, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('displays UnknownNotification', (tester) async { + final notification = UnknownNotification( + type: NotificationType.unknown, + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + + testWidgets('shows unread indicator when isRead is false', (tester) async { + final notification = DiaryReminderNotification( + type: NotificationType.diaryReminderNotification, + isRead: false, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + // Check for unread indicator (blue circle) + expect(find.byType(Container), findsWidgets); + }); + + testWidgets('hides unread indicator when isRead is true', (tester) async { + final notification = DiaryReminderNotification( + type: NotificationType.diaryReminderNotification, + isRead: true, + createdAt: testDate, + ); + + await tester.pumpWidget(createTestWidget(notification)); + await tester.pumpAndSettle(); + + expect(find.byType(NotificationWidget), findsOneWidget); + }); + }); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/features/notifications/service/notifications_service_test.dart b/test/features/notifications/service/notifications_service_test.dart index 59a6ae76..988085d2 100644 --- a/test/features/notifications/service/notifications_service_test.dart +++ b/test/features/notifications/service/notifications_service_test.dart @@ -1,79 +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()]) -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?>()); - expect(result, isNotNull); - expect(result!['notifications'], isA()); - 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()]) +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?>()); + expect(result, isNotNull); + expect(result!['notifications'], isA()); + 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); + }); + }); +} + + + + + + + + + + + + + + + + + + +