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
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,6 @@ jest.mock(
},
);

// Mock HeaderCompactStandard
jest.mock(
'../../../../../component-library/components-temp/HeaderCompactStandard',
() => {
const ReactNative = jest.requireActual('react-native');
const { View, Text, TouchableOpacity } = ReactNative;

return {
__esModule: true,
default: (props: { title: string; onClose: () => void }) => (
<View testID="header-center">
<Text>{props.title}</Text>
<TouchableOpacity onPress={props.onClose} accessibilityLabel="Close">
<Text>Close</Text>
</TouchableOpacity>
</View>
),
};
},
);

// Mock InputStepper
jest.mock('../InputStepper', () => ({
InputStepper: jest.fn(
Expand Down Expand Up @@ -172,6 +151,7 @@ jest.mock('../../../../../../locales/i18n', () => ({
'bridge.slippage': 'Slippage',
'bridge.cancel': 'Cancel',
'bridge.confirm': 'Confirm',
'bridge.close': 'Close',
};
return translations[key] || key;
}),
Expand All @@ -183,6 +163,7 @@ import { useSlippageStepperDescription } from '../../hooks/useSlippageStepperDes
import { useParams } from '../../../../../util/navigation/navUtils';
import { InputStepper } from '../InputStepper';
import Keypad from '../../../../Base/Keypad';
import { strings } from '../../../../../../locales/i18n';

const mockUseSlippageConfig = useSlippageConfig as jest.MockedFunction<
typeof useSlippageConfig
Expand Down Expand Up @@ -1041,7 +1022,7 @@ describe('CustomSlippageModal', () => {
it('closes modal via header close button', () => {
const { getByLabelText } = render(<CustomSlippageModal />);

const closeButton = getByLabelText('Close');
const closeButton = getByLabelText(strings('bridge.close'));
fireEvent.press(closeButton);

// Verify it doesn't throw and component handles close
Expand All @@ -1051,7 +1032,7 @@ describe('CustomSlippageModal', () => {
it('does not dispatch slippage when closing without confirm', () => {
const { getByLabelText } = render(<CustomSlippageModal />);

const closeButton = getByLabelText('Close');
const closeButton = getByLabelText(strings('bridge.close'));
fireEvent.press(closeButton);

expect(mockDispatch).not.toHaveBeenCalled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import React, { useCallback, useRef, useState } from 'react';
import BottomSheet, {
BottomSheetRef,
} from '../../../../../component-library/components/BottomSheets/BottomSheet';
import HeaderCompactStandard from '../../../../../component-library/components-temp/HeaderCompactStandard';
import { strings } from '../../../../../../locales/i18n';
import { View } from 'react-native';
import {
Button,
ButtonSize,
ButtonVariant,
HeaderStandard,
} from '@metamask/design-system-react-native';
import Keypad from '../../../../Base/Keypad';
import { InputStepper } from '../InputStepper';
Expand Down Expand Up @@ -97,9 +97,12 @@ export const CustomSlippageModal = () => {

return (
<BottomSheet ref={sheetRef}>
<HeaderCompactStandard
<HeaderStandard
title={strings('bridge.slippage')}
onClose={handleClose}
closeButtonProps={{
accessibilityLabel: strings('bridge.close'),
}}
/>
<View style={customSlippageModalStyles.stepperContainer}>
<InputStepper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,6 @@ jest.mock(
},
);

// Mock HeaderCompactStandard
jest.mock(
'../../../../../component-library/components-temp/HeaderCompactStandard',
() => {
const ReactNative = jest.requireActual('react-native');
const { View, Text, TouchableOpacity } = ReactNative;

return {
__esModule: true,
default: (props: { title: string; onClose: () => void }) => (
<View testID="header-center">
<Text>{props.title}</Text>
<TouchableOpacity onPress={props.onClose} accessibilityLabel="Close">
<Text>Close</Text>
</TouchableOpacity>
</View>
),
};
},
);

// Mock dependencies
jest.mock('./DefaultSlippageButtonGroup', () => ({
DefaultSlippageButtonGroup: jest.fn(({ options }) => {
Expand Down Expand Up @@ -106,6 +85,7 @@ jest.mock('../../../../../../locales/i18n', () => ({
'bridge.slippage': 'Slippage',
'bridge.default_slippage_description': 'Set your slippage tolerance',
'bridge.submit': 'Submit',
'bridge.close': 'Close',
};
return translations[key] || key;
}),
Expand All @@ -115,6 +95,7 @@ import { useGetSlippageOptions } from '../../hooks/useGetSlippageOptions';
import { useSlippageConfig } from '../../hooks/useSlippageConfig';
import { useParams } from '../../../../../util/navigation/navUtils';
import { AUTO_SLIPPAGE_VALUE } from './constants';
import { strings } from '../../../../../../locales/i18n';

const mockUseGetSlippageOptions = useGetSlippageOptions as jest.MockedFunction<
typeof useGetSlippageOptions
Expand Down Expand Up @@ -215,7 +196,7 @@ describe('DefaultSlippageModal', () => {
it('closes bottom sheet when close is called', () => {
const { getByLabelText } = render(<DefaultSlippageModal />);

const closeButton = getByLabelText('Close');
const closeButton = getByLabelText(strings('bridge.close'));
fireEvent.press(closeButton);

// Bottom sheet close is handled internally by ref
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { useCallback, useRef, useState } from 'react';
import HeaderCompactStandard from '../../../../../component-library/components-temp/HeaderCompactStandard';
import BottomSheet, {
BottomSheetRef,
} from '../../../../../component-library/components/BottomSheets/BottomSheet';
Expand All @@ -9,6 +8,7 @@ import {
Button,
ButtonSize,
ButtonVariant,
HeaderStandard,
Text,
} from '@metamask/design-system-react-native';
import { DefaultSlippageButtonGroup } from './DefaultSlippageButtonGroup';
Expand Down Expand Up @@ -80,9 +80,12 @@ export const DefaultSlippageModal = () => {

return (
<BottomSheet ref={sheetRef}>
<HeaderCompactStandard
<HeaderStandard
title={strings('bridge.slippage')}
onClose={handleClose}
closeButtonProps={{
accessibilityLabel: strings('bridge.close'),
}}
/>
<View style={styles.descriptionContainer}>
<Text style={styles.descriptionText}>
Expand Down
1 change: 1 addition & 0 deletions locales/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -7368,6 +7368,7 @@
"price_impact_execution_description": "You'll lose approximately {{priceImpact}} of your token's value on this swap. Try lowering the amount or choosing a more liquid route.",
"proceed": "Proceed",
"cancel": "Cancel",
"close": "Close",
"slippage_info_title": "Slippage",
"slippage_info_description": "The % change in price you're willing to allow before your transaction is canceled.",
"blockaid_error_title": "This transaction will be reverted",
Expand Down
Loading