import 'package:eatvio_app/core/app_config.dart'; import 'package:eatvio_app/core/app_initializer.dart'; import 'package:eatvio_app/core/locator_service.dart'; import 'package:eatvio_app/core/theme/theme_helper.dart'; import 'package:eatvio_app/features/profile/models/profile_model.dart'; import 'package:eatvio_app/features/settings/entities/settings_entity.dart'; import 'package:eatvio_app/features/settings/models/profile_settings_model.dart'; import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_cubit.dart'; import 'package:eatvio_app/features/settings/presentation/bloc/settings_cubit/settings_state.dart'; import 'package:eatvio_app/features/settings/presentation/pages/pressure_screen.dart'; import 'package:eatvio_app/generated/l10n.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:go_router/go_router.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'pressure_screen_test.mocks.dart'; @GenerateNiceMocks([MockSpec()]) void main() { group('PressureScreen smoke', () { setUpAll(() async { dotenv.loadFromString(envString: 'DEV_BASE_URL=http://localhost\nBASE_URL=http://localhost'); }); setUp(() async { await sl.reset(); sl.registerLazySingleton(() => AppConfig(buildType: AppBuildType.tests)..setBaseUrl('http://localhost')); }); const mockProfile = ProfileModel( id: 1, name: 'Test User', email: 'test@example.com', phoneConfirmationState: 'confirmed', isPublicProfile: true, isBlockedByMe: false, isBlockedByAuthor: false, isBlockedByUser: false, isEntitySubscribedByMe: false, slug: 'test-user', profilePhotoUrl: '/test.jpg', roles: ['user'], badges: [], subscriptions: [], subscribers: [], ); const mockProfileDetails = ProfileDetailsModel( firstName: 'Test', lastName: 'User', birthdate: '1990-01-01', gender: 'male', country: 'Russia', city: 'Moscow', lang: 'ru', weight: 70.0, height: 175, chestCircumference: 90, waistCircumference: 80, hipCircumference: 95, bloodPressureUp: 120, bloodPressureDown: 80, hasHypo: false, hasHyper: false, aboutAlergy: '', aboutTakingPils: '', aboutSportHobbies: '', favoriteFoods: '', unfavoriteFoods: '', additionalInfo: '', isMoodFillable: true, isBedtimeFillable: true, activityCoefficient: 1.2, ); const mockProfileSettings = ProfileSettingsModel( newUpdatesNotifications: 1, diaryReminderNotifications: 1, isMoodFillable: true, isBedtimeFillable: true, isPublicProfile: true, ); Widget wrap(Widget child) { return MaterialApp.router( theme: ThemeHelper().themeData(), localizationsDelegates: const [ S.delegate, GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, GlobalCupertinoLocalizations.delegate, ], supportedLocales: const [Locale('ru')], routerConfig: GoRouter( initialLocation: '/', routes: [GoRoute(path: '/', builder: (context, state) => child)], ), ); } testWidgets('renders pressure screen', (tester) async { final cubit = MockSettingsCubit(); const state = SettingsState.loaded( profileSettings: mockProfileSettings, profileDetails: mockProfileDetails, profile: mockProfile, hasActiveConsultation: false, ); when(cubit.state).thenReturn(state); when(cubit.stream).thenAnswer((_) => Stream.value(state)); when(cubit.close()).thenAnswer((_) async => Future.value()); when(cubit.updateProfileDetails(profileDetailsModel: anyNamed('profileDetailsModel'))).thenAnswer((_) async => Future.value()); final settingsEntity = SettingsEntity(profileSettingsModel: mockProfileSettings, profileDetailsModel: mockProfileDetails, settingsCubit: cubit); await tester.pumpWidget( BlocProvider.value( value: cubit, child: wrap(PressureScreen(settingsEntity: settingsEntity)), ), ); await tester.pump(); await tester.pump(const Duration(milliseconds: 100)); expect(find.byType(PressureScreen), findsOneWidget); }); }); }