feat(tests): increased tests coverage

This commit is contained in:
misha
2025-12-25 12:56:38 +03:00
parent 5b705dfb72
commit 99659f7ea1
132 changed files with 10304 additions and 6226 deletions

View File

@@ -0,0 +1,85 @@
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/feed/models/diets_pagination_model.dart';
import 'package:eatvio_app/features/feed/models/recipes_model.dart';
import 'package:eatvio_app/features/recipe/presentation/widgets/ingredients_widget.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('IngredientsWidget smoke', () {
setUpAll(() async {
dotenv.loadFromString(envString: 'DEV_BASE_URL=http://localhost\nBASE_URL=http://localhost');
});
setUp(() async {
await sl.reset();
sl.registerLazySingleton<AppConfig>(() => AppConfig(buildType: AppBuildType.tests)..setBaseUrl('http://localhost'));
});
const mockAuthor = Author(
authorSlug: 'test-author',
authorName: 'Test Author',
authorProfileIcon: '/test.jpg',
authorIsMe: false,
isEntitySubscribedByMe: false,
authorPlaceInRating: null,
);
final mockRecipe = Recipe(
id: 1,
image: '/test.jpg',
state: 'active',
cookingTime: 30,
activeCookingTime: 15,
ingredients: const [
Ingredient(name: 'Flour', unit: 'г', portion: '200', productId: 1),
Ingredient(name: 'Sugar', unit: 'г', portion: '100', productId: 2),
],
description: 'Test description',
steps: const [],
videoUrl: null,
createdAt: DateTime.now(),
updatedAt: DateTime.now(),
title: 'Test Recipe',
type: 'main',
slug: 'test-recipe',
commentsCount: 0,
wasLikedByMe: false,
isFavorite: false,
calories: 200.0,
servings: 4,
likesCount: 10,
viewsCount: 100,
tags: const [],
author: mockAuthor,
);
Widget wrap(Widget child) {
return MaterialApp(
theme: ThemeHelper().themeData(),
localizationsDelegates: const [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: const [Locale('ru')],
home: Scaffold(body: child),
);
}
testWidgets('renders ingredients widget', (tester) async {
await tester.pumpWidget(wrap(IngredientsWidget(recipe: mockRecipe)));
await tester.pump();
await tester.pump(const Duration(milliseconds: 100));
expect(find.byType(IngredientsWidget), findsOneWidget);
});
});
}

View File

@@ -0,0 +1,31 @@
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/recipe/presentation/widgets/my_recipes_tab.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('MyRecipesTab smoke', () {
Widget wrap(Widget child) {
return MaterialApp(
theme: ThemeHelper().themeData(),
localizationsDelegates: const [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: const [Locale('ru')],
home: Scaffold(body: child),
);
}
testWidgets('renders my recipes tab', (tester) async {
await tester.pumpWidget(wrap(const MyRecipesTab()));
await tester.pump();
expect(find.byType(MyRecipesTab), findsOneWidget);
});
});
}