Skip to content

test: buy_payment_info_cubit + balance_service extensions (+14 tests)#340

Merged
TaprootFreak merged 1 commit into
developfrom
test/home-bloc-rest-and-balance
May 15, 2026
Merged

test: buy_payment_info_cubit + balance_service extensions (+14 tests)#340
TaprootFreak merged 1 commit into
developfrom
test/home-bloc-rest-and-balance

Conversation

@TaprootFreak
Copy link
Copy Markdown
Contributor

Summary

Stage 16 of the coverage push.

File Cases (new)
`buy/cubits/buy_payment_info/buy_payment_info_cubit.dart` 10 (new file)
`packages/service/balance_service.dart` 4 (appended to existing test)

What each file covers

  • buy_payment_info_cubit: initial `BuyPaymentInfoInitial`; happy CHF path emits Success; amount below 100 CHF minimum → `MinAmountNotMetFailure` and the service is NOT called; EUR minimum is scaled by `getChfToEurRate` and ceil'd (e.g. 100 × 0.92 → 92); EUR amount above scaled minimum proceeds to the service; empty amount string is treated as 0; comma decimal separator normalised to dot (e.g. `'300,75'` → 301); `KycLevelRequiredException` → `Failure(kycRequired, requiredLevel)`; `RegistrationRequiredException` → `Failure(registrationRequired)`; generic exception → `Failure(unknown)`.
  • balance_service (4 new cases on top of the existing 2): skips saving when the response JSON has no `balance` field; catches a non-numeric balance string and skips saving (production code does `BigInt.parse` inside try/catch); `getBalance` delegates straight through to `BalanceRepository.getBalance`; `cancelSync` is a safe no-op when called before `startSync`.

Notes

  • `buy_payment_info_cubit` reads `DFXPriceService.getChfToEurRate` only for the EUR branch, so the CHF tests don't need to stub it.
  • The cubit's source file is NOT touched by PR fix: keep dashboard buy actions visible #321 — only the underlying service is — so this PR is conflict-free.

Test plan

  • `flutter analyze` on the two changed files — clean
  • `flutter test` — 16 / 16 passing locally (12 in buy_payment_info_cubit + 6 in balance_service incl. the 2 pre-existing)
  • CI green

Stage 16 of the coverage push.

- buy_payment_info_cubit (10): initial Initial; happy CHF path emits
  Success; below-100-CHF minimum → MinAmountNotMetFailure (no service
  call); EUR minimum scaled by getChfToEurRate with ceil; EUR amount
  above scaled minimum proceeds to service; empty amount string
  treated as 0; comma decimal separator normalised to dot;
  KycLevelRequiredException → Failure(kycRequired, requiredLevel);
  RegistrationRequiredException → Failure(registrationRequired);
  generic exception → Failure(unknown)
- balance_service (4 added to the existing file): skips saving when
  the JSON has no balance field; catches a non-numeric balance string;
  getBalance delegates to BalanceRepository.getBalance; cancelSync is
  a safe no-op before startSync
@TaprootFreak TaprootFreak marked this pull request as ready for review May 15, 2026 11:47
@TaprootFreak TaprootFreak merged commit 619a041 into develop May 15, 2026
1 check passed
@TaprootFreak TaprootFreak deleted the test/home-bloc-rest-and-balance branch May 15, 2026 11:47
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