Skip to content

Commit

Permalink
chore: remove show receive amount in select provider feature gate (#4859
Browse files Browse the repository at this point in the history
)

### Description

The `show_receive_amount_in_select_provider` feature gate has been
rolled out to 100% since v1.62.0. This is to remove the code path for
when that gate returned false.

### Test plan

- Tested locally on iOS
- Unit Tests updated
- E2E tests updated

### Related issues

- Fixes ACT-1076

### Backwards compatibility

Yes
  • Loading branch information
MuckT committed Feb 14, 2024
1 parent ee6e8fc commit 69af536
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 513 deletions.
10 changes: 0 additions & 10 deletions e2e/src/usecases/OnRamps.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ export default onRamps = () => {
device.getPlatform() === 'ios'
? cardProviders.label.split(' ')[0]
: cardProviders.text.split(' ')[0]
await element(by.id('Card/section')).tap()
// Check that best rate is displayed first
await expect(
element(by.id('Card/provider-0').withDescendant(by.id('Card/bestRate')))
).toExist()
// Check that the expected number of providers show
for (let i = 0; i < numCardProviders; i++) {
await expect(element(by.id(`Card/provider-${i}`))).toExist()
Expand All @@ -64,11 +59,6 @@ export default onRamps = () => {
device.getPlatform() === 'ios'
? bankProviders.label.split(' ')[0]
: bankProviders.text.split(' ')[0]
await element(by.id('Bank/section')).tap()
// Check that best rate is displayed first
await expect(
element(by.id('Bank/provider-0').withDescendant(by.id('Bank/bestRate')))
).toExist()
// Check that the expected number of providers show
for (let i = 0; i < numBankProviders; i++) {
await expect(element(by.id(`Bank/provider-${i}`))).toExist()
Expand Down
29 changes: 4 additions & 25 deletions src/fiatExchanges/FiatExchangeAmount.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Screens } from 'src/navigator/Screens'
import { getFeatureGate } from 'src/statsig'
import { NetworkId } from 'src/transactions/types'
import { CiCoCurrency } from 'src/utils/currencies'
import { createMockStore, getElementText, getMockStackScreenProps } from 'test/utils'
import { createMockStore, getMockStackScreenProps } from 'test/utils'
import {
mockCeloAddress,
mockCeloTokenId,
Expand Down Expand Up @@ -243,51 +243,30 @@ describe('FiatExchangeAmount cashOut', () => {
})

it('displays correctly for cUSD when local currency is USD', () => {
const { getByText, getByTestId } = render(
const { getByText } = render(
<Provider store={storeWithUSD}>
<FiatExchangeAmount {...mockScreenProps} />
</Provider>
)
expect(getByText('amount (cUSD)')).toBeTruthy()
expect(getElementText(getByTestId('LineItemRowTitle/subtotal'))).toBe('cUSD @ $1.00')
expect(getElementText(getByTestId('LineItemRow/subtotal'))).toBe('$0.00')
expect(getByText('disclaimerFiat, {"currency":"cUSD"}')).toBeTruthy()
})

it('displays correctly for cEUR when local currency is USD', () => {
const { getByText, getByTestId } = render(
const { getByText } = render(
<Provider store={storeWithUSD}>
<FiatExchangeAmount {...mockScreenPropsEuro} />
</Provider>
)
expect(getByText('amount (cEUR)')).toBeTruthy()
expect(getElementText(getByTestId('LineItemRowTitle/subtotal'))).toBe('cEUR @ $1.20')
expect(getElementText(getByTestId('LineItemRow/subtotal'))).toBe('$0.00')
expect(getByText('disclaimerFiat, {"currency":"cEUR"}')).toBeTruthy()
})

it('displays correctly for CELO when local currency is USD', () => {
const { getByText, getByTestId } = render(
const { getByText } = render(
<Provider store={storeWithUSD}>
<FiatExchangeAmount {...mockScreenPropsCelo} />
</Provider>
)
expect(getByText('amount (CELO)')).toBeTruthy()
expect(getElementText(getByTestId('LineItemRowTitle/subtotal'))).toBe('CELO @ $5.00')
expect(getElementText(getByTestId('LineItemRow/subtotal'))).toBe('$0.00')
})

it('displays correctly when the SHOW_RECEIVE_AMOUNT_IN_SELECT_PROVIDER feature flag is on', () => {
jest.mocked(getFeatureGate).mockReturnValue(true)
const { getByText, queryByTestId, queryByText } = render(
<Provider store={storeWithUSD}>
<FiatExchangeAmount {...mockScreenProps} />
</Provider>
)
expect(getByText('amount (cUSD)')).toBeTruthy()
expect(queryByTestId('LineItemRowTitle/subtotal')).toBeFalsy()
expect(queryByTestId('LineItemRow/subtotal')).toBeFalsy()
expect(queryByText('disclaimerFiat, {"currency":"cUSD"}')).toBeFalsy()
})

it('disables the next button if the cUSD amount is 0', () => {
Expand Down
46 changes: 0 additions & 46 deletions src/fiatExchanges/FiatExchangeAmount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import Button, { BtnSizes, BtnTypes } from 'src/components/Button'
import Dialog from 'src/components/Dialog'
import KeyboardAwareScrollView from 'src/components/KeyboardAwareScrollView'
import KeyboardSpacer from 'src/components/KeyboardSpacer'
import LineItemRow from 'src/components/LineItemRow'
import TokenDisplay from 'src/components/TokenDisplay'
import { ALERT_BANNER_DURATION, DOLLAR_ADD_FUNDS_MAX_AMOUNT } from 'src/config'
import { useMaxSendAmount } from 'src/fees/hooks'
import { FeeType } from 'src/fees/reducer'
Expand All @@ -37,8 +35,6 @@ import { navigate } from 'src/navigator/NavigationService'
import { Screens } from 'src/navigator/Screens'
import { StackParamList } from 'src/navigator/types'
import DisconnectBanner from 'src/shared/DisconnectBanner'
import { getFeatureGate } from 'src/statsig'
import { StatsigFeatureGates } from 'src/statsig/types'
import colors from 'src/styles/colors'
import fontStyles from 'src/styles/fonts'
import variables from 'src/styles/variables'
Expand Down Expand Up @@ -94,10 +90,6 @@ function FiatExchangeAmount({ route }: Props) {
overLocalLimitDisplayString = ` (${localCurrencySymbol}${roundUp(localCurrencyMaxAmount)})`
}

const showExchangeRate = !getFeatureGate(
StatsigFeatureGates.SHOW_RECEIVE_AMOUNT_IN_SELECT_PROVIDER
)

const dispatch = useDispatch()

function isNextButtonValid() {
Expand Down Expand Up @@ -213,37 +205,7 @@ function FiatExchangeAmount({ route }: Props) {
testID="FiatExchangeInput"
/>
</View>
{showExchangeRate && (
<LineItemRow
testID="subtotal"
textStyle={styles.subtotalBodyText}
title={
<>
{`${tokenSymbol} @ `}
{
<TokenDisplay
amount={BigNumber(1)}
tokenId={tokenId}
showLocalAmount={true}
hideSign={false}
/>
}
</>
}
amount={
<TokenDisplay
amount={inputCryptoAmount}
tokenId={tokenId}
showLocalAmount={inputIsCrypto}
hideSign={false}
/>
}
/>
)}
</KeyboardAwareScrollView>
{showExchangeRate && (
<Text style={styles.disclaimerFiat}>{t('disclaimerFiat', { currency: tokenSymbol })}</Text>
)}
<Button
onPress={onPressContinue}
showLoading={usdToLocalRate === null || attemptReturnUserFlowLoading}
Expand Down Expand Up @@ -326,9 +288,6 @@ const styles = StyleSheet.create({
exchangeBodyText: {
...fontStyles.regular500,
},
subtotalBodyText: {
...fontStyles.small,
},
currencyInput: {
...fontStyles.regular,
marginLeft: 10,
Expand All @@ -344,9 +303,4 @@ const styles = StyleSheet.create({
reviewBtn: {
padding: variables.contentPadding,
},
disclaimerFiat: {
...fontStyles.small,
color: colors.gray4,
textAlign: 'center',
},
})
118 changes: 6 additions & 112 deletions src/fiatExchanges/PaymentMethodSection.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
mockCusdAddress,
mockCusdTokenId,
mockFiatConnectQuotes,
mockFiatConnectQuotesWithUnknownFees,
mockProviderSelectionAnalyticsData,
mockProviders,
} from 'test/values'
Expand Down Expand Up @@ -89,30 +88,7 @@ describe('PaymentMethodSection', () => {
expect(queryByTestId('newDialog')).toBeFalsy()
})

it('shows a non-expandable view with fees if there is one provider available and feature gate is false', async () => {
props.normalizedQuotes = normalizeQuotes(
CICOFlow.CashIn,
[],
[mockProviders[2]],
mockCusdTokenId,
'cUSD'
)
const { queryByText, queryByTestId } = render(
<Provider store={mockStore}>
<PaymentMethodSection {...props} />
</Provider>
)
expect(queryByText('selectProviderScreen.card')).toBeTruthy()
expect(queryByTestId('image-Ramp')).toBeTruthy()
expect(queryByTestId('newLabel-Ramp')).toBeFalsy()
// NOTE: this ideally should show fees, but because of mock store, tokenInfo
// and exchange rate isn't available, no fees are shown. This isn't too
// important to test now since that we're going to roll out received amount
// and this will be cleaned up
expect(queryByTestId('Card/provider-0')).toHaveTextContent('selectProviderScreen.feesVary')
})

it('shows a non-expandable view with receive amount if there is one provider available and feature gate is true', async () => {
it('shows a non-expandable view with receive amount if there is one provider available', async () => {
jest.mocked(getFeatureGate).mockReturnValue(true)
props.normalizedQuotes = normalizeQuotes(
CICOFlow.CashIn,
Expand Down Expand Up @@ -160,69 +136,6 @@ describe('PaymentMethodSection', () => {
await waitFor(() => expect(getByTestId('newDialog')).not.toBeVisible())
})

it('shows an expandable view with fees if there is more than one provider available and feature gate is false', async () => {
const { queryByText, queryByTestId, getByText } = render(
<Provider store={mockStore}>
<PaymentMethodSection {...props} />
</Provider>
)

expect(queryByText('selectProviderScreen.card')).toBeTruthy()
expect(queryByText('selectProviderScreen.numProviders, {"count":3}')).toBeTruthy()
expect(queryByTestId('Card/minFee')).toBeTruthy()
expect(queryByTestId('image-Ramp')).toBeFalsy()
expect(queryByTestId('image-Simplex')).toBeFalsy()
expect(queryByTestId('image-Moonpay')).toBeFalsy()

// Expand works
fireEvent.press(getByText('selectProviderScreen.numProviders, {"count":3}'))
expect(queryByTestId('image-Ramp')).toBeTruthy()
expect(queryByTestId('image-Simplex')).toBeTruthy()
expect(queryByTestId('image-Moonpay')).toBeTruthy()
expect(queryByTestId('newLabel-Ramp')).toBeFalsy()
expect(queryByTestId('newLabel-Simplex')).toBeFalsy()
expect(queryByTestId('newLabel-Moonpay')).toBeFalsy()
expect(queryByTestId('Card/amount-0')).toHaveTextContent('selectProviderScreen.feesVary')
expect(queryByTestId('Card/amount-1')).toHaveTextContent('selectProviderScreen.feesVary')
expect(queryByTestId('Card/amount-2')).toHaveTextContent('selectProviderScreen.feesVary')
})

it('shows an expanded view with receive amount if there is more than one provider available and feature gate is false', async () => {
jest.mocked(getFeatureGate).mockReturnValue(true)
const { queryByText, queryByTestId, getByText, debug } = render(
<Provider store={mockStore}>
<PaymentMethodSection {...props} />
</Provider>
)

debug()

expect(queryByText('selectProviderScreen.card')).toBeTruthy()
expect(queryByText('selectProviderScreen.numProviders, {"count":3}')).toBeTruthy()
expect(queryByTestId('Card/minFee')).toBeFalsy()
expect(queryByTestId('image-Ramp')).toBeTruthy()
expect(queryByTestId('image-Simplex')).toBeTruthy()
expect(queryByTestId('image-Moonpay')).toBeTruthy()
expect(queryByTestId('newLabel-Ramp')).toBeFalsy()
expect(queryByTestId('newLabel-Simplex')).toBeFalsy()
expect(queryByTestId('newLabel-Moonpay')).toBeFalsy()
expect(queryByTestId('Card/amount-0')).toHaveTextContent(
'selectProviderScreen.receiveAmount100.00 cUSD'
)
expect(queryByTestId('Card/amount-1')).toHaveTextContent(
'selectProviderScreen.receiveAmount25.00 cUSD'
)
expect(queryByTestId('Card/amount-2')).toHaveTextContent(
'selectProviderScreen.receiveAmount90.00 cUSD'
)

// Collapse works
fireEvent.press(getByText('selectProviderScreen.numProviders, {"count":3}'))
expect(queryByTestId('image-Ramp')).toBeFalsy()
expect(queryByTestId('image-Simplex')).toBeFalsy()
expect(queryByTestId('image-Moonpay')).toBeFalsy()
})

it('shows new label for multiple providers in expanded view', async () => {
// make simplex and moonpay card quotes new
jest.spyOn(props.normalizedQuotes[3], 'isProviderNew').mockReturnValue(true)
Expand All @@ -236,12 +149,7 @@ describe('PaymentMethodSection', () => {

expect(queryByText('selectProviderScreen.card')).toBeTruthy()
expect(queryByText('selectProviderScreen.numProviders, {"count":3}')).toBeTruthy()
expect(queryByTestId('image-Ramp')).toBeFalsy()
expect(queryByTestId('image-Simplex')).toBeFalsy()
expect(queryByTestId('image-Moonpay')).toBeFalsy()

// Expand works
fireEvent.press(getByText('selectProviderScreen.numProviders, {"count":3}'))
expect(queryByTestId('image-Ramp')).toBeTruthy()
expect(queryByTestId('image-Simplex')).toBeTruthy()
expect(queryByTestId('image-Moonpay')).toBeTruthy()
Expand All @@ -256,26 +164,12 @@ describe('PaymentMethodSection', () => {
await waitFor(() => expect(getByTestId('newDialog')).not.toBeVisible())
fireEvent.press(getByTestId('newLabel-Moonpay'))
expect(getByTestId('newDialog')).toBeVisible()
})

it('shows "Fees Vary" when a provider does not return fees in its quote', async () => {
props.normalizedQuotes = normalizeQuotes(
CICOFlow.CashIn,
mockFiatConnectQuotesWithUnknownFees,
[],
mockCusdTokenId,
'cUSD'
)
props.paymentMethod = PaymentMethod.Bank
const { queryByText, queryByTestId } = render(
<Provider store={mockStore}>
<PaymentMethodSection {...props} />
</Provider>
)
const expandElement = queryByText('selectProviderScreen.numProviders, {"count":2}')
expect(expandElement).toBeTruthy()
fireEvent.press(expandElement!)
expect(queryByTestId('Bank/amount-1')).toHaveTextContent('selectProviderScreen.feesVary')
// Collapse works
fireEvent.press(getByText('selectProviderScreen.numProviders, {"count":3}'))
expect(queryByTestId('image-Ramp')).toBeFalsy()
expect(queryByTestId('image-Simplex')).toBeFalsy()
expect(queryByTestId('image-Moonpay')).toBeFalsy()
})

it('shows "ID required" when KYC is required', async () => {
Expand Down
Loading

0 comments on commit 69af536

Please sign in to comment.