feat(tests): add fixtures

This commit is contained in:
mso7nueh
2025-11-20 16:58:56 +03:00
parent 6fa944b3df
commit 4deda92c5e
24 changed files with 6852 additions and 4358 deletions

View File

@@ -1,24 +1,22 @@
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/create_plan/presentation/cubit/create_plan_cubit.dart';
import 'package:eatvio_app/features/create_plan/repositories/create_plan_repository.dart';
import 'package:eatvio_app/features/glossary/repositories/glossary_repository.dart';
import 'package:eatvio_app/features/profile/repositories/profile_repository.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/annotations.dart';
import 'basic_widget_test.mocks.dart';
import '../../fixtures/doubles/create_plan_doubles.dart';
import '../../fixtures/fixture_reader.dart';
@GenerateMocks([CreatePlanRepository, ProfileRepository, GlossaryRepository])
void main() {
group('Meal Plan Creation Basic Widget Tests', () {
late MockCreatePlanRepository mockCreatePlanRepository;
late FixtureCreatePlanRepository createPlanRepository;
late CreatePlanCubit createPlanCubit;
late Map<String, dynamic> planFixture;
setUp(() {
mockCreatePlanRepository = MockCreatePlanRepository();
createPlanCubit = CreatePlanCubit(createPlanRepository: mockCreatePlanRepository);
planFixture = FixtureReader.readAsMap('create_plan/create_plan_request.json');
createPlanRepository = FixtureCreatePlanRepository();
createPlanCubit = CreatePlanCubit(createPlanRepository: createPlanRepository);
});
tearDown(() {
@@ -37,7 +35,7 @@ void main() {
testWidgets('should create CreatePlanCubit successfully', (WidgetTester tester) async {
// Arrange & Act
final cubit = CreatePlanCubit(createPlanRepository: mockCreatePlanRepository);
final cubit = CreatePlanCubit(createPlanRepository: createPlanRepository);
// Assert
expect(cubit, isA<CreatePlanCubit>());
@@ -98,7 +96,7 @@ void main() {
await tester.pumpWidget(createTestWidget(formWidget));
await tester.pumpAndSettle();
const testName = 'Тестовый план питания';
final testName = planFixture['name'] as String;
// Act
await tester.enterText(find.byKey(const Key('planNameField')), testName);
@@ -119,7 +117,7 @@ void main() {
await tester.pumpWidget(createTestWidget(formWidget));
await tester.pumpAndSettle();
const testDescription = 'Это тестовое описание плана питания для здорового образа жизни';
final testDescription = planFixture['description'] as String;
// Act
await tester.enterText(find.byKey(const Key('planDescriptionField')), testDescription);