feat(tests): test coverage is 69.2

This commit is contained in:
misha
2026-01-21 09:19:41 +03:00
parent 775d4fb80f
commit f6809a06b3
16 changed files with 5274 additions and 333 deletions

View File

@@ -135,6 +135,91 @@ void main() {
expect(blogPostRoute.builder, isNotNull);
});
test('aboutPlanScreen builder обрабатывает slug из query параметров с navigateToComments false', () {
final routes = ContentRoutes.createRoutes();
final planRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/about-plan-screen',
) as GoRoute;
expect(planRoute.builder, isNotNull);
expect(planRoute.name, 'aboutPlanScreen');
});
test('aboutRecipesScreen builder обрабатывает slug из query параметров с navigateToComments false', () {
final routes = ContentRoutes.createRoutes();
final recipeRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/about-recipes-screen',
) as GoRoute;
expect(recipeRoute.builder, isNotNull);
expect(recipeRoute.name, 'aboutRecipesScreen');
});
test('aboutDietScreen builder обрабатывает slug из query параметров с index null', () {
final routes = ContentRoutes.createRoutes();
final dietRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/about-diet-screen',
) as GoRoute;
expect(dietRoute.builder, isNotNull);
expect(dietRoute.name, 'aboutDietScreen');
});
test('blogPostScreen builder обрабатывает id из query параметров как int', () {
final routes = ContentRoutes.createRoutes();
final blogPostRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/blog-post-screen',
) as GoRoute;
expect(blogPostRoute.builder, isNotNull);
expect(blogPostRoute.name, 'blogPostScreen');
});
test('blogPostScreen builder обрабатывает id из extra как int', () {
final routes = ContentRoutes.createRoutes();
final blogPostRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/blog-post-screen',
) as GoRoute;
expect(blogPostRoute.builder, isNotNull);
});
test('aboutPlanScreen builder обрабатывает extra данные с index', () {
final routes = ContentRoutes.createRoutes();
final planRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/about-plan-screen',
) as GoRoute;
expect(planRoute.builder, isNotNull);
});
test('aboutRecipesScreen builder обрабатывает extra данные с index', () {
final routes = ContentRoutes.createRoutes();
final recipeRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/about-recipes-screen',
) as GoRoute;
expect(recipeRoute.builder, isNotNull);
});
test('aboutDietScreen builder обрабатывает extra данные с id и slug', () {
final routes = ContentRoutes.createRoutes();
final dietRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/about-diet-screen',
) as GoRoute;
expect(dietRoute.builder, isNotNull);
});
test('blogPostCreateScreen builder обрабатывает null extra', () {
final routes = ContentRoutes.createRoutes();
final blogPostCreateRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/blog-post-create-screen',
) as GoRoute;
expect(blogPostCreateRoute.builder, isNotNull);
});
});
}

View File

@@ -14,6 +14,109 @@ void main() {
final routes = MainNavigationRoutes.createRoutes();
expect(routes.first, isA<ShellRoute>());
});
test('ShellRoute содержит маршрут myProfileScreen', () {
final routes = MainNavigationRoutes.createRoutes();
final shellRoute = routes.first as ShellRoute;
final myProfileRoute = shellRoute.routes.firstWhere(
(route) => route is GoRoute && route.path == '/my-profile-screen',
orElse: () => throw Exception('Route not found'),
);
expect(myProfileRoute, isA<GoRoute>());
expect((myProfileRoute as GoRoute).name, 'myProfileScreen');
});
test('ShellRoute содержит маршрут feedScreen', () {
final routes = MainNavigationRoutes.createRoutes();
final shellRoute = routes.first as ShellRoute;
final feedRoute = shellRoute.routes.firstWhere(
(route) => route is GoRoute && route.path == '/feed-screen',
orElse: () => throw Exception('Route not found'),
);
expect(feedRoute, isA<GoRoute>());
expect((feedRoute as GoRoute).name, 'feedScreen');
});
test('ShellRoute содержит маршрут diaryScreen', () {
final routes = MainNavigationRoutes.createRoutes();
final shellRoute = routes.first as ShellRoute;
final diaryRoute = shellRoute.routes.firstWhere(
(route) => route is GoRoute && route.path == '/diary-screen',
orElse: () => throw Exception('Route not found'),
);
expect(diaryRoute, isA<GoRoute>());
expect((diaryRoute as GoRoute).name, 'diaryScreen');
});
test('ShellRoute содержит маршрут consultationsScreen', () {
final routes = MainNavigationRoutes.createRoutes();
final shellRoute = routes.first as ShellRoute;
final consultationsRoute = shellRoute.routes.firstWhere(
(route) => route is GoRoute && route.path == '/consultations-screen',
orElse: () => throw Exception('Route not found'),
);
expect(consultationsRoute, isA<GoRoute>());
});
test('ShellRoute содержит маршрут chatSelectScreen', () {
final routes = MainNavigationRoutes.createRoutes();
final shellRoute = routes.first as ShellRoute;
final chatSelectRoute = shellRoute.routes.firstWhere(
(route) => route is GoRoute && route.path == '/chat-select-screen',
orElse: () => throw Exception('Route not found'),
);
expect(chatSelectRoute, isA<GoRoute>());
expect((chatSelectRoute as GoRoute).name, 'chatSelectScreen');
});
test('ShellRoute содержит маршрут notificationsScreen', () {
final routes = MainNavigationRoutes.createRoutes();
final shellRoute = routes.first as ShellRoute;
final notificationsRoute = shellRoute.routes.firstWhere(
(route) => route is GoRoute && route.path == '/notifications-screen',
orElse: () => throw Exception('Route not found'),
);
expect(notificationsRoute, isA<GoRoute>());
expect((notificationsRoute as GoRoute).name, 'notificationsScreen');
});
test('ShellRoute содержит маршрут menuScreen', () {
final routes = MainNavigationRoutes.createRoutes();
final shellRoute = routes.first as ShellRoute;
final menuRoute = shellRoute.routes.firstWhere(
(route) => route is GoRoute && route.path == '/menu-screen',
orElse: () => throw Exception('Route not found'),
);
expect(menuRoute, isA<GoRoute>());
expect((menuRoute as GoRoute).name, 'menuScreen');
});
test('feedScreen имеет redirect функцию', () {
final routes = MainNavigationRoutes.createRoutes();
final shellRoute = routes.first as ShellRoute;
final feedRoute = shellRoute.routes.firstWhere(
(route) => route is GoRoute && route.path == '/feed-screen',
) as GoRoute;
expect(feedRoute.redirect, isNotNull);
});
test('menuScreen использует BlocBuilder для ProfileAvatarCubit', () {
final routes = MainNavigationRoutes.createRoutes();
final shellRoute = routes.first as ShellRoute;
final menuRoute = shellRoute.routes.firstWhere(
(route) => route is GoRoute && route.path == '/menu-screen',
) as GoRoute;
expect(menuRoute.pageBuilder, isNotNull);
});
test('ShellRoute builder инициализирует ProfileAvatarCubit', () {
final routes = MainNavigationRoutes.createRoutes();
final shellRoute = routes.first as ShellRoute;
expect(shellRoute.builder, isNotNull);
});
});
}

View File

