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 @@ -41,6 +41,7 @@ jest.mock(

// Mock hooks (consolidated to avoid conflicts)
const mockNavigateBack = jest.fn();
const mockNavigateToWallet = jest.fn();
const mockNavigateToMarketList = jest.fn();
jest.mock('../../hooks', () => ({
usePerpsHomeData: jest.fn(),
Expand All @@ -49,6 +50,7 @@ jest.mock('../../hooks', () => ({
navigateTo: jest.fn(),
navigateToMarketDetails: jest.fn(),
navigateToMarketList: mockNavigateToMarketList,
navigateToWallet: mockNavigateToWallet,
navigateBack: mockNavigateBack,
goBack: jest.fn(),
})),
Expand Down Expand Up @@ -392,6 +394,7 @@ describe('PerpsHomeView', () => {
beforeEach(() => {
jest.clearAllMocks();
mockNavigateBack.mockClear();
mockNavigateToWallet.mockClear();
mockNavigateToMarketList.mockClear();
mockUsePerpsHomeData.mockReturnValue(mockDefaultData);
});
Expand Down Expand Up @@ -537,15 +540,15 @@ describe('PerpsHomeView', () => {
expect(queryByText('perps.home.orders')).toBeNull();
});

it('handles back button press', () => {
it('navigates to wallet home when back button is pressed', () => {
// Arrange
const { getByTestId } = render(<PerpsHomeView />);

// Act
fireEvent.press(getByTestId('back-button'));

// Assert
expect(mockNavigateBack).toHaveBeenCalled();
// Assert - Always navigates to wallet home to avoid loops (e.g., from tutorial)
expect(mockNavigateToWallet).toHaveBeenCalled();
});

it('navigates to close all modal when close all is pressed', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,9 @@ const PerpsHomeView = () => {
setShowCancelAllSheet(false);
}, []);

// Back button handler - now uses navigation hook
const handleBackPress = perpsNavigation.navigateBack;
// Back button handler - always navigate to wallet home to avoid loops
// (e.g., when coming from tutorial/onboarding flow)
const handleBackPress = perpsNavigation.navigateToWallet;

return (
<SafeAreaView style={styles.container}>
Expand Down
Loading