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 @@ -4,7 +4,6 @@ import { SafeAreaView } from 'react-native';
import { useNavigation } from '@react-navigation/native';

// External dependencies.
import BottomSheetHeader from '../../../../component-library/components/BottomSheets/BottomSheetHeader';
import { IconName } from '@metamask/design-system-react-native';
import ActionListItem from '../../ActionListItem';
import { strings } from '../../../../../locales/i18n';
Expand Down Expand Up @@ -88,9 +87,6 @@ const MultichainAddWalletActions = ({
return (
<SafeAreaView>
<Fragment>
<BottomSheetHeader>
{strings('multichain_accounts.add_wallet')}
</BottomSheetHeader>
{actionConfigs.map(
(config) =>
config.isVisible && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,46 +313,6 @@ exports[`MultichainAddWalletActions renders correctly 1`] = `
}
>
<RCTSafeAreaView>
<View
style={
[
{
"backgroundColor": "#ffffff",
"flexDirection": "row",
"gap": 16,
"padding": 16,
},
false,
]
}
testID="header"
>
<View
style={
{
"alignItems": "center",
"flex": 1,
}
}
>
<Text
accessibilityRole="text"
style={
{
"color": "#121314",
"fontFamily": "Geist Bold",
"fontSize": 16,
"letterSpacing": 0,
"lineHeight": 24,
"textAlign": "center",
}
}
testID="header-title"
>
Add wallet
</Text>
</View>
</View>
<View
accessibilityState={
{
Expand Down
9 changes: 9 additions & 0 deletions app/components/Nav/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,15 @@ const RootModalFlow = (props: RootModalFlowProps) => (
<Stack.Screen
name={Routes.SHEET.ACCOUNT_SELECTOR}
component={AccountSelector}
options={{
cardStyle: { backgroundColor: importedColors.transparent },
cardStyleInterpolator: () => ({
overlayStyle: {
opacity: 0,
},
}),
detachPreviousScreen: false,
}}
/>
<Stack.Screen
name={Routes.SHEET.ADDRESS_SELECTOR}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('PredictActivity', () => {
expect(screen.getByText('Buy')).toBeOnTheScreen();
expect(screen.getByText(baseItem.marketTitle)).toBeOnTheScreen();
expect(screen.getByText('-$1,234.50')).toBeOnTheScreen();
expect(screen.getByText('2%')).toBeOnTheScreen();
expect(screen.getByText('1.5%')).toBeOnTheScreen();
});

it('renders SELL activity with plus-signed amount and negative percent', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ describe('PredictActivityDetail', () => {
expect(screen.getByText(expectedPricePerShare)).toBeOnTheScreen();

expect(screen.getByText('Price impact')).toBeOnTheScreen();
expect(screen.getByText('2%')).toBeOnTheScreen();
expect(screen.getByText('1.5%')).toBeOnTheScreen();

expect(screen.queryByLabelText('USDC')).toBeNull();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ describe('PredictBalance', () => {
});

// Assert
expect(getByText(/\$123\.45/)).toBeOnTheScreen();
expect(getByText(/\$123\.46/)).toBeOnTheScreen();
});

it('displays zero balance', () => {
Expand All @@ -189,7 +189,7 @@ describe('PredictBalance', () => {
});

// Assert
expect(getByText(/\$0\.00/)).toBeOnTheScreen();
expect(getByText(/\$0/)).toBeOnTheScreen();
});

it('displays large balance correctly', () => {
Expand All @@ -209,7 +209,7 @@ describe('PredictBalance', () => {
});

// Assert
expect(getByText(/\$1,234,567\.88/)).toBeOnTheScreen();
expect(getByText(/\$1,234,567\.89/)).toBeOnTheScreen();
});

it('renders container with correct test ID', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const PredictMarketMultiple: React.FC<PredictMarketMultipleProps> = ({
const parsed = outcomePrices;
if (Array.isArray(parsed) && parsed.length > 0) {
const firstValue = parsed[0];
return formatPercentage(firstValue * 100);
return formatPercentage(firstValue * 100, { truncate: true });
}
} catch (error) {
DevLogger.log('PredictMarketMultiple: Failed to parse outcomePrices', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const PredictMarketOutcome: React.FC<PredictMarketOutcomeProps> = ({
const getYesPercentage = (): string => {
const prices = getOutcomePrices();
if (prices.length > 0) {
return formatPercentage(prices[0] * 100);
return formatPercentage(prices[0] * 100, { truncate: true });
}
return '0%';
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ import {
} from '../../types';
import { PredictPositionSelectorsIDs } from '../../../../../../e2e/selectors/Predict/Predict.selectors';

jest.mock('../../../../../../locales/i18n', () => ({
strings: jest.fn((key: string, vars?: Record<string, string | number>) => {
if (key === 'predict.position_info' && vars) {
return `${vars.initialValue} on ${vars.outcome} to win ${vars.shares}`;
}
return key;
}),
}));

const basePosition: PredictPositionType = {
id: 'pos-1',
providerId: 'polymarket',
Expand Down Expand Up @@ -46,17 +55,15 @@ describe('PredictPosition', () => {
renderComponent();

expect(screen.getByText(basePosition.title)).toBeOnTheScreen();
expect(
screen.getByText('$123.45 on Yes · 10 shares at 34¢'),
).toBeOnTheScreen();
expect(screen.getByText('$123.45 on Yes to win $10')).toBeOnTheScreen();
expect(screen.getByText('$2,345.67')).toBeOnTheScreen();
expect(screen.getByText('5%')).toBeOnTheScreen();
expect(screen.getByText('5.25%')).toBeOnTheScreen();
});

it.each([
{ value: -3.5, expected: '-3%' },
{ value: -3.5, expected: '-3.5%' },
{ value: 0, expected: '0%' },
{ value: 7.5, expected: '8%' },
{ value: 7.5, expected: '7.5%' },
])('formats percentPnl $value as $expected', ({ value, expected }) => {
renderComponent({ percentPnl: value });

Expand All @@ -71,9 +78,7 @@ describe('PredictPosition', () => {
size: 10,
});

expect(
screen.getByText('$50.00 on No · 10 shares at 70¢'),
).toBeOnTheScreen();
expect(screen.getByText('$50 on No to win $10')).toBeOnTheScreen();
});

it('displays singular share when size is 1', () => {
Expand All @@ -84,7 +89,7 @@ describe('PredictPosition', () => {
size: 1,
});

expect(screen.getByText('$50.00 on No · 1 share at 70¢')).toBeOnTheScreen();
expect(screen.getByText('$50 on No to win $1')).toBeOnTheScreen();
});

it('renders icon image with correct URI', () => {
Expand Down Expand Up @@ -154,33 +159,25 @@ describe('PredictPosition', () => {
it('formats avgPrice with 1 decimal precision in cents', () => {
renderComponent({ avgPrice: 0.456, size: 5 });

expect(
screen.getByText('$123.45 on Yes · 5 shares at 45.6¢'),
).toBeOnTheScreen();
expect(screen.getByText('$123.45 on Yes to win $5')).toBeOnTheScreen();
});

it('formats avgPrice as whole cents when no decimals needed', () => {
renderComponent({ avgPrice: 0.5, size: 2 });

expect(
screen.getByText('$123.45 on Yes · 2 shares at 50¢'),
).toBeOnTheScreen();
expect(screen.getByText('$123.45 on Yes to win $2')).toBeOnTheScreen();
});

it('formats initialValue without decimals when minimumDecimals is 0', () => {
renderComponent({ initialValue: 100, size: 3 });

expect(
screen.getByText('$100.00 on Yes · 3 shares at 34¢'),
).toBeOnTheScreen();
expect(screen.getByText('$100 on Yes to win $3')).toBeOnTheScreen();
});

it('formats size with 2 decimal places', () => {
renderComponent({ size: 10.5555, initialValue: 200 });

expect(
screen.getByText('$200.00 on Yes · 10.56 shares at 34¢'),
).toBeOnTheScreen();
expect(screen.getByText('$200 on Yes to win $10.56')).toBeOnTheScreen();
});

it('renders all position properties correctly', () => {
Expand Down Expand Up @@ -209,11 +206,9 @@ describe('PredictPosition', () => {
render(<PredictPosition position={position} />);

expect(screen.getByText('Test Market Question?')).toBeOnTheScreen();
expect(
screen.getByText('$75.25 on Maybe · 7.50 shares at 62.5¢'),
).toBeOnTheScreen();
expect(screen.getByText('$75.25 on Maybe to win $7.50')).toBeOnTheScreen();
expect(screen.getByText('$100.75')).toBeOnTheScreen();
expect(screen.getByText('16%')).toBeOnTheScreen();
expect(screen.getByText('15.75%')).toBeOnTheScreen();
});

describe('optimistic updates UI', () => {
Expand All @@ -233,15 +228,13 @@ describe('PredictPosition', () => {
renderComponent({ optimistic: false });

expect(screen.getByText('$2,345.67')).toBeOnTheScreen();
expect(screen.getByText('5%')).toBeOnTheScreen();
expect(screen.getByText('5.25%')).toBeOnTheScreen();
});

it('shows initial value line when optimistic', () => {
renderComponent({ optimistic: true, initialValue: 123.45 });

expect(
screen.getByText('$123.45 on Yes · 10 shares at 34¢'),
).toBeOnTheScreen();
expect(screen.getByText('$123.45 on Yes to win $10')).toBeOnTheScreen();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ import Text, {
} from '../../../../../component-library/components/Texts/Text';
import { useStyles } from '../../../../../component-library/hooks';
import { PredictPosition as PredictPositionType } from '../../types';
import {
formatCents,
formatPercentage,
formatPositionSize,
formatPrice,
} from '../../utils/format';
import { formatPercentage, formatPrice } from '../../utils/format';
import styleSheet from './PredictPosition.styles';
import { PredictPositionSelectorsIDs } from '../../../../../../e2e/selectors/Predict/Predict.selectors';
import { strings } from '../../../../../../locales/i18n';
Expand All @@ -32,7 +27,6 @@ const PredictPosition: React.FC<PredictPositionProps> = ({
initialValue,
percentPnl,
outcome,
avgPrice,
currentValue,
size,
optimistic,
Expand All @@ -53,23 +47,15 @@ const PredictPosition: React.FC<PredictPositionProps> = ({
{title}
</Text>
<Text variant={TextVariant.BodySMMedium} color={TextColor.Alternative}>
{strings(
size !== 1
? 'predict.position_info_plural'
: 'predict.position_info_singular',
{
amount: formatPrice(initialValue, {
minimumDecimals: 0,
maximumDecimals: 2,
}),
outcome,
shares: formatPositionSize(size, {
minimumDecimals: 2,
maximumDecimals: 2,
}),
priceCents: formatCents(avgPrice),
},
)}
{strings('predict.position_info', {
initialValue: formatPrice(initialValue, {
maximumDecimals: 2,
}),
outcome,
shares: formatPrice(size, {
maximumDecimals: 2,
}),
})}
</Text>
</View>
<View style={styles.positionPnl}>
Expand Down
Loading
Loading