Merge remote-tracking branch 'upstream/main'

This commit is contained in:
misha
2026-01-20 12:00:44 +03:00
50 changed files with 984 additions and 1131 deletions

View File

@@ -12,10 +12,7 @@ void main() {
test('createRoutes содержит маршрут authScreen', () {
final routes = AuthRoutes.createRoutes();
final authRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/auth-screen',
orElse: () => throw Exception('Route not found'),
);
final authRoute = routes.firstWhere((route) => route is GoRoute && route.path == '/auth-screen', orElse: () => throw Exception('Route not found'));
expect(authRoute, isA<GoRoute>());
});
@@ -67,10 +64,7 @@ void main() {
test('createRoutes содержит маршрут verifyScreen', () {
final routes = AuthRoutes.createRoutes();
final verifyRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/verify-screen',
orElse: () => throw Exception('Route not found'),
);
final verifyRoute = routes.firstWhere((route) => route is GoRoute && route.path == '/verify-screen', orElse: () => throw Exception('Route not found'));
expect(verifyRoute, isA<GoRoute>());
});
@@ -92,44 +86,25 @@ void main() {
expect(registerViaSocialRoute, isA<GoRoute>());
});
test('authScreen имеет redirect функцию', () {
final routes = AuthRoutes.createRoutes();
final authRoute = routes.first as GoRoute;
expect(authRoute.redirect, isNotNull);
});
test('forgetPasswordScreen builder обрабатывает extra данные', () {
final routes = AuthRoutes.createRoutes();
final authRoute = routes.first as GoRoute;
final forgetPasswordRoute = authRoute.routes.firstWhere(
(route) => route is GoRoute && route.path == 'forget-password-screen',
orElse: () => throw Exception('Route not found'),
) as GoRoute;
final forgetPasswordRoute =
authRoute.routes.firstWhere((route) => route is GoRoute && route.path == 'forget-password-screen', orElse: () => throw Exception('Route not found'))
as GoRoute;
expect(forgetPasswordRoute.builder, isNotNull);
});
test('verifyScreen builder обрабатывает extra данные', () {
final routes = AuthRoutes.createRoutes();
final verifyRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/verify-screen',
) as GoRoute;
final verifyRoute = routes.firstWhere((route) => route is GoRoute && route.path == '/verify-screen') as GoRoute;
expect(verifyRoute.builder, isNotNull);
});
test('registerViaSocialScreen builder обрабатывает extra данные', () {
final routes = AuthRoutes.createRoutes();
final registerViaSocialRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/register-via-social-screen',
) as GoRoute;
final registerViaSocialRoute = routes.firstWhere((route) => route is GoRoute && route.path == '/register-via-social-screen') as GoRoute;
expect(registerViaSocialRoute.builder, isNotNull);
});
});
}

View File

@@ -6,6 +6,10 @@ void main() {
group('TokenStorage', () {
setUp(() async {
SharedPreferences.setMockInitialValues({});
// Clear cached instance to ensure fresh state for each test
TokenStorage.clearCache();
final prefs = await SharedPreferences.getInstance();
await prefs.clear();
});
test('haveTokenInStorage returns false when no token is stored', () async {
@@ -66,6 +70,10 @@ void main() {
group('SocketIdStorage', () {
setUp(() async {
SharedPreferences.setMockInitialValues({});
// Clear cached instance to ensure fresh state for each test
TokenStorage.clearCache();
final prefs = await SharedPreferences.getInstance();
await prefs.clear();
});
test('haveSocketIdInStorage returns false when no socketId is stored', () async {

View File

@@ -29,6 +29,7 @@ void main() {
const MarketingBottomSheet(),
),
);
await tester.pumpAndSettle();
expect(find.byType(MarketingBottomSheet), findsOneWidget);
});
@@ -59,6 +60,7 @@ void main() {
),
);
await tester.pump();
await tester.tap(find.text('Show'));
await tester.pumpAndSettle();

View File

@@ -24,6 +24,7 @@ void main() {
testWidgets('returns SizedBox.shrink when option is null', (tester) async {
await tester.pumpWidget(createTestWidget(const OptionWidget(option: null, duration: 7)));
await tester.pumpAndSettle();
expect(find.byType(OptionWidget), findsOneWidget);
expect(find.byType(SizedBox), findsWidgets);
@@ -33,6 +34,7 @@ void main() {
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)));
await tester.pumpAndSettle();
expect(find.byType(OptionWidget), findsOneWidget);
expect(find.text('Short'), findsOneWidget);
@@ -43,6 +45,7 @@ void main() {
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)));
await tester.pumpAndSettle();
expect(find.byType(OptionWidget), findsOneWidget);
});
@@ -51,6 +54,7 @@ void main() {
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)));
await tester.pumpAndSettle();
expect(find.byType(OptionWidget), findsOneWidget);
});

View File

@@ -31,6 +31,7 @@ void main() {
),
);
await tester.pump();
await tester.tap(find.text('Show Error'));
await tester.pumpAndSettle();
@@ -68,6 +69,7 @@ void main() {
),
);
await tester.pump();
await tester.tap(find.text('Show Error'));
await tester.pumpAndSettle();
@@ -103,6 +105,7 @@ void main() {
),
);
await tester.pump();
await tester.tap(find.text('Show Error'));
await tester.pumpAndSettle();
@@ -134,6 +137,7 @@ void main() {
),
);
await tester.pump();
await tester.tap(find.text('Show Error'));
await tester.pumpAndSettle();

View File

@@ -2,6 +2,8 @@ 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/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_cubit.dart';
import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_state.dart';
import 'package:eatvio_app/features/bottom_navigation_bar/presentation/widgets/bottom_navigation_bar_widget.dart';
import 'package:eatvio_app/features/chat/presentation/bloc/chats_cubit/chats_cubit.dart';
import 'package:eatvio_app/features/chat/presentation/bloc/chats_cubit/chats_state.dart';
@@ -20,7 +22,7 @@ import 'package:network_image_mock/network_image_mock.dart';
import 'bottom_navigation_bar_widget_test.mocks.dart';
@GenerateNiceMocks([MockSpec<NotificationsCubit>(), MockSpec<ChatsCubit>()])
@GenerateNiceMocks([MockSpec<NotificationsCubit>(), MockSpec<ChatsCubit>(), MockSpec<ProfileAvatarCubit>()])
void main() {
group('BottomNavigationBarWidget smoke', () {
setUpAll(() async {
@@ -86,6 +88,7 @@ void main() {
mockNetworkImagesFor(() async {
final notificationsCubit = MockNotificationsCubit();
final chatsCubit = MockChatsCubit();
final profileAvatarCubit = MockProfileAvatarCubit();
when(notificationsCubit.state).thenReturn(const NotificationsState());
when(notificationsCubit.stream).thenAnswer((_) => const Stream.empty());
@@ -93,16 +96,20 @@ void main() {
when(chatsCubit.state).thenReturn(ChatsState());
when(chatsCubit.stream).thenAnswer((_) => const Stream.empty());
when(chatsCubit.close()).thenAnswer((_) async => Future<void>.value());
when(profileAvatarCubit.state).thenReturn(const ProfileAvatarState.loaded(profile: mockUserProfile));
when(profileAvatarCubit.stream).thenAnswer((_) => const Stream.empty());
when(profileAvatarCubit.close()).thenAnswer((_) async => Future<void>.value());
await tester.pumpWidget(
MultiBlocProvider(
providers: [
BlocProvider<NotificationsCubit>.value(value: notificationsCubit),
BlocProvider<ChatsCubit>.value(value: chatsCubit),
BlocProvider<ProfileAvatarCubit>.value(value: profileAvatarCubit),
],
child: wrap(
const Scaffold(
body: BottomNavigationBarWidget(profileModel: mockUserProfile, child: Text('Test Content')),
body: BottomNavigationBarWidget(child: Text('Test Content')),
),
),
),
@@ -117,6 +124,7 @@ void main() {
mockNetworkImagesFor(() async {
final notificationsCubit = MockNotificationsCubit();
final chatsCubit = MockChatsCubit();
final profileAvatarCubit = MockProfileAvatarCubit();
when(notificationsCubit.state).thenReturn(const NotificationsState());
when(notificationsCubit.stream).thenAnswer((_) => const Stream.empty());
@@ -124,16 +132,20 @@ void main() {
when(chatsCubit.state).thenReturn(ChatsState());
when(chatsCubit.stream).thenAnswer((_) => const Stream.empty());
when(chatsCubit.close()).thenAnswer((_) async => Future<void>.value());
when(profileAvatarCubit.state).thenReturn(const ProfileAvatarState.loaded(profile: mockConsultantProfile));
when(profileAvatarCubit.stream).thenAnswer((_) => const Stream.empty());
when(profileAvatarCubit.close()).thenAnswer((_) async => Future<void>.value());
await tester.pumpWidget(
MultiBlocProvider(
providers: [
BlocProvider<NotificationsCubit>.value(value: notificationsCubit),
BlocProvider<ChatsCubit>.value(value: chatsCubit),
BlocProvider<ProfileAvatarCubit>.value(value: profileAvatarCubit),
],
child: wrap(
const Scaffold(
body: BottomNavigationBarWidget(profileModel: mockConsultantProfile, child: Text('Test Content')),
body: BottomNavigationBarWidget(child: Text('Test Content')),
),
),
),

View File

@@ -34,6 +34,7 @@ void main() {
),
),
);
await tester.pumpAndSettle();
expect(find.byType(ChosenDietWidgetContent), findsOneWidget);
expect(find.text('Test Diet'), findsOneWidget);
@@ -50,6 +51,7 @@ void main() {
),
),
);
await tester.pumpAndSettle();
expect(find.byType(ChosenDietWidgetContent), findsOneWidget);
});
@@ -65,6 +67,7 @@ void main() {
),
),
);
await tester.pumpAndSettle();
expect(find.text('My Diet'), findsOneWidget);
});

View File

@@ -37,6 +37,7 @@ void main() {
planName: 'Test Plan',
planDuration: 14,
));
await tester.pumpAndSettle();
expect(find.byType(ChosenPlanWidgetContent), findsOneWidget);
expect(find.text('Test Plan'), findsOneWidget);
@@ -48,6 +49,7 @@ void main() {
planName: 'My Plan',
planDuration: 7,
));
await tester.pumpAndSettle();
expect(find.byType(ChosenPlanWidgetContent), findsOneWidget);
expect(find.textContaining('3'), findsOneWidget);
@@ -60,6 +62,7 @@ void main() {
planName: 'Long Plan',
planDuration: 30,
));
await tester.pumpAndSettle();
expect(find.byType(ChosenPlanWidgetContent), findsOneWidget);
expect(find.text('Long Plan'), findsOneWidget);

View File

@@ -78,6 +78,7 @@ void main() {
),
),
);
await tester.pumpAndSettle();
expect(find.byType(CommentsWidget), findsOneWidget);
});

View File

@@ -63,6 +63,7 @@ void main() {
// Act
await tester.pumpWidget(createTestWidget(const SizedBox(), mockCubit));
await tester.pump();
await tester.tap(find.text('Show Bottom Sheet'));
await tester.pumpAndSettle();
@@ -107,6 +108,7 @@ void main() {
// Act
await tester.pumpWidget(createTestWidgetError(const SizedBox(), mockCubit));
await tester.pump();
await tester.tap(find.text('Show Bottom Sheet'));
await tester.pumpAndSettle();

View File

@@ -54,6 +54,7 @@ void main() {
home: ChangePasswordScreen(settingsEntity: settingsEntity),
),
);
await tester.pumpAndSettle();
expect(find.byType(ChangePasswordScreen), findsOneWidget);
expect(find.text('Смена пароля'), findsOneWidget);
@@ -80,6 +81,7 @@ void main() {
home: ChangePasswordScreen(settingsEntity: settingsEntity),
),
);
await tester.pumpAndSettle();
expect(find.byType(AppBar), findsOneWidget);
expect(find.text('Смена пароля'), findsOneWidget);