forked from eatvio/eatvio_app
fix: issue-372, issue-227, issue-406
This commit is contained in:
@@ -6,8 +6,10 @@ import 'package:eatvio_app/core/widgets/custom_outlined_button.dart';
|
||||
import 'package:eatvio_app/features/order_info/presentation/widgets/collect_charge_banner.dart';
|
||||
import 'package:eatvio_app/features/plans/enums/chosen_plan_state_enum.dart';
|
||||
import 'package:eatvio_app/features/plans/models/chosen_plan_model.dart';
|
||||
import 'package:eatvio_app/features/feed/models/plan_pagination_model.dart' show PlanModel, PlanType;
|
||||
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart' show Author;
|
||||
import 'package:eatvio_app/features/feed/models/plan_pagination_model.dart'
|
||||
show PlanModel, PlanType;
|
||||
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'
|
||||
show Author;
|
||||
import 'package:eatvio_app/generated/l10n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
@@ -20,8 +22,14 @@ void main() {
|
||||
group('CollectChargeBanner', () {
|
||||
setUp(() async {
|
||||
await sl.reset();
|
||||
dotenv.loadFromString(envString: 'DEV_BASE_URL=http://localhost\nBASE_URL=http://localhost');
|
||||
sl.registerLazySingleton<AppConfig>(() => AppConfig(buildType: AppBuildType.tests)..setBaseUrl('http://localhost'));
|
||||
dotenv.loadFromString(
|
||||
envString: 'DEV_BASE_URL=http://localhost\nBASE_URL=http://localhost',
|
||||
);
|
||||
sl.registerLazySingleton<AppConfig>(
|
||||
() =>
|
||||
AppConfig(buildType: AppBuildType.tests)
|
||||
..setBaseUrl('http://localhost'),
|
||||
);
|
||||
});
|
||||
|
||||
Widget createTestWidget(Widget child) {
|
||||
@@ -42,12 +50,76 @@ void main() {
|
||||
child: Scaffold(body: SingleChildScrollView(child: child)),
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/card-settings-screen',
|
||||
builder: (context, state) =>
|
||||
Scaffold(body: Text('chosenPlanId:${state.extra}')),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('should display collect charge banner with plan name and price', (WidgetTester tester) async {
|
||||
testWidgets(
|
||||
'should display collect charge banner with plan name and price',
|
||||
(WidgetTester tester) async {
|
||||
// Arrange
|
||||
final chosenPlan = ChosenPlanModel(
|
||||
id: 1,
|
||||
optionType: 'standard',
|
||||
startDate: DateTime.now(),
|
||||
chosenPlanState: ChosenPlanStateEnum.stateDone,
|
||||
chatId: 'chat-1',
|
||||
consultantId: 1,
|
||||
plan: const PlanModel(
|
||||
id: 1,
|
||||
slug: 'test-plan',
|
||||
name: 'Test Plan',
|
||||
image: 'test.jpg',
|
||||
duration: 30,
|
||||
state: 'active',
|
||||
type: PlanType(
|
||||
fit: true,
|
||||
slim: false,
|
||||
behavior: false,
|
||||
wellness: false,
|
||||
),
|
||||
details: 'Test details',
|
||||
packetsCount: 1,
|
||||
author: Author(
|
||||
authorSlug: '',
|
||||
authorName: '',
|
||||
authorProfileIcon: '',
|
||||
authorIsMe: false,
|
||||
),
|
||||
totalLikes: 0,
|
||||
totalViews: 0,
|
||||
totalComments: 0,
|
||||
isFavorite: false,
|
||||
minPriceOfOptions: 100.0,
|
||||
maxPriceOfOptions: 500.0,
|
||||
wasLikedByMe: false,
|
||||
),
|
||||
);
|
||||
const price = 1000.0;
|
||||
final widget = CollectChargeBanner(
|
||||
chosenPlan: chosenPlan,
|
||||
price: price,
|
||||
);
|
||||
|
||||
// Act
|
||||
await tester.pumpWidget(createTestWidget(widget));
|
||||
await tester.pump();
|
||||
|
||||
// Assert
|
||||
expect(find.byType(CollectChargeBanner), findsOneWidget);
|
||||
expect(find.byType(CustomOutlinedButton), findsOneWidget);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('should have button that navigates to card settings', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
// Arrange
|
||||
final chosenPlan = ChosenPlanModel(
|
||||
id: 1,
|
||||
@@ -63,10 +135,20 @@ void main() {
|
||||
image: 'test.jpg',
|
||||
duration: 30,
|
||||
state: 'active',
|
||||
type: PlanType(fit: true, slim: false, behavior: false, wellness: false),
|
||||
type: PlanType(
|
||||
fit: true,
|
||||
slim: false,
|
||||
behavior: false,
|
||||
wellness: false,
|
||||
),
|
||||
details: 'Test details',
|
||||
packetsCount: 1,
|
||||
author: Author(authorSlug: '', authorName: '', authorProfileIcon: '', authorIsMe: false),
|
||||
author: Author(
|
||||
authorSlug: '',
|
||||
authorName: '',
|
||||
authorProfileIcon: '',
|
||||
authorIsMe: false,
|
||||
),
|
||||
totalLikes: 0,
|
||||
totalViews: 0,
|
||||
totalComments: 0,
|
||||
@@ -83,50 +165,10 @@ void main() {
|
||||
await tester.pumpWidget(createTestWidget(widget));
|
||||
await tester.pump();
|
||||
|
||||
// Assert
|
||||
expect(find.byType(CollectChargeBanner), findsOneWidget);
|
||||
expect(find.byType(CustomOutlinedButton), findsOneWidget);
|
||||
});
|
||||
await tester.tap(find.byType(CustomOutlinedButton));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
testWidgets('should have button that navigates to card settings', (WidgetTester tester) async {
|
||||
// Arrange
|
||||
final chosenPlan = ChosenPlanModel(
|
||||
id: 1,
|
||||
optionType: 'standard',
|
||||
startDate: DateTime.now(),
|
||||
chosenPlanState: ChosenPlanStateEnum.stateDone,
|
||||
chatId: 'chat-1',
|
||||
consultantId: 1,
|
||||
plan: const PlanModel(
|
||||
id: 1,
|
||||
slug: 'test-plan',
|
||||
name: 'Test Plan',
|
||||
image: 'test.jpg',
|
||||
duration: 30,
|
||||
state: 'active',
|
||||
type: PlanType(fit: true, slim: false, behavior: false, wellness: false),
|
||||
details: 'Test details',
|
||||
packetsCount: 1,
|
||||
author: Author(authorSlug: '', authorName: '', authorProfileIcon: '', authorIsMe: false),
|
||||
totalLikes: 0,
|
||||
totalViews: 0,
|
||||
totalComments: 0,
|
||||
isFavorite: false,
|
||||
minPriceOfOptions: 100.0,
|
||||
maxPriceOfOptions: 500.0,
|
||||
wasLikedByMe: false,
|
||||
),
|
||||
);
|
||||
const price = 1000.0;
|
||||
final widget = CollectChargeBanner(chosenPlan: chosenPlan, price: price);
|
||||
|
||||
// Act
|
||||
await tester.pumpWidget(createTestWidget(widget));
|
||||
await tester.pump();
|
||||
|
||||
// Assert - проверяем, что кнопка существует
|
||||
expect(find.byType(CustomOutlinedButton), findsOneWidget);
|
||||
expect(find.text('chosenPlanId:1'), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user