fix: align diary diet row and hide terminal cancel

- show only the personal diet name in the diary and keep the plan day chip
- hide consultation cancellation for terminal and non-cancellable states
- enable the refund form only for paid, started and in-progress plans
- cover diary rows and order info cancel visibility with tests
This commit is contained in:
2026-11-06 13:33:44 +03:00
parent 57536aba06
commit 0241265b3c
7 changed files with 105 additions and 29 deletions

View File

@@ -27,9 +27,7 @@ void main() {
await tester.pumpWidget(
createTestWidget(
const ChosenDietWidgetContent(
currentDietDay: 5,
dietName: 'Test Diet',
dietDuration: 14,
dietId: 1,
),
),
@@ -38,15 +36,14 @@ void main() {
expect(find.byType(ChosenDietWidgetContent), findsOneWidget);
expect(find.text('Test Diet'), findsOneWidget);
expect(find.textContaining('из 14'), findsNothing);
});
testWidgets('displays current day and duration', (tester) async {
testWidgets('does not display current day and duration', (tester) async {
await tester.pumpWidget(
createTestWidget(
const ChosenDietWidgetContent(
currentDietDay: 7,
dietName: 'Test Diet',
dietDuration: 21,
dietId: 1,
),
),
@@ -54,15 +51,14 @@ void main() {
await tester.pumpAndSettle();
expect(find.byType(ChosenDietWidgetContent), findsOneWidget);
expect(find.textContaining('из 21'), findsNothing);
});
testWidgets('displays diet name with underline', (tester) async {
await tester.pumpWidget(
createTestWidget(
const ChosenDietWidgetContent(
currentDietDay: 1,
dietName: 'My Diet',
dietDuration: 7,
dietId: 1,
),
),
@@ -70,6 +66,7 @@ void main() {
await tester.pumpAndSettle();
expect(find.text('My Diet'), findsOneWidget);
expect(find.textContaining('из 7'), findsNothing);
});
});
}

View File

@@ -100,6 +100,17 @@ void main() {
await tester.pumpWidget(wrap(const ChosenDietWidget(), cubit));
await tester.pump();
expect(find.text('Diet'), findsOneWidget);
expect(find.textContaining('из 7'), findsNothing);
});
testWidgets('ChosenDietWidget hides diet day while plan keeps its day', (tester) async {
final cubit = FakeDiaryCubit(loadedState(hasDiet: true, hasPlan: true));
await tester.pumpWidget(wrap(const Column(children: [ChosenPlanWidget(), ChosenDietWidget()]), cubit));
await tester.pump();
expect(find.text('Plan'), findsOneWidget);
expect(find.textContaining('из 30'), findsOneWidget);
expect(find.text('Diet'), findsOneWidget);
expect(find.textContaining('из 7'), findsNothing);
});
testWidgets('AddProductButtonWidget renders for loaded state', (tester) async {