Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions src/app/(mobile-ui)/add-money/__tests__/add-money-states.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,9 @@ jest.mock('@/components/Common/CountryList', () => ({
<button data-testid="country-germany" onClick={() => props.onCountryClick({ path: 'germany', id: 'DE' })}>
Germany
</button>
<button data-testid="country-chad" onClick={() => props.onCountryClick({ path: 'chad', id: 'TD' })}>
Chad
</button>
</div>
),
}))
Expand Down Expand Up @@ -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(<AddMoneyPage />)

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(<AddMoneyPage />)

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(<AddMoneyPage />)

fireEvent.click(screen.getByTestId('country-chad'))
expect(mockRouterPush).toHaveBeenCalledWith('/add-money/chad')
})

test('back from method selection navigates to /home', () => {
Expand Down
26 changes: 22 additions & 4 deletions src/app/(mobile-ui)/add-money/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading