diff --git a/src/app/(mobile-ui)/add-money/__tests__/add-money-states.test.tsx b/src/app/(mobile-ui)/add-money/__tests__/add-money-states.test.tsx index b0aeec54ac..07140bf537 100644 --- a/src/app/(mobile-ui)/add-money/__tests__/add-money-states.test.tsx +++ b/src/app/(mobile-ui)/add-money/__tests__/add-money-states.test.tsx @@ -607,6 +607,9 @@ jest.mock('@/components/Common/CountryList', () => ({ + ), })) @@ -1029,12 +1032,31 @@ describe('GROUP 1: Landing / Method Selection', () => { expect(screen.getByText('Select your country')).toBeInTheDocument() }) - test('selecting a country from list navigates to country page', () => { + // TASK-20033: picking a bank-supported country skips the redundant per-country + // method list and goes straight to the deposit screen (Manteca for AR/BR, + // Bridge bank otherwise). Coming-soon countries keep the per-country screen. + test('selecting a Manteca country (AR/BR) goes straight to the manteca deposit', () => { resetQueryState({ method: 'bank' }) renderWithProviders() fireEvent.click(screen.getByTestId('country-argentina')) - expect(mockRouterPush).toHaveBeenCalledWith('/add-money/argentina') + expect(mockRouterPush).toHaveBeenCalledWith('/add-money/argentina/manteca') + }) + + test('selecting a Bridge-supported country goes straight to the bank deposit', () => { + resetQueryState({ method: 'bank' }) + renderWithProviders() + + fireEvent.click(screen.getByTestId('country-germany')) + expect(mockRouterPush).toHaveBeenCalledWith('/add-money/germany/bank') + }) + + test('selecting a coming-soon country keeps the per-country method screen', () => { + resetQueryState({ method: 'bank' }) + renderWithProviders() + + fireEvent.click(screen.getByTestId('country-chad')) + expect(mockRouterPush).toHaveBeenCalledWith('/add-money/chad') }) test('back from method selection navigates to /home', () => { diff --git a/src/app/(mobile-ui)/add-money/page.tsx b/src/app/(mobile-ui)/add-money/page.tsx index 495b65140b..d2ecdf0a6a 100644 --- a/src/app/(mobile-ui)/add-money/page.tsx +++ b/src/app/(mobile-ui)/add-money/page.tsx @@ -14,10 +14,12 @@ import { useOnrampFlow } from '@/context/OnrampFlowContext' import { useRouter, useSearchParams } from 'next/navigation' import { useEffect } from 'react' import { useQueryState, parseAsStringEnum } from 'nuqs' -import { checkIfInternalNavigation, getRedirectUrl, clearRedirectUrl, getFromLocalStorage } from '@/utils/general.utils' +import { getRedirectUrl, clearRedirectUrl, getFromLocalStorage } from '@/utils/general.utils' +import { isBridgeSupportedCountry } from '@/utils/regions.utils' +import { isMantecaSupportedCountryCode } from '@/constants/manteca.consts' import posthog from 'posthog-js' import { ANALYTICS_EVENTS } from '@/constants/analytics.consts' -import { addMoneyCountryUrl } from '@/utils/native-routes' +import { addMoneyCountryUrl, rewriteMethodPath } from '@/utils/native-routes' export default function AddMoneyPage() { const router = useRouter() @@ -28,9 +30,12 @@ export default function AddMoneyPage() { // native app passes country as query param instead of path segment const countryFromQuery = searchParams.get('country') + // clear stale onramp state on the root list (no country in the URL); reruns + // on back-nav from a ?country=… sub-view, not just on mount. resetOnrampFlow + // is a stable useCallback. useEffect(() => { if (!countryFromQuery) resetOnrampFlow() - }, []) + }, [countryFromQuery, resetOnrampFlow]) const handleBack = () => { // if viewing country-specific form, go back to country list @@ -68,7 +73,20 @@ export default function AddMoneyPage() { method_type: 'bank', country: country.path, }) - router.push(addMoneyCountryUrl(country.path)) + + // The user already chose "Bank" — skip the redundant per-country method + // list and go straight to the deposit screen. AR/BR deposit via Manteca + // (which surfaces Pix / Mercado Pago itself); every other bank-supported + // country goes to the Bridge bank flow. Countries where bank isn't live + // yet keep the per-country screen, which is still useful there: it shows + // the "coming soon" bank state and the crypto fallback. + if (isMantecaSupportedCountryCode(country.id)) { + router.push(rewriteMethodPath(`/add-money/${country.path}/manteca`)) + } else if (isBridgeSupportedCountry(country.id)) { + router.push(rewriteMethodPath(`/add-money/${country.path}/bank`)) + } else { + router.push(addMoneyCountryUrl(country.path)) + } } // native app: render sub-views based on query params