Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
274 commits
Select commit Hold shift + click to select a range
530853f
docs: align doc format
abretonc7s Oct 9, 2025
99fd17e
feat: align error handling with perps controller
abretonc7s Oct 9, 2025
e08d8cc
Merge branch 'main' into feat/perps/optimize-connection
abretonc7s Oct 9, 2025
c2eff03
improved reconnection flow
abretonc7s Oct 9, 2025
2c5661b
restore test
abretonc7s Oct 9, 2025
b2a689c
fix: unit test coverage
abretonc7s Oct 9, 2025
48c6d94
fix: pr comments
abretonc7s Oct 9, 2025
584798d
Merge branch 'main' into feat/perps/optimize-connection
nickewansmith Oct 9, 2025
6aade3b
Merge branch 'main' into feat/perps/optimize-connection
abretonc7s Oct 10, 2025
c48089e
Merge branch 'feat/perps/optimize-connection' into feat/perps/optimiz…
abretonc7s Oct 10, 2025
fe35821
tsc
abretonc7s Oct 10, 2025
c7dd106
Merge remote-tracking branch 'origin/main' into feat/perps/optimize-c…
abretonc7s Oct 10, 2025
cadf787
add coverage
abretonc7s Oct 10, 2025
c01e407
feat: add sentry error identifier
abretonc7s Oct 10, 2025
fc48aec
feat: restore test deletion
abretonc7s Oct 10, 2025
7771256
fix: unit tests
abretonc7s Oct 10, 2025
60abffe
feat: update sentry doc
abretonc7s Oct 10, 2025
0644bde
:Merge remote-tracking branch 'origin/main' into feat/perps/optimize-…
abretonc7s Oct 10, 2025
05c7d5f
fix: pr comments
abretonc7s Oct 10, 2025
d5be820
Merge remote-tracking branch 'origin/main' into feat/perps/optimize-c…
abretonc7s Oct 10, 2025
2af9146
fix: missing reward discount when closing position
abretonc7s Oct 10, 2025
9a10f0e
fix: unit tests coverage
abretonc7s Oct 10, 2025
38749b5
Merge remote-tracking branch 'origin/main' into feat/perps/optimize-c…
abretonc7s Oct 10, 2025
1604de6
Merge remote-tracking branch 'origin/main' into feat/perps/optimize-c…
abretonc7s Oct 10, 2025
107daff
Merge remote-tracking branch 'origin/main' into feat/perps/optimize-c…
abretonc7s Oct 11, 2025
0ff076f
fix: pr comments
abretonc7s Oct 11, 2025
96f07e8
fix: critical type safety issue in tracing system
abretonc7s Oct 11, 2025
20c4e04
fix: unit tests
abretonc7s Oct 11, 2025
913cd9e
cleanup
abretonc7s Oct 11, 2025
0657495
fix: revert uistartup change
abretonc7s Oct 11, 2025
92cad89
fix: unit test
abretonc7s Oct 11, 2025
1cab419
Merge remote-tracking branch 'origin/main' into fix/sentry-type
abretonc7s Oct 11, 2025
86bc422
fix: unit tests
abretonc7s Oct 11, 2025
038af28
fix; discount emission on perps
abretonc7s Oct 11, 2025
ce9ba81
fix: unit tests
abretonc7s Oct 11, 2025
ba0a301
fix: pr comments
abretonc7s Oct 11, 2025
2eb19aa
cleanup
abretonc7s Oct 11, 2025
f9b844a
Merge remote-tracking branch 'origin/fix/sentry-type' into feat/perps…
abretonc7s Oct 13, 2025
7e75c0c
wip
abretonc7s Oct 13, 2025
4774327
Merge remote-tracking branch 'origin/main' into feat/perps/optimize-c…
abretonc7s Oct 13, 2025
101029b
Merge remote-tracking branch 'origin/main' into feat/perps/optimize-c…
abretonc7s Oct 14, 2025
d0938d3
cleanup
abretonc7s Oct 14, 2025
f8b7448
cleanup
abretonc7s Oct 14, 2025
ca00011
Merge remote-tracking branch 'origin/main' into feat/perps/optimize-c…
abretonc7s Oct 14, 2025
4a25877
feat(perps): migrate to latest hyperliquid sdk
abretonc7s Oct 14, 2025
7fe6baa
Merge branch 'main' into feat/perps/optimize-connection2
abretonc7s Oct 14, 2025
c9ee08a
Merge branch 'feat/perps/optimize-connection2' into feat/perps/hypers…
abretonc7s Oct 14, 2025
abf607e
feat: remove ws package
abretonc7s Oct 14, 2025
fc63ab9
cleanup
abretonc7s Oct 14, 2025
f36f5f9
cleanup
abretonc7s Oct 14, 2025
ca8ba8e
cleanup
abretonc7s Oct 14, 2025
db00eee
Merge branch 'main' into feat/perps/optimize-connection2
abretonc7s Oct 14, 2025
25ffbb4
Merge branch 'feat/perps/optimize-connection2' into feat/perps/hypers…
abretonc7s Oct 14, 2025
3045eac
Merge remote-tracking branch 'origin/main' into feat/perps/hypersdk-u…
abretonc7s Oct 15, 2025
1c83ad6
fix: merge conflicts
abretonc7s Oct 15, 2025
974d228
cleanup
abretonc7s Oct 15, 2025
0c53ed4
Merge branch 'main' into feat/perps/hypersdk-update
abretonc7s Oct 15, 2025
54cbf66
merge main into branch
abretonc7s Oct 15, 2025
f25a938
fix: restore main behavior on formatting auto merged
abretonc7s Oct 15, 2025
765a190
cleanup + sonarcloud
abretonc7s Oct 15, 2025
27eccc6
Merge branch 'main' into feat/perps/hypersdk-update
abretonc7s Oct 16, 2025
9db3a9d
feat(perps): HIP-3 support
abretonc7s Oct 15, 2025
336ed06
feat: baseline for equity perps
abretonc7s Oct 16, 2025
72bdddf
feat: hyperliquid docs embedded for llm
abretonc7s Oct 16, 2025
1e30bf1
feat: ui changes for hip3
abretonc7s Oct 17, 2025
6e0ee07
working state with tpsl live
abretonc7s Oct 17, 2025
475f9ea
Merge remote-tracking branch 'origin/main' into perps/feat/hip3
abretonc7s Oct 17, 2025
ed9fa95
cleanup
abretonc7s Oct 17, 2025
a2462a7
cleanup
abretonc7s Oct 17, 2025
92bb3bb
cleanup
abretonc7s Oct 17, 2025
30b8196
fix: unit tests
abretonc7s Oct 17, 2025
63e4c05
Merge remote-tracking branch 'origin/main' into perps/feat/hip3
abretonc7s Oct 17, 2025
7506420
fix: bugbot
abretonc7s Oct 17, 2025
3883a6d
cleanup removing magic nums
abretonc7s Oct 17, 2025
5427dcc
Merge branch 'main' into perps/feat/hip3
abretonc7s Oct 17, 2025
4f462e2
fix: linting issues
abretonc7s Oct 17, 2025
508db46
Merge remote-tracking branch 'origin/main' into perps/feat/hip3
abretonc7s Oct 17, 2025
b763e7e
Merge branch 'main' into perps/feat/hip3
abretonc7s Oct 17, 2025
a198721
feat: styling badges
abretonc7s Oct 17, 2025
43c1377
Merge remote-tracking branch 'origin/main' into perps/feat/hip3
abretonc7s Oct 17, 2025
d7ad7fd
cleanup
abretonc7s Oct 17, 2025
fdd64f2
fix: bugbot comment
abretonc7s Oct 17, 2025
62d4844
cleanup
abretonc7s Oct 17, 2025
7e894cd
cleanup
abretonc7s Oct 17, 2025
fc44971
cleanup
abretonc7s Oct 17, 2025
ae84278
cleanup
abretonc7s Oct 17, 2025
8c37f19
cleanup
abretonc7s Oct 18, 2025
e4534d5
feat: re-enable hip3 debug page for testing
abretonc7s Oct 18, 2025
5e3d962
feat: cleanup
abretonc7s Oct 18, 2025
1659d34
cleanup
abretonc7s Oct 18, 2025
e19ea08
feat: feature flag improvement and controller init
abretonc7s Oct 18, 2025
78fd8a5
cleanup
abretonc7s Oct 18, 2025
bd41a38
Merge remote-tracking branch 'origin/main' into perps/feat/hip3
abretonc7s Oct 18, 2025
a0b4f93
feat: pr commentS
abretonc7s Oct 18, 2025
f24cde9
fix: unit tests
abretonc7s Oct 18, 2025
cb72ebe
feat: change default equityEnabled flag to true on dev only
abretonc7s Oct 18, 2025
6101ff7
fix: unit test
abretonc7s Oct 18, 2025
3626732
fix: unit tests
abretonc7s Oct 19, 2025
b043c90
Merge remote-tracking branch 'origin/main' into perps/feat/hip3
abretonc7s Oct 19, 2025
444a778
fix: sonarcloud issues
abretonc7s Oct 20, 2025
3dbfa8e
fix: linting
abretonc7s Oct 20, 2025
73f49a2
fix: sonarcloud
abretonc7s Oct 20, 2025
8009689
fix: sonarcloud
abretonc7s Oct 20, 2025
bd101be
cleanup
abretonc7s Oct 20, 2025
414ac82
cleanup
abretonc7s Oct 20, 2025
fcf1b90
feat: cleanup
abretonc7s Oct 20, 2025
e105321
feat: tat-1784
abretonc7s Oct 20, 2025
4995b09
cleanup
abretonc7s Oct 20, 2025
3941ae4
cleanup
abretonc7s Oct 20, 2025
5a78f1d
coverage
abretonc7s Oct 20, 2025
b27539a
coverage
abretonc7s Oct 20, 2025
3c25c10
feat: coverage
abretonc7s Oct 20, 2025
30b8cb2
feat(perps): add home screen v2, market sorting, and batch operations
abretonc7s Oct 20, 2025
3fb838b
cleanup
abretonc7s Oct 20, 2025
4b84e86
cleanup
abretonc7s Oct 20, 2025
084ab76
Merge remote-tracking branch 'origin/main' into perps/feat/newhome
abretonc7s Oct 20, 2025
a50b02f
cleanup
abretonc7s Oct 20, 2025
1d31c0c
fix: unit test
abretonc7s Oct 21, 2025
b8569b6
Merge remote-tracking branch 'origin/main' into perps/feat/hip3
abretonc7s Oct 21, 2025
f6045f9
pr comment
abretonc7s Oct 21, 2025
08dcf2a
feat: add error handling to perpsdex
abretonc7s Oct 21, 2025
d419893
fix: overfund dex to allow acreating new position over existing
abretonc7s Oct 21, 2025
2d64d89
merge main into branch
abretonc7s Oct 21, 2025
b215768
Merge remote-tracking branch 'origin/main' into perps/feat/newhome
abretonc7s Oct 21, 2025
9463495
fix: cleanup
abretonc7s Oct 21, 2025
030fd8c
Merge remote-tracking branch 'origin/main' into perps/feat/hip3
abretonc7s Oct 21, 2025
d3084e3
testing auto transfer
abretonc7s Oct 21, 2025
fa70e99
feat: hip3 abstraction support
abretonc7s Oct 22, 2025
6630ac5
Merge remote-tracking branch 'origin/main' into perps/feat/hip3
abretonc7s Oct 22, 2025
587a803
fix: tpsl matching
abretonc7s Oct 22, 2025
1a77586
Merge remote-tracking branch 'origin/main' into perps/feat/hip3
abretonc7s Oct 22, 2025
3158234
merge main into branch
abretonc7s Oct 22, 2025
4ed3262
feat: utility funciton to determine maker status
abretonc7s Oct 22, 2025
5a2e743
Merge remote-tracking branch 'origin/main' into perps/feat/newhome
abretonc7s Oct 22, 2025
46f27df
merge hip3 into branch
abretonc7s Oct 22, 2025
b61a6e7
Merge remote-tracking branch 'origin/main' into perps/feat/newhome
abretonc7s Oct 22, 2025
6d4eb28
feat(sentry): add searchable tags and context to Logger.error
abretonc7s Oct 22, 2025
cc8e4b8
feat: add unit tests
abretonc7s Oct 22, 2025
b050c5e
Merge branch 'main' into feat/sentry-tags
abretonc7s Oct 22, 2025
d28cb27
feat: closing all positions
abretonc7s Oct 22, 2025
c562003
Merge remote-tracking branch 'origin/main' into perps/feat/newhome
abretonc7s Oct 22, 2025
924e55d
fix: unit testS
abretonc7s Oct 22, 2025
e641b77
Merge remote-tracking branch 'origin/main' into feat/sentry-tags
abretonc7s Oct 22, 2025
5f8e38c
fix: coverage
abretonc7s Oct 22, 2025
75e04fa
Merge remote-tracking branch 'origin/main' into perps/feat/newhome
abretonc7s Oct 22, 2025
59454c2
feat: refactor for unit test coverage
abretonc7s Oct 22, 2025
f784504
Merge remote-tracking branch 'origin/main' into perps/feat/newhome
abretonc7s Oct 22, 2025
585f53c
Merge branch 'main' into feat/sentry-tags
abretonc7s Oct 22, 2025
51d52c7
fix: unit tests
abretonc7s Oct 23, 2025
4ee38c9
feat: handle legazy format
abretonc7s Oct 23, 2025
6a984fc
fix(perps): improve error handling and navigation safety
abretonc7s Oct 23, 2025
58484b9
Merge remote-tracking branch 'origin/main' into perps/feat/newhome
abretonc7s Oct 23, 2025
400e985
Merge branch 'main' into feat/sentry-tags
abretonc7s Oct 23, 2025
3aec352
feat: unit test
abretonc7s Oct 23, 2025
fa73e99
merge main into branch
abretonc7s Oct 23, 2025
47ec3a4
Merge branch 'main' into feat/sentry-tags
abretonc7s Oct 23, 2025
1c21a67
Merge branch 'feat/sentry-tags' into perps/feat/newhome
abretonc7s Oct 23, 2025
35da86c
fix: resolve duplicate symbol display and invalid concurrency test
abretonc7s Oct 23, 2025
0285ffc
fix: unit test and linting
abretonc7s Oct 23, 2025
c4161d2
feat(perps): add watchlist feature
abretonc7s Oct 23, 2025
9e635dc
feat: watchlist support and unit tests
abretonc7s Oct 23, 2025
df92ac4
fix: unit tests
abretonc7s Oct 23, 2025
b198643
Merge remote-tracking branch 'origin/main' into perps/feat/newhome
abretonc7s Oct 23, 2025
3a208d1
fix: unit tests
abretonc7s Oct 23, 2025
1d1a490
feat: compute points based on currentprice not entryprice
abretonc7s Oct 23, 2025
f9ce580
feat: styling
abretonc7s Oct 23, 2025
468c28a
feat: perps tab card navigation on everytabs
abretonc7s Oct 23, 2025
f3a0fc9
fix: bugbot
abretonc7s Oct 23, 2025
02338de
fix: unit tests
abretonc7s Oct 24, 2025
2c2543a
Merge remote-tracking branch 'origin/main' into perps/feat/newhome
abretonc7s Oct 24, 2025
5d9ff5c
feat: support leverage trading preferences
abretonc7s Oct 24, 2025
6da818b
coverage
abretonc7s Oct 24, 2025
ae77ca1
feat: coverage and disable pull to refresh
abretonc7s Oct 24, 2025
6d52233
feat: add loading indicator while loading fees
abretonc7s Oct 24, 2025
1ccfea1
fix: perps recent activity list
abretonc7s Oct 24, 2025
fc3378c
feat: trending sorting page
abretonc7s Oct 24, 2025
4f60c95
feat: persisting trending sort preferences
abretonc7s Oct 24, 2025
3d61056
fix: unit tests
abretonc7s Oct 24, 2025
cda90d2
fix: merge main into branch
abretonc7s Oct 24, 2025
e65c21c
fix: unit test + linting
abretonc7s Oct 24, 2025
4d104c5
fix: coverage
abretonc7s Oct 24, 2025
74af03e
merge main into branch
abretonc7s Oct 24, 2025
3e2d8fe
cleanup
abretonc7s Oct 24, 2025
ee6f2da
styling
abretonc7s Oct 24, 2025
fcdb832
fix: unit tests
abretonc7s Oct 24, 2025
b409dbe
Merge remote-tracking branch 'origin/main' into perps/feat/newhome
abretonc7s Oct 24, 2025
8d56b9f
feat: improve caching access
abretonc7s Oct 24, 2025
1aa44b8
feat: merge main into branch
abretonc7s Oct 24, 2025
7bdfed5
feat: perps card nav under tab
abretonc7s Oct 24, 2025
7bee93a
feat; unit tests
abretonc7s Oct 24, 2025
b306b70
Merge remote-tracking branch 'origin/main' into perps/feat/newhome
abretonc7s Oct 24, 2025
9ffe3ee
docs: improvements
abretonc7s Oct 24, 2025
e595d9c
fix: linting
abretonc7s Oct 24, 2025
d51f61a
fix: unit test
abretonc7s Oct 24, 2025
c7d6544
feat: use e2e selectors for testids
abretonc7s Oct 24, 2025
de2062a
Merge remote-tracking branch 'origin/main' into perps/feat/newhome
abretonc7s Oct 24, 2025
42c8da3
fix: unit tests
abretonc7s Oct 24, 2025
45e7738
shared styles to avoid duplication
abretonc7s Oct 24, 2025
9ceace9
feat: unit test
abretonc7s Oct 24, 2025
fd20d23
sonarcloud
abretonc7s Oct 24, 2025
0088255
sonarcloud
abretonc7s Oct 24, 2025
8eb61e4
sonarcloud
abretonc7s Oct 24, 2025
4a4f55e
cleanup
abretonc7s Oct 24, 2025
45f4a13
Merge remote-tracking branch 'origin/main' into perps/feat/newhome
abretonc7s Oct 24, 2025
c889f25
cleanup
abretonc7s Oct 24, 2025
0c5019e
Merge remote-tracking branch 'origin/main' into perps/feat/newhome
abretonc7s Oct 24, 2025
a7b5fa1
merge main into branch
abretonc7s Oct 25, 2025
03593d9
feat: cleanup
abretonc7s Oct 25, 2025
dd8687d
feat: optimize batch cancel close orders positions
abretonc7s Oct 26, 2025
44834e0
feat: improved loaders in home screen
abretonc7s Oct 26, 2025
e251d6c
feat: perps home view styling with market list
abretonc7s Oct 26, 2025
037feac
feat: simplify perps route for consistency
abretonc7s Oct 26, 2025
81f3e71
feat: cleanup ui component
abretonc7s Oct 26, 2025
460651d
feat: improved ui refactor with watchlist toggle
abretonc7s Oct 26, 2025
1aabf79
styling
abretonc7s Oct 26, 2025
04bfd5f
fix: prevent invalid points computation
abretonc7s Oct 26, 2025
fb6b8fe
fix: unit tests
abretonc7s Oct 26, 2025
66fc926
fix: linting
abretonc7s Oct 27, 2025
a8c9807
feat: navigation via hooks
abretonc7s Oct 27, 2025
fce6d64
fix: bugbot
abretonc7s Oct 27, 2025
359ad8a
fix: unit test coverage
abretonc7s Oct 27, 2025
34e39da
feat: improved leverage validation
abretonc7s Oct 27, 2025
df225d0
fix: unit tests
abretonc7s Oct 27, 2025
c03548b
fix: unit tests
abretonc7s Oct 27, 2025
f75bda9
fix: unit tests
abretonc7s Oct 27, 2025
15b1f99
fix: unit test coverage
abretonc7s Oct 27, 2025
8e1b707
fix: unit tests
abretonc7s Oct 27, 2025
21322a2
fix: unit tests
abretonc7s Oct 27, 2025
6dbf89e
fix: coverage
abretonc7s Oct 27, 2025
a811309
fix: sonarcloud
abretonc7s Oct 27, 2025
c8aed6c
feat: use crypto instead of perps
abretonc7s Oct 27, 2025
9718b58
Merge remote-tracking branch 'origin/main' into perps/feat/newhome
abretonc7s Oct 27, 2025
27943d1
fix: bugbot
abretonc7s Oct 27, 2025
5197e30
feat: hide bottom nav on marketlist
abretonc7s Oct 27, 2025
67d4967
feat: remove watchlist from sort fields
abretonc7s Oct 27, 2025
705e954
chore: Merge main, address conflicts
gambinish Oct 27, 2025
0761119
Merge branch 'main' into perps/feat/newhome
gambinish Oct 27, 2025
cb57664
test(predict): add cash out position e2e (#21545)
cortisiko Oct 27, 2025
4fa26b1
chore: revert hardcoded fingerprint (#21617)
tommasini Oct 27, 2025
0d0e740
fix(INFRA-3066): path based rebuilds (#21747)
bsgrigorov Oct 27, 2025
bf02d2f
cleanup
abretonc7s Oct 28, 2025
cac904d
Merge branch 'main' into perps/feat/newhome
abretonc7s Oct 28, 2025
101c520
Merge remote-tracking branch 'origin/main' into perps/feat/newhome
abretonc7s Oct 28, 2025
af3a14a
reset to main
abretonc7s Oct 28, 2025
40f210b
reset to main
abretonc7s Oct 28, 2025
95b8c02
reset to main
abretonc7s Oct 28, 2025
b20e6da
reset to main
abretonc7s Oct 28, 2025
dbc377d
Merge remote-tracking branch 'origin/main' into perps/feat/newhome
abretonc7s Oct 28, 2025
a9037c8
Merge remote-tracking branch 'origin/main' into perps/feat/newhome
abretonc7s Oct 28, 2025
e16e93f
feat(perps): specific hip-3 fees
abretonc7s Oct 28, 2025
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
2 changes: 1 addition & 1 deletion app/components/UI/Navbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1945,7 +1945,7 @@ export function getPerpsMarketDetailsNavbar(navigation, title) {
},
});
// Always navigate back to markets page for consistent navigation
const leftAction = () => navigation.navigate(Routes.PERPS.MARKETS);
const leftAction = () => navigation.navigate(Routes.PERPS.PERPS_HOME);

return {
headerTitle: () => (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { StyleSheet } from 'react-native';
import type { Theme } from '../../../../../util/theme/models';

export const createStyles = (_theme: Theme) =>
StyleSheet.create({
contentContainer: {
paddingHorizontal: 16,
paddingVertical: 16,
},
loadingContainer: {
paddingVertical: 32,
alignItems: 'center',
justifyContent: 'center',
},
loadingText: {
marginTop: 12,
},
emptyContainer: {
paddingVertical: 32,
paddingHorizontal: 16,
alignItems: 'center',
justifyContent: 'center',
},
footerContainer: {
paddingHorizontal: 16,
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
import React from 'react';
import { render } from '@testing-library/react-native';
import PerpsCancelAllOrdersView from './PerpsCancelAllOrdersView';
import { usePerpsCancelAllOrders, usePerpsLiveOrders } from '../../hooks';

// Mock all dependencies
jest.mock('@react-navigation/native', () => ({
useNavigation: jest.fn(() => ({ navigate: jest.fn(), goBack: jest.fn() })),
}));

jest.mock('../../../../../../locales/i18n', () => ({
strings: jest.fn((key: string) => key),
}));

jest.mock('../../hooks', () => ({
usePerpsLiveOrders: jest.fn(),
usePerpsCancelAllOrders: jest.fn(),
}));

jest.mock('../../hooks/usePerpsToasts', () => ({
__esModule: true,
default: jest.fn(() => ({ showToast: jest.fn() })),
}));

jest.mock('../../../../../util/theme', () => ({
useTheme: jest.fn(() => ({
colors: {
accent03: { normal: '#00ff00', dark: '#008800' },
accent01: { light: '#ffcccc', dark: '#cc0000' },
primary: { default: '#0000ff' },
background: { default: '#ffffff' },
},
})),
}));

jest.mock('../../hooks/usePerpsEventTracking', () => ({
usePerpsEventTracking: jest.fn(),
}));

jest.mock(
'../../../../../component-library/components/BottomSheets/BottomSheet',
() => {
const mockReact = jest.requireActual<typeof React>('react');
return mockReact.forwardRef(
(props: { children: React.ReactNode }, _ref) => <>{props.children}</>,
);
},
);

jest.mock(
'../../../../../component-library/components/BottomSheets/BottomSheetHeader',
() => 'BottomSheetHeader',
);

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

return {
__esModule: true,
default: ({
buttonPropsArray,
}: {
buttonPropsArray?: {
label: string;
onPress: () => void;
disabled?: boolean;
}[];
}) => (
<View>
{buttonPropsArray?.map((buttonProps, index) => (
<TouchableOpacity
key={index}
onPress={buttonProps.onPress}
disabled={buttonProps.disabled}
>
<Text>{buttonProps.label}</Text>
</TouchableOpacity>
))}
</View>
),
ButtonsAlignment: {
Horizontal: 'Horizontal',
Vertical: 'Vertical',
},
};
},
);

const mockUsePerpsLiveOrders = usePerpsLiveOrders as jest.MockedFunction<
typeof usePerpsLiveOrders
>;
const mockUsePerpsCancelAllOrders =
usePerpsCancelAllOrders as jest.MockedFunction<
typeof usePerpsCancelAllOrders
>;

describe('PerpsCancelAllOrdersView', () => {
const mockOrders = [
{
orderId: 'order-1',
symbol: 'BTC',
side: 'buy' as const,
orderType: 'limit' as const,
size: '0.1',
originalSize: '0.1',
price: '50000',
filledSize: '0',
remainingSize: '0.1',
status: 'open' as const,
timestamp: Date.now(),
},
{
orderId: 'order-2',
symbol: 'ETH',
side: 'sell' as const,
orderType: 'limit' as const,
size: '1.0',
originalSize: '1.0',
price: '3000',
filledSize: '0',
remainingSize: '1.0',
status: 'open' as const,
timestamp: Date.now(),
},
];

const mockCancelAllHook = {
isCanceling: false,
orderCount: 2,
handleCancelAll: jest.fn(),
handleKeepOrders: jest.fn(),
error: null,
};

beforeEach(() => {
jest.clearAllMocks();
mockUsePerpsLiveOrders.mockReturnValue({
orders: mockOrders,
isInitialLoading: false,
});
mockUsePerpsCancelAllOrders.mockReturnValue(mockCancelAllHook);
});

it('renders cancel all orders view with orders', () => {
// Arrange & Act
const { getByText } = render(<PerpsCancelAllOrdersView />);

// Assert
expect(getByText('perps.cancel_all_modal.title')).toBeTruthy();
expect(getByText('perps.cancel_all_modal.description')).toBeTruthy();
});

it('renders empty state when no orders', () => {
// Arrange
mockUsePerpsLiveOrders.mockReturnValue({
orders: [],
isInitialLoading: false,
});
mockUsePerpsCancelAllOrders.mockReturnValue({
...mockCancelAllHook,
orderCount: 0,
});

// Act
const { getByText } = render(<PerpsCancelAllOrdersView />);

// Assert
expect(getByText('perps.order.no_orders')).toBeTruthy();
});

it('renders loading state when canceling', () => {
// Arrange
mockUsePerpsCancelAllOrders.mockReturnValue({
...mockCancelAllHook,
isCanceling: true,
});

// Act
const { getAllByText } = render(<PerpsCancelAllOrdersView />);

// Assert
const cancelingElements = getAllByText('perps.cancel_all_modal.canceling');
expect(cancelingElements.length).toBeGreaterThan(0);
});

it('displays footer buttons with correct labels', () => {
// Arrange & Act
const { getByText } = render(<PerpsCancelAllOrdersView />);

// Assert
expect(getByText('perps.cancel_all_modal.keep_orders')).toBeTruthy();
expect(getByText('perps.cancel_all_modal.confirm')).toBeTruthy();
});

it('shows canceling label on confirm button when in progress', () => {
// Arrange
mockUsePerpsCancelAllOrders.mockReturnValue({
...mockCancelAllHook,
isCanceling: true,
});

// Act
const { getAllByText } = render(<PerpsCancelAllOrdersView />);

// Assert
const cancelingElements = getAllByText('perps.cancel_all_modal.canceling');
expect(cancelingElements.length).toBeGreaterThan(0);
});

it('renders with empty orders gracefully', () => {
// Arrange
mockUsePerpsLiveOrders.mockReturnValue({
orders: [],
isInitialLoading: false,
});
mockUsePerpsCancelAllOrders.mockReturnValue({
...mockCancelAllHook,
orderCount: 0,
});

// Act
const { getByText } = render(<PerpsCancelAllOrdersView />);

// Assert
expect(getByText('perps.order.no_orders')).toBeTruthy();
});
});
Loading
Loading