test(wallets): wait for async ongoing balance refresh#359
Closed
mariohd wants to merge 1 commit into
Closed
Conversation
## Context Six wallet integration tests (`#update`, `#get`, `#get_all` on both `spec/integration/wallets_spec.rb` and `spec/integration/customers/ wallets_spec.rb`) intermittently fail in CI with `expected: "10.0", got: "0.0"` on `credits_ongoing_balance`. `balance_cents` is synced synchronously when the wallet transaction settles, but `ongoing_balance_cents` / `credits_ongoing_balance` are refreshed by an async job (RefreshWalletJob). The existing `wait_for_balance_update` only polls until `balance_cents == 2000`, so the assertion can run before the ongoing refresh has landed and the wallet still reports `0.0`. ## Description Re-fetches the wallet inside `assert_wallet_attributes_with_updated_ balance` and waits until `ongoing_balance_cents` matches the expected value before asserting. The expected value is read from the optional `ongoing_balance_cents` override (default 2000), so tests that override it continue to drive the wait correctly.
Contributor
Author
|
Closed in favor of #357 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Six wallet integration tests (
#update,#get,#get_allon bothspec/integration/wallets_spec.rbandspec/integration/customers/wallets_spec.rb) fail in CI withexpected: "10.0", got: "0.0"oncredits_ongoing_balance.balance_centsis updated synchronously when the wallet transaction settles, butongoing_balance_cents/credits_ongoing_balanceare refreshed by an asyncRefreshWalletJob. The existingwait_for_balance_updateonly polls untilbalance_cents == 2000, so the assertions can run before the ongoing refresh has landed and the wallet still reports0.0for the ongoing fields.Fix
Adds a second wait inside
assert_wallet_attributes_with_updated_balancethat re-fetches the wallet untilongoing_balance_centsmatches the expected value before asserting. The expected value is read from the optionalongoing_balance_centsoverride (default2000), so tests that pass a custom override continue to drive the wait correctly.Same shape applied to both the top-level (
wallets_spec.rb) and customer-scoped (customers/wallets_spec.rb) helpers.Tests
All ten previously-failing examples pass; no regressions in the surrounding suites. The
#destroyflake that occasionally surfaces when the two files run back-to-back is unrelated (HTTP 409 from leftover Lago state), passes in isolation, and was already green before this branch.