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

@@ -61,6 +61,47 @@ void main() {
expect(ChosenPlanStateEnum.stateConfirmedByConsultant.isStateAfterPaidState(), isTrue);
});
test('canShowCancelAction returns true for cancellable states', () {
expect(ChosenPlanStateEnum.stateInited.canShowCancelAction, isTrue);
expect(ChosenPlanStateEnum.stateInCoordination.canShowCancelAction, isTrue);
expect(ChosenPlanStateEnum.stateStartDateHasBeenSet.canShowCancelAction, isTrue);
expect(ChosenPlanStateEnum.statePendingPayment.canShowCancelAction, isTrue);
expect(ChosenPlanStateEnum.statePaid.canShowCancelAction, isTrue);
expect(ChosenPlanStateEnum.stateStarted.canShowCancelAction, isTrue);
expect(ChosenPlanStateEnum.stateInProgress.canShowCancelAction, isTrue);
});
test('canShowCancelAction returns false for non-cancellable states', () {
expect(ChosenPlanStateEnum.personalDietSet.canShowCancelAction, isFalse);
expect(ChosenPlanStateEnum.stateLastDayStarted.canShowCancelAction, isFalse);
expect(ChosenPlanStateEnum.stateLastDayFinished.canShowCancelAction, isFalse);
expect(ChosenPlanStateEnum.stateComplained.canShowCancelAction, isFalse);
expect(ChosenPlanStateEnum.stateDone.canShowCancelAction, isFalse);
expect(ChosenPlanStateEnum.stateChargeWasCollected.canShowCancelAction, isFalse);
expect(ChosenPlanStateEnum.stateCanceledByTheInitiator.canShowCancelAction, isFalse);
expect(ChosenPlanStateEnum.statePaymentFailed.canShowCancelAction, isFalse);
expect(ChosenPlanStateEnum.stateConfirmedByConsultant.canShowCancelAction, isFalse);
});
test('isCancelAfterPaidState returns true only for post-paid cancellable states', () {
expect(ChosenPlanStateEnum.statePaid.isCancelAfterPaidState, isTrue);
expect(ChosenPlanStateEnum.stateStarted.isCancelAfterPaidState, isTrue);
expect(ChosenPlanStateEnum.stateInProgress.isCancelAfterPaidState, isTrue);
expect(ChosenPlanStateEnum.stateInited.isCancelAfterPaidState, isFalse);
expect(ChosenPlanStateEnum.stateInCoordination.isCancelAfterPaidState, isFalse);
expect(ChosenPlanStateEnum.stateStartDateHasBeenSet.isCancelAfterPaidState, isFalse);
expect(ChosenPlanStateEnum.statePendingPayment.isCancelAfterPaidState, isFalse);
expect(ChosenPlanStateEnum.statePaymentFailed.isCancelAfterPaidState, isFalse);
expect(ChosenPlanStateEnum.stateConfirmedByConsultant.isCancelAfterPaidState, isFalse);
expect(ChosenPlanStateEnum.personalDietSet.isCancelAfterPaidState, isFalse);
expect(ChosenPlanStateEnum.stateLastDayStarted.isCancelAfterPaidState, isFalse);
expect(ChosenPlanStateEnum.stateLastDayFinished.isCancelAfterPaidState, isFalse);
expect(ChosenPlanStateEnum.stateComplained.isCancelAfterPaidState, isFalse);
expect(ChosenPlanStateEnum.stateDone.isCancelAfterPaidState, isFalse);
expect(ChosenPlanStateEnum.stateChargeWasCollected.isCancelAfterPaidState, isFalse);
expect(ChosenPlanStateEnum.stateCanceledByTheInitiator.isCancelAfterPaidState, isFalse);
});
test('getActiveStates returns correct states', () {
final activeStates = ChosenPlanStateEnum.getActiveStates();