forked from eatvio/eatvio_app
feat(tests): menu, settings, remove icov, remove generated files from % tests
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/features/create_plan/presentation/cubit/create_plan_cubit.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_image_compress/flutter_image_compress.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../../fixtures/doubles/create_plan_doubles.dart';
|
||||
@@ -585,44 +582,5 @@ void main() {
|
||||
expect(find.byKey(const Key('premiumOptionContainer')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should send correct request when creating plan', (WidgetTester tester) async {
|
||||
// Arrange
|
||||
final tempFile = File('${Directory.systemTemp.path}/test_image.jpg');
|
||||
await tempFile.writeAsBytes([0, 1, 2, 3]);
|
||||
final xFile = XFile(tempFile.path);
|
||||
|
||||
createPlanCubit.setName(planFixture['name'] as String);
|
||||
createPlanCubit.setDetails(planFixture['description'] as String);
|
||||
createPlanCubit.setDuration(0); // 7 days
|
||||
createPlanCubit.setPlanState(planFixture['status'] as String);
|
||||
createPlanCubit.setImage(xFile);
|
||||
createPlanCubit.setPlanType([true, false, false, false]); // At least one type must be selected
|
||||
|
||||
// Set at least one option (required for validation)
|
||||
final options = planFixture['options'] as List<dynamic>;
|
||||
if (options.isNotEmpty) {
|
||||
final firstOption = options[0] as Map<String, dynamic>;
|
||||
createPlanCubit.setOptionTitle(firstOption['title'] as String);
|
||||
createPlanCubit.setPrice((firstOption['price'] as num).toDouble());
|
||||
createPlanCubit.setOptionDescription(firstOption['description'] as String);
|
||||
}
|
||||
|
||||
// Act
|
||||
await createPlanCubit.publishPlan();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Assert
|
||||
expect(createPlanRepository.createPlanRequests.length, 1);
|
||||
final request = createPlanRepository.createPlanRequests.single;
|
||||
expect(request['name'], planFixture['name']);
|
||||
expect(request['description'], planFixture['description']);
|
||||
expect(request['duration'], planFixture['duration']);
|
||||
expect(request['status'], planFixture['status']);
|
||||
|
||||
// Cleanup
|
||||
if (await tempFile.exists()) {
|
||||
await tempFile.delete();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user