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
22 changes: 1 addition & 21 deletions app/components/UI/Rewards/Views/BenefitFullView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,6 @@ jest.mock('@metamask/design-system-twrnc-preset', () => ({
useTailwind: () => ({ style: (...args: unknown[]) => args }),
}));

jest.mock(
'../../../../component-library/components-temp/HeaderCompactStandard',
() => {
const ReactActual = jest.requireActual('react');
const { Pressable, Text, View } = jest.requireActual('react-native');
return {
__esModule: true,
default: ({ title, onBack }: { title: string; onBack: () => void }) =>
ReactActual.createElement(
View,
{ testID: 'header' },
ReactActual.createElement(Text, null, title),
ReactActual.createElement(Pressable, {
onPress: onBack,
testID: 'header-back-button',
}),
),
};
},
);

jest.mock('../../../Views/ErrorBoundary', () => ({
__esModule: true,
default: ({ children }: { children: React.ReactNode }) => children,
Expand All @@ -104,6 +83,7 @@ jest.mock('react-native-safe-area-context', () => {
testID,
}: React.PropsWithChildren<{ testID?: string }>) =>
ReactActual.createElement(View, { testID }, children),
useSafeAreaInsets: () => ({ top: 0, bottom: 0, left: 0, right: 0 }),
};
});

Expand Down
4 changes: 2 additions & 2 deletions app/components/UI/Rewards/Views/BenefitFullView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import {
Text,
TextColor,
TextVariant,
HeaderStandard,
} from '@metamask/design-system-react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { BenefitFullViewRouteProp } from './BenefitFullView.types.ts';
import { REWARDS_VIEW_SELECTORS } from './RewardsView.constants.ts';
import { formatDateRemaining } from '../utils/formatUtils.ts';
import HeaderCompactStandard from '../../../../component-library/components-temp/HeaderCompactStandard';
import { strings } from '../../../../../locales/i18n';
import ErrorBoundary from '../../../Views/ErrorBoundary';
import Routes from '../../../../constants/navigation/Routes.ts';
Expand Down Expand Up @@ -80,7 +80,7 @@ const BenefitFullView = () => {
style={tw.style('flex-1')}
testID={REWARDS_VIEW_SELECTORS.DETAIL_BENEFIT_VIEW}
>
<HeaderCompactStandard
<HeaderStandard
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

includesTopInset prop likely ignored by HeaderStandard

High Severity

Multiple views pass includesTopInset to HeaderStandard, but this prop was specific to the HeaderRoot/HeaderCompactStandard component in components-temp. Existing HeaderStandard usages elsewhere in the codebase (MoneyHeader, PerpsHomeHeader) never use includesTopInset, and no evidence of this prop exists in the design-system package. The affected views (BenefitFullView, BenefitsFullView, CampaignMechanicsView, CampaignsView, OndoCampaignDetailsView, RewardsReferralView, SeasonOneCampaignDetailsView) use SafeAreaView with edges={{ bottom: 'additive' }}, relying entirely on the header for top safe-area inset handling. If HeaderStandard silently ignores includesTopInset, header content will render under the status bar / notch on iOS devices.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d6a8c44. Configure here.

title={strings('rewards.benefits.title_claim')}
onBack={() => navigation.goBack()}
backButtonProps={{ testID: 'header-back-button' }}
Expand Down
27 changes: 1 addition & 26 deletions app/components/UI/Rewards/Views/BenefitsFullView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,32 +43,6 @@ jest.mock('@metamask/design-system-twrnc-preset', () => ({
useTailwind: () => ({ style: (...args: unknown[]) => args }),
}));

jest.mock('@metamask/design-system-react-native', () => {
const actual = jest.requireActual('@metamask/design-system-react-native');
return { ...actual };
});

jest.mock(
'../../../../component-library/components-temp/HeaderCompactStandard',
() => {
const ReactActual = jest.requireActual('react');
const { Pressable, Text, View } = jest.requireActual('react-native');
return {
__esModule: true,
default: ({ title, onBack }: { title: string; onBack: () => void }) =>
ReactActual.createElement(
View,
{ testID: 'header' },
ReactActual.createElement(Text, null, title),
ReactActual.createElement(Pressable, {
onPress: onBack,
testID: 'header-back-button',
}),
),
};
},
);

jest.mock('../../../Views/ErrorBoundary', () => ({
__esModule: true,
default: ({ children }: { children: React.ReactNode }) => children,
Expand Down Expand Up @@ -123,6 +97,7 @@ jest.mock('react-native-safe-area-context', () => {
testID,
}: React.PropsWithChildren<{ testID?: string }>) =>
ReactActual.createElement(View, { testID }, children),
useSafeAreaInsets: () => ({ top: 0, bottom: 0, left: 0, right: 0 }),
};
});

Expand Down
9 changes: 6 additions & 3 deletions app/components/UI/Rewards/Views/BenefitsFullView.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { Text, TextVariant } from '@metamask/design-system-react-native';
import {
HeaderStandard,
Text,
TextVariant,
} from '@metamask/design-system-react-native';
import React, { useState } from 'react';
import useTrackRewardsPageView from '../hooks/useTrackRewardsPageView';
import { strings } from '../../../../../locales/i18n';
Expand All @@ -12,7 +16,6 @@ import { useBenefits } from '../hooks/useBenefits.ts';
import { SubscriptionBenefitDto } from '../../../../core/Engine/controllers/rewards-controller/types.ts';
import BenefitCard from '../components/Benefits/BenefitCard.tsx';
import { useTailwind } from '@metamask/design-system-twrnc-preset';
import HeaderCompactStandard from '../../../../component-library/components-temp/HeaderCompactStandard';
import { useNavigation } from '@react-navigation/native';
import ErrorBoundary from '../../../Views/ErrorBoundary';
import TheMiracleFooter from '../components/Benefits/TheMiracleFooter.tsx';
Expand Down Expand Up @@ -59,7 +62,7 @@ const BenefitsFullView = () => {
style={tw.style('flex-1 bg-default')}
testID={REWARDS_VIEW_SELECTORS.LIST_BENEFIT_VIEW}
>
<HeaderCompactStandard
<HeaderStandard
title={strings('rewards.benefits.title')}
onBack={() => navigation.goBack()}
backButtonProps={{ testID: 'header-back-button' }}
Expand Down
28 changes: 1 addition & 27 deletions app/components/UI/Rewards/Views/CampaignMechanicsView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,10 @@ jest.mock('@react-navigation/native', () => ({
useRoute: () => ({ params: { campaignId: 'campaign-1' } }),
}));

jest.mock('@metamask/design-system-react-native', () => {
const actual = jest.requireActual('@metamask/design-system-react-native');
return { ...actual };
});

jest.mock('@metamask/design-system-twrnc-preset', () => ({
useTailwind: () => ({ style: (...args: unknown[]) => args }),
}));

jest.mock(
'../../../../component-library/components-temp/HeaderCompactStandard',
() => {
const ReactActual = jest.requireActual('react');
const { View, Text, Pressable } = jest.requireActual('react-native');
return {
__esModule: true,
default: ({ title, onBack }: { title: string; onBack: () => void }) =>
ReactActual.createElement(
View,
{ testID: 'header' },
ReactActual.createElement(Text, null, title),
ReactActual.createElement(Pressable, {
onPress: onBack,
testID: 'header-back-button',
}),
),
};
},
);

jest.mock('../../../Views/ErrorBoundary', () => {
const ReactActual = jest.requireActual('react');
return {
Expand Down Expand Up @@ -151,7 +125,7 @@ describe('CampaignMechanicsView', () => {

it('navigates back when the back button is pressed', () => {
const { getByTestId } = render(<CampaignMechanicsView />);
fireEvent.press(getByTestId('header-back-button'));
fireEvent.press(getByTestId('campaign-mechanics-back-button'));
expect(mockGoBack).toHaveBeenCalledTimes(1);
});

Expand Down
5 changes: 2 additions & 3 deletions app/components/UI/Rewards/Views/CampaignMechanicsView.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React, { useMemo } from 'react';
import { ScrollView } from 'react-native';
import { useNavigation, useRoute, RouteProp } from '@react-navigation/native';
import { Box } from '@metamask/design-system-react-native';
import { Box, HeaderStandard } from '@metamask/design-system-react-native';
import { useTailwind } from '@metamask/design-system-twrnc-preset';
import { SafeAreaView } from 'react-native-safe-area-context';
import HeaderCompactStandard from '../../../../component-library/components-temp/HeaderCompactStandard';
import ErrorBoundary from '../../../Views/ErrorBoundary';
import CampaignHowItWorks from '../components/Campaigns/CampaignHowItWorks';
import ContentfulRichText, {
Expand Down Expand Up @@ -54,7 +53,7 @@ const CampaignMechanicsView: React.FC = () => {
style={tw.style('flex-1 bg-default')}
testID={CAMPAIGN_MECHANICS_TEST_IDS.CONTAINER}
>
<HeaderCompactStandard
<HeaderStandard
title={strings('rewards.campaign_mechanics.title')}
onBack={() => navigation.goBack()}
backButtonProps={{ testID: 'campaign-mechanics-back-button' }}
Expand Down
26 changes: 0 additions & 26 deletions app/components/UI/Rewards/Views/CampaignsView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ jest.mock('@react-navigation/native', () => ({
useNavigation: () => ({ goBack: mockGoBack }),
}));

jest.mock('@metamask/design-system-react-native', () => {
const actual = jest.requireActual('@metamask/design-system-react-native');
return { ...actual };
});

jest.mock('@metamask/design-system-twrnc-preset', () => ({
useTailwind: () => ({ style: (...args: unknown[]) => args }),
}));
Expand Down Expand Up @@ -102,27 +97,6 @@ jest.mock('../components/RewardsErrorBanner', () => {
};
});

jest.mock(
'../../../../component-library/components-temp/HeaderCompactStandard',
() => {
const ReactActual = jest.requireActual('react');
const { View, Text, Pressable } = jest.requireActual('react-native');
return {
__esModule: true,
default: ({ title, onBack }: { title: string; onBack: () => void }) =>
ReactActual.createElement(
View,
{ testID: 'header' },
ReactActual.createElement(Text, null, title),
ReactActual.createElement(Pressable, {
onPress: onBack,
testID: 'header-back-button',
}),
),
};
},
);

jest.mock('../../../Views/ErrorBoundary', () => {
const ReactActual = jest.requireActual('react');
return {
Expand Down
4 changes: 2 additions & 2 deletions app/components/UI/Rewards/Views/CampaignsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import {
TextVariant,
BoxFlexDirection,
BoxAlignItems,
HeaderStandard,
Skeleton,
} from '@metamask/design-system-react-native';
import { useTailwind } from '@metamask/design-system-twrnc-preset';
import { SafeAreaView } from 'react-native-safe-area-context';
import ErrorBoundary from '../../../Views/ErrorBoundary';
import HeaderCompactStandard from '../../../../component-library/components-temp/HeaderCompactStandard';
import { useRewardCampaigns } from '../hooks/useRewardCampaigns';
import RewardsErrorBanner from '../components/RewardsErrorBanner';
import { REWARDS_VIEW_SELECTORS } from './RewardsView.constants';
Expand Down Expand Up @@ -110,7 +110,7 @@ const CampaignsView: React.FC = () => {
style={tw.style('flex-1 bg-default')}
testID={REWARDS_VIEW_SELECTORS.CAMPAIGNS_VIEW}
>
<HeaderCompactStandard
<HeaderStandard
title={strings('rewards.campaigns_view.title')}
onBack={() => navigation.goBack()}
backButtonProps={{ testID: 'header-back-button' }}
Expand Down
20 changes: 0 additions & 20 deletions app/components/UI/Rewards/Views/MusdCalculatorView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,6 @@ jest.mock('../../../Views/ErrorBoundary', () => ({
default: ({ children }: { children: React.ReactNode }) => children,
}));

jest.mock(
'../../../../component-library/components-temp/HeaderCompactStandard',
() => {
const ReactActual = jest.requireActual('react');
const { View, Pressable } = jest.requireActual('react-native');
return {
__esModule: true,
default: ({ onBack }: { title: string; onBack: () => void }) =>
ReactActual.createElement(
View,
{ testID: 'header' },
ReactActual.createElement(Pressable, {
onPress: onBack,
testID: 'header-back-button',
}),
),
};
},
);

jest.mock('../components/Tabs/MusdCalculatorTab/MusdCalculatorTab', () => {
const ReactActual = jest.requireActual('react');
const { View } = jest.requireActual('react-native');
Expand Down
5 changes: 3 additions & 2 deletions app/components/UI/Rewards/Views/MusdCalculatorView.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { HeaderStandard } from '@metamask/design-system-react-native';
import { useNavigation } from '@react-navigation/native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { useTailwind } from '@metamask/design-system-twrnc-preset';
import ErrorBoundary from '../../../Views/ErrorBoundary';
import HeaderCompactStandard from '../../../../component-library/components-temp/HeaderCompactStandard';
import MusdCalculatorTab from '../components/Tabs/MusdCalculatorTab/MusdCalculatorTab';
import { strings } from '../../../../../locales/i18n';
import useTrackRewardsPageView from '../hooks/useTrackRewardsPageView';
Expand All @@ -20,9 +20,10 @@ const MusdCalculatorView: React.FC = () => {
edges={{ top: 'additive' }}
style={tw.style('flex-1 bg-default')}
>
<HeaderCompactStandard
<HeaderStandard
title={strings('rewards.musd.page_title')}
onBack={() => navigation.goBack()}
backButtonProps={{ testID: 'header-back-button' }}
/>
<MusdCalculatorTab />
</SafeAreaView>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ jest.mock('@metamask/design-system-react-native', () => {
const actual = jest.requireActual('@metamask/design-system-react-native');
const ReactActual = jest.requireActual('react');
const { View } = jest.requireActual('react-native');
// Skeleton is absent from the installed design-system version; stub it so
// the loading-state render doesn't throw "Element type is invalid".
const Skeleton = (props: Record<string, unknown>) =>
ReactActual.createElement(View, { testID: 'skeleton', ...props });
return { ...actual, Skeleton };
return {
...actual,
Skeleton,
};
});

jest.mock('@metamask/design-system-twrnc-preset', () => ({
Expand All @@ -64,42 +65,6 @@ jest.mock('@metamask/design-system-twrnc-preset', () => ({
},
}));

jest.mock(
'../../../../component-library/components-temp/HeaderCompactStandard',
() => {
const ReactActual = jest.requireActual('react');
const { View, Text, Pressable } = jest.requireActual('react-native');
return {
__esModule: true,
default: ({
title,
onBack,
endButtonIconProps,
}: {
title: string;
onBack: () => void;
endButtonIconProps?: { testID?: string; onPress?: () => void }[];
}) =>
ReactActual.createElement(
View,
{ testID: 'header' },
ReactActual.createElement(Text, null, title),
ReactActual.createElement(Pressable, {
onPress: onBack,
testID: 'header-back-button',
}),
...(endButtonIconProps ?? []).map((btn, i) =>
ReactActual.createElement(Pressable, {
key: i,
onPress: btn.onPress,
testID: btn.testID ?? `end-button-${i}`,
}),
),
),
};
},
);

jest.mock('../../../Views/ErrorBoundary', () => {
const ReactActual = jest.requireActual('react');
return {
Expand Down Expand Up @@ -1055,7 +1020,7 @@ describe('OndoCampaignDetailsView', () => {
campaigns: [createTestCampaign()],
});
const { getByTestId } = render(<OndoCampaignDetailsView />);
fireEvent.press(getByTestId('header-back-button'));
fireEvent.press(getByTestId('campaign-details-back-button'));
expect(mockGoBack).toHaveBeenCalledTimes(1);
});

Expand Down
Loading
Loading