Skip to content

test(kyc): KycFinancialDataCubit + LoadedSuccess helpers (+17 tests)#367

Merged
TaprootFreak merged 1 commit into
developfrom
test/kyc-financial-data-cubit
May 15, 2026
Merged

test(kyc): KycFinancialDataCubit + LoadedSuccess helpers (+17 tests)#367
TaprootFreak merged 1 commit into
developfrom
test/kyc-financial-data-cubit

Conversation

@TaprootFreak
Copy link
Copy Markdown
Contributor

Summary

Stage 43 of the coverage push. Cubit-level coverage of the KYC financial-data step: question loading, conditional visibility, answer routing, navigation, submission and the `LoadedSuccess` view-model helpers.

Cases

Target Cases
initial state 1 — `KycFinancialDataInitial`
`loadQuestions` 3 — Loading → LoadedSuccess; conditional questions filtered when their condition is unmet; Loading → Failure on service error
`answerQuestion` 2 — no-op outside LoadedSuccess; stores the answer and re-runs the visibility filter (conditional questions appear once their predicate matches)
`submitAndNext` 4 — non-last increments `currentIndex`; last emits Submitting → SubmitSuccess and calls `setFinancialData`; submit error surfaces a Failure; no-op outside LoadedSuccess
`goBack` 3 — decrements `currentIndex` from 1; no emit at index 0; no-op outside LoadedSuccess
`KycFinancialDataLoadedSuccess` helpers 4 — `currentQuestion` at index; `isFirstQuestion` / `isLastQuestion`; `currentResponse` + `hasAnswer` reflect the responses map; `hasAnswer` is false on an empty string response

What's pinned

  • Conditional-question visibility is dynamic: `answerQuestion` re-runs the filter so a previously hidden question becomes visible the moment its condition is satisfied. Pinned by a live-flip test on `q3` (visible only when `q1 == 'a'`).
  • `submitAndNext` only calls `setFinancialData` once the user is on the last visible question — the non-last branch must never reach the service.
  • `goBack` at index 0 must not emit (same state instance pinned with `same`), so the UI doesn't show a spurious rebuild when the user taps Back too hard.
  • `hasAnswer` treats an empty string as no answer — pins the contract used by the "Next" button's disabled state.

Test plan

  • `flutter test test/screens/kyc/steps/financial_data/kyc_financial_data_cubit_test.dart` — 17 pass
  • `flutter analyze` clean on the new file
  • CI green

Stage 43 of the coverage push. Cubit-level coverage of the
KYC financial-data step (questions / answers / submit).

- initial state (1): KycFinancialDataInitial
- loadQuestions (3): Loading → LoadedSuccess; conditional
  questions filtered when their condition is unmet; Loading →
  Failure on service error
- answerQuestion (2): no-op outside LoadedSuccess; stores the
  answer and re-runs the visibility filter (conditional questions
  appear once their predicate matches)
- submitAndNext (4): non-last increments currentIndex; last
  emits Submitting → SubmitSuccess and calls setFinancialData;
  submit error surfaces a Failure; no-op outside LoadedSuccess
- goBack (3): decrements currentIndex from 1; no emit at index 0;
  no-op outside LoadedSuccess
- KycFinancialDataLoadedSuccess helpers (4): currentQuestion at
  index; isFirstQuestion / isLastQuestion; currentResponse +
  hasAnswer reflect the responses map; hasAnswer is false on an
  empty string response
@TaprootFreak TaprootFreak marked this pull request as ready for review May 15, 2026 19:07
@TaprootFreak TaprootFreak merged commit 7c0c450 into develop May 15, 2026
1 check passed
@TaprootFreak TaprootFreak deleted the test/kyc-financial-data-cubit branch May 15, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant