fix: issue-372, issue-227, issue-406

This commit is contained in:
misha
2026-09-02 09:32:14 +03:00
parent 10af279d87
commit c6ea1d414d
34 changed files with 1623 additions and 387 deletions

View File

@@ -16,12 +16,18 @@ import 'package:network_image_mock/network_image_mock.dart';
void main() {
group('ConsultationCardWidget smoke', () {
setUpAll(() async {
dotenv.loadFromString(envString: 'DEV_BASE_URL=http://localhost\nBASE_URL=http://localhost');
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'));
sl.registerLazySingleton<AppConfig>(
() =>
AppConfig(buildType: AppBuildType.tests)
..setBaseUrl('http://localhost'),
);
});
final mockConsultation = ConsultationModel(
@@ -39,9 +45,21 @@ void main() {
endDate: DateTime(2025, 1, 8),
consultantId: 1,
diaries: [
DiaryModel(id: 1, state: DiaryStateEnum.finished, date: DateTime(2025, 1, 1)),
DiaryModel(id: 2, state: DiaryStateEnum.commented, date: DateTime(2025, 1, 2)),
DiaryModel(id: 3, state: DiaryStateEnum.init, date: DateTime(2025, 1, 3)),
DiaryModel(
id: 1,
state: DiaryStateEnum.finished,
date: DateTime(2025, 1, 1),
),
DiaryModel(
id: 2,
state: DiaryStateEnum.commented,
date: DateTime(2025, 1, 2),
),
DiaryModel(
id: 3,
state: DiaryStateEnum.init,
date: DateTime(2025, 1, 3),
),
],
personalDietId: null,
);
@@ -63,18 +81,25 @@ void main() {
GoRoute(
path: '/profile-screen',
name: 'profileScreen',
builder: (context, state) => const Scaffold(body: Text('Profile')),
builder: (context, state) =>
const Scaffold(body: Text('Profile')),
),
GoRoute(
path: '/user-details-screen',
name: 'userDetailsScreen',
builder: (context, state) => const Scaffold(body: Text('User Details')),
builder: (context, state) =>
const Scaffold(body: Text('User Details')),
),
GoRoute(
path: '/diary-screen',
name: 'diaryScreen',
builder: (context, state) => const Scaffold(body: Text('Diary')),
),
GoRoute(
path: '/card-settings-screen',
builder: (context, state) =>
Scaffold(body: Text('chosenPlanId:${state.extra}')),
),
],
),
);
@@ -82,7 +107,9 @@ void main() {
testWidgets('renders consultation card with user info', (tester) async {
await mockNetworkImagesFor(() async {
await tester.pumpWidget(wrap(ConsultationCardWidget(consultationsModel: mockConsultation)));
await tester.pumpWidget(
wrap(ConsultationCardWidget(consultationsModel: mockConsultation)),
);
await tester.pumpAndSettle();
expect(find.text('John Doe'), findsOneWidget);
@@ -92,12 +119,49 @@ void main() {
testWidgets('renders diary days', (tester) async {
await mockNetworkImagesFor(() async {
await tester.pumpWidget(wrap(ConsultationCardWidget(consultationsModel: mockConsultation)));
await tester.pumpWidget(
wrap(ConsultationCardWidget(consultationsModel: mockConsultation)),
);
await tester.pumpAndSettle();
expect(find.byType(InkWell), findsWidgets);
});
});
testWidgets('hides collect charge when consultation is in progress', (
tester,
) async {
await mockNetworkImagesFor(() async {
await tester.pumpWidget(
wrap(ConsultationCardWidget(consultationsModel: mockConsultation)),
);
await tester.pumpAndSettle();
expect(find.text('Получить выплату'), findsNothing);
});
});
testWidgets(
'shows collect charge and opens card settings with chosen plan id when done',
(tester) async {
final doneConsultation = mockConsultation.copyWith(
chosenPlanState: ChosenPlanStateEnum.stateDone,
);
await mockNetworkImagesFor(() async {
await tester.pumpWidget(
wrap(ConsultationCardWidget(consultationsModel: doneConsultation)),
);
await tester.pumpAndSettle();
expect(find.text('Получить выплату'), findsOneWidget);
await tester.tap(find.text('Получить выплату'));
await tester.pumpAndSettle();
expect(find.text('chosenPlanId:1'), findsOneWidget);
});
},
);
});
}