fix(ramps): normalize provider IDs in BuildQuote quote matching [TRAM-3331]#28337
Conversation
The UB2 BuildQuote screen compared quote.provider with selectedProvider.id using strict equality. When the API returned prefixed IDs (e.g. /providers/transak) the match failed, causing a brief error flash. Use normalizeProviderCode on both sides and .find() instead of array destructuring so all returned quotes are searched.
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
…x-token-error-flash
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 25ca6bb. Configure here.
…x-token-error-flash
isAutoSelecting only checked !selectedPaymentMethod (null), missing the case where the selected method is stale (no longer in the refreshed list). This allowed the stale name to flash before the useEffect corrected it. Now also checks that the current selection exists in the fetched list, keeping isLoading true until the fallback completes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace toBeTruthy/toBeNull with toBeOnTheScreen/not.toBeOnTheScreen per unit testing guidelines. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| !paymentMethodsQuery.data.some( | ||
| (m) => m.id === selectedPaymentMethod.id, |
There was a problem hiding this comment.
nit: for clarity
| !paymentMethodsQuery.data.some( | |
| (m) => m.id === selectedPaymentMethod.id, | |
| paymentMethodsQuery.data.every( | |
| (m) => m.id !== selectedPaymentMethod.id, |
There was a problem hiding this comment.
I'll add it now
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
These are targeted bug fixes in the Ramps feature's BuildQuote flow and payment method selection. The changes are self-contained within Performance Test Selection: |
|
|
✅ E2E Fixture Validation — Schema is up to date |




Description
When selecting a token in the UB2 Buy flow, a quick error ("We've encountered an error") flashes on the amount input screen before the correct "Powered by [provider]" text appears.
The root cause is a provider ID mismatch: the quotes API can return provider IDs in a prefixed format (
/providers/transak) while the controller state stores them without the prefix (transak). This causedselectedQuoteto resolve tonull, briefly rendering the error banner.The fix normalizes provider IDs on both sides of the comparison using
normalizeProviderCode()and switches from array destructuring to.find()so all returned quotes are searched.Changelog
CHANGELOG entry: Fixed Buy amount screen sometimes showing a generic error when quotes returned for the selected provider but provider id strings differed in format.
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/TRAM-3331
Based on draft PR #27779
Manual testing steps
Screenshots/Recordings
Before
N/A. Reason: This is an extremely rare race condition. It doesn't happen often, and after several changes on main, it's even less common. Nevertheless, we still want to solve this logical condition via this PR.
After
N/A. Reason: This is an extremely rare race condition. It doesn't happen often, and after several changes on main, it's even less common. Nevertheless, we still want to solve this logical condition via this PR.
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Touches Buy flow quote-selection and payment-method loading state; small logic changes but in a user-critical conversion path and could affect when errors/continue button appear.
Overview
Prevents the Buy amount input screen from briefly showing the generic no quotes error by updating
BuildQuoteto normalize provider IDs (handling/providers/...vs short codes) and to search all returned quotes via.find()when derivingselectedQuote.Tightens
useRampsPaymentMethodsloading behavior soisLoadingstays true while auto-selecting a payment method when the previously selected method is no longer present, avoiding UI flashes of stale selection. Adds targeted tests covering provider-ID matching scenarios, empty/mismatched quote responses, continue-button disabled state, and the stale-selection loading fallback.Reviewed by Cursor Bugbot for commit 2d4d9d7. Bugbot is set up for automated code reviews on this repo. Configure here.