fix(withdrawal): surface backend failures instead of returning mock data - #682
Open
woahwhattheheck wants to merge 7 commits into
Conversation
Use vi.spyOn(axios, 'get') so the mock is registered without an unbound method reference; fixes the @typescript-eslint/unbound-method error from the typechecked lint config.
Extend the vitest suite to assert rejection propagation for initiateWithdrawal, getTransactionStatus and cancelWithdrawal as well, matching the issue's error-path coverage criterion.
Keep the status-propagation assertion under the 100-character print width so the format check passes.
Rewrite the test file with LF line endings so the prettier --check step passes.
The existing error-propagating service reaches useWithdrawal, but WithdrawalFlow then reads its pre-await render state and calls onSuccess even after a validation or request failure. Return an explicit boolean from initiation and notify the caller only on success. Preserve current errors, form/processing states, polling and the existing successful-initiation account-refresh timing; this does not claim settlement. This source residual was identified in Lantern's earlier PayD457 intake and remains present on the existing PR682 carrier. Only the hook and component change; backend/service and prior contributor work stay intact. Static source inspection of service, hook, component and actual EmployeePortal callback only. No tests, fixtures, build, browser, wallet/backend or runtime execution was performed. The prior fork CI receipt remains historical on c6f73d8; native validation and maintainer acceptance of this continuation are pending.
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.
Closes #457.
What
Removes the blanket
catch-and-mock-fallback behavior from all four methods infrontend/src/services/withdrawal.ts(getAvailableAnchors,initiateWithdrawal,getTransactionStatus,cancelWithdrawal). Real axios errors now propagate to the caller, so the existinguseWithdrawalhook surfaces them through itserrorstate andfailedstep instead of displaying fabricated anchors/transaction data.Tests
Adds
frontend/src/services/__tests__/withdrawal.test.tscovering rejection propagation for each of the four methods — a simulated network/500 failure reaches the caller rather than producing a fake success.Validation
Fork CI
Build Project and Run Tests(eslint typechecked rules, prettier, unit tests) passes on the head commit. The Playwright sidebar-navigation spec (getByRole('link', { name: 'Employees' })strict-mode violation) fails onmainindependently of this change.