@@ -1,4 +1,5 @@
import 'package:eatvio_app/core/routing/other_routes.dart';
import 'package:eatvio_app/core/routing/route_constants.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:go_router/go_router.dart';
@@ -77,5 +78,149 @@ void main() {
routes.firstWhere((route) => route is GoRoute && route.path == '/update-screen', orElse: () => throw Exception('Route not found')) as GoRoute;
expect(updateRoute.redirect, isNotNull);
});
test('createRoutes содержит маршрут chatScreen', () {
final routes = OtherRoutes.createRoutes();
final chatRoute = routes.firstWhere((route) => route is GoRoute && route.path == '/chat-screen', orElse: () => throw Exception('Route not found'));
expect(chatRoute, isA<GoRoute>());
});
test('createRoutes содержит маршрут emptyChatScreen', () {
final routes = OtherRoutes.createRoutes();
final emptyChatRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/empty-chat-screen',
orElse: () => throw Exception('Route not found'),
);
expect(emptyChatRoute, isA<GoRoute>());
});
test('createRoutes содержит маршрут createDietScreen', () {
final routes = OtherRoutes.createRoutes();
final createDietRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/create-diet-screen',
orElse: () => throw Exception('Route not found'),
);
expect(createDietRoute, isA<GoRoute>());
});
test('createRoutes содержит маршрут dietPreviewScreen', () {
final routes = OtherRoutes.createRoutes();
final dietPreviewRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/create-diet-screen/preview',
orElse: () => throw Exception('Route not found'),
);
expect(dietPreviewRoute, isA<GoRoute>());
});
test('createRoutes содержит маршрут myDietsScreen', () {
final routes = OtherRoutes.createRoutes();
final myDietsRoute = routes.firstWhere((route) => route is GoRoute && route.path == '/my-diets-screen', orElse: () => throw Exception('Route not found'));
expect(myDietsRoute, isA<GoRoute>());
});
test('createRoutes содержит маршрут myPlansScreen', () {
final routes = OtherRoutes.createRoutes();
final myPlansRoute = routes.firstWhere((route) => route is GoRoute && route.path == '/my-plans-screen', orElse: () => throw Exception('Route not found'));
expect(myPlansRoute, isA<GoRoute>());
});
test('createRoutes содержит маршрут myRecipesScreen', () {
final routes = OtherRoutes.createRoutes();
final myRecipesRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/my-recipes-screen',
orElse: () => throw Exception('Route not found'),
);
expect(myRecipesRoute, isA<GoRoute>());
});
test('createRoutes содержит маршрут userFinanceScreen', () {
final routes = OtherRoutes.createRoutes();
final userFinanceRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/user-finance-screen',
orElse: () => throw Exception('Route not found'),
);
expect(userFinanceRoute, isA<GoRoute>());
});
test('createRoutes содержит маршрут consultationsArchiveScreen', () {
final routes = OtherRoutes.createRoutes();
final consultationsArchiveRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/consultations-archive-screen',
orElse: () => throw Exception('Route not found'),
);
expect(consultationsArchiveRoute, isA<GoRoute>());
});
test('createRoutes содержит маршрут consultantFinancesScreen', () {
final routes = OtherRoutes.createRoutes();
final consultantFinancesRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/consultant-finances-screen',
orElse: () => throw Exception('Route not found'),
);
expect(consultantFinancesRoute, isA<GoRoute>());
});
test('createRoutes содержит маршрут userPurchasesScreen', () {
final routes = OtherRoutes.createRoutes();
final userPurchasesRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/user-purchases-screen',
orElse: () => throw Exception('Route not found'),
);
expect(userPurchasesRoute, isA<GoRoute>());
});
test('createRoutes содержит маршрут stepperBecomeConsultantScreen', () {
final routes = OtherRoutes.createRoutes();
final stepperBecomeConsultantRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/stepper-become-consultant-screen',
orElse: () => throw Exception('Route not found'),
);
expect(stepperBecomeConsultantRoute, isA<GoRoute>());
});
test('createRoutes содержит маршрут photoViewScreen', () {
final routes = OtherRoutes.createRoutes();
final photoViewRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == RouteConstants.photoViewScreen,
orElse: () => throw Exception('Route not found'),
);
expect(photoViewRoute, isA<GoRoute>());
});
test('createRoutes содержит маршрут userDetailsScreen', () {
final routes = OtherRoutes.createRoutes();
final userDetailsRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/user-details-screen',
orElse: () => throw Exception('Route not found'),
);
expect(userDetailsRoute, isA<GoRoute>());
});
test('createRoutes содержит маршрут personalDietSuggestionScreen', () {
final routes = OtherRoutes.createRoutes();
final personalDietSuggestionRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/personal-diet-suggestion',
orElse: () => throw Exception('Route not found'),
);
expect(personalDietSuggestionRoute, isA<GoRoute>());
});
test('createRoutes содержит маршрут blockedUsersScreen', () {
final routes = OtherRoutes.createRoutes();
final blockedUsersRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/blocked-users-screen',
orElse: () => throw Exception('Route not found'),
);
expect(blockedUsersRoute, isA<GoRoute>());
});
test('createRoutes содержит маршрут notificationsSettingsScreen', () {
final routes = OtherRoutes.createRoutes();
final notificationsSettingsRoute = routes.firstWhere(
(route) => route is GoRoute && route.path == '/notifications-settings-screen',
orElse: () => throw Exception('Route not found'),
);
expect(notificationsSettingsRoute, isA<GoRoute>());
});
});
}