Skip to content

test: buy + sell cubit subset, no PR-conflict overlap (+22 tests)#337

Merged
TaprootFreak merged 1 commit into
developfrom
test/buy-sell-cubits
May 15, 2026
Merged

test: buy + sell cubit subset, no PR-conflict overlap (+22 tests)#337
TaprootFreak merged 1 commit into
developfrom
test/buy-sell-cubits

Conversation

@TaprootFreak
Copy link
Copy Markdown
Contributor

Summary

Stage 13 of the coverage push. Covers four cubits in the sell and buy flows whose source files are NOT touched by the currently-open #321 (dashboard buy actions, sell_page) or #332 (bitbox sign).

Cubit under test Test file Cases
`sell/cubits/sell_selected_bank_account/sell_selected_bank_account_cubit.dart` `test/screens/sell/cubits/sell_selected_bank_account_cubit_test.dart` 3
`sell/cubits/sell_balance/sell_balance_cubit.dart` `test/screens/sell/cubits/sell_balance_cubit_test.dart` 4
`sell/cubits/sell_bank_accounts/sell_bank_accounts_cubit.dart` `test/screens/sell/cubits/sell_bank_accounts_cubit_test.dart` 6
`buy/cubits/buy_converter/buy_converter_cubit.dart` `test/screens/buy/cubits/buy_converter_cubit_test.dart` 9

What each file covers

  • sell_selected_bank_account_cubit: initial null, `selectBankAccount` emits the provided account, `selectBankAccount(null)` clears the selection.
  • sell_balance_cubit: initial zero-balance derived from `AppStore.apiConfig.asset` + `primaryAddress`; subscribes to `BalanceRepository.watchBalance` on init; emits each pushed balance; `close()` cancels the subscription.
  • sell_bank_accounts_cubit: Success with DTO → BankAccount mapping on init; LoadFailure on `getBankAccounts` throw; `add()` calls `createBankAccount` + re-fetches; `AddFailure` preserves prior accounts + carries error message; `deactivate()` calls `updateBankAccount(isActive=false)` + re-fetches; `UpdateFailure` preserves prior accounts.
  • buy_converter_cubit: initial empty state; `onFiatChanged` debounces (100ms) and writes the converted shares; multiple rapid keystrokes only fire the LAST service call (pins the debounce contract); service error keeps state stable; `onSharesChanged` matches the output's fractional digits to the input (`'5'` → 2 digits, `'5.000'` → 3 digits — pins `_fractionDigits` behaviour); `onCurrencyChanged` re-fetches in the new currency and emits both fields; currency still flips on service error; `close()` cancels pending debounce timers so no service call happens after close.

Excluded (and why)

  • `sell_payment_info`, `sell_confirm`, `sell_converter` (the parallel cubit to buy_converter), `buy_confirm`, `buy_payment_info` — each pulls in `real_unit_buy_payment_info_service` / `real_unit_sell_payment_info_service` / signing flows that are likely on PR fix: keep dashboard buy actions visible #321's path. Held back to avoid review conflicts.
  • `sell_bitbox_cubit`, `hardware_connect_bitbox_cubit` — both directly touch BitBox; held while fix(bitbox): harden multi-page sign and KYC routing #332 is open.

Test plan

  • `flutter analyze` on the four new files — clean
  • `flutter test` — 22 / 22 passing locally
  • CI green

Stage 13 of the coverage push.

- sell_selected_bank_account_cubit (3): initial null, select emits
  the account, select(null) clears
- sell_balance_cubit (4): initial zero balance derived from AppStore,
  subscribes to BalanceRepository.watchBalance on init, emits each
  pushed balance, close() cancels cleanly
- sell_bank_accounts_cubit (6): Success with mapped DTOs on init,
  LoadFailure on getBankAccounts throw, add() calls createBankAccount
  + refetches, AddFailure preserves prior accounts, deactivate()
  calls updateBankAccount(isActive=false) + refetches, UpdateFailure
  preserves prior accounts
- buy_converter_cubit (9): initial empty state, onFiatChanged
  debounces + writes converted shares, debounce keeps only the last
  value, error path leaves state stable, onSharesChanged matches
  output fractional digits to the input (and defaults to 2 without
  dot), onCurrencyChanged refetches in the new currency, currency
  still flips on service error, close() cancels pending debounce
  timers (no service call after close)
@TaprootFreak TaprootFreak marked this pull request as ready for review May 15, 2026 11:47
@TaprootFreak TaprootFreak merged commit 059244f into develop May 15, 2026
1 check passed
@TaprootFreak TaprootFreak deleted the test/buy-sell-cubits 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