Skip to content

Commit 5a68f33

Browse files
committed
fix: all test and remove skip
1 parent a96887b commit 5a68f33

16 files changed

+219
-123
lines changed

app/components/UI/Perps/Views/PerpsTabView/PerpsTabView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ const PerpsTabView: React.FC<PerpsTabViewProps> = () => {
231231
};
232232

233233
return (
234-
<SafeAreaView style={styles.wrapper} edges={['left', 'right']}>
234+
<SafeAreaView style={styles.wrapper} edges={['left', 'right', 'bottom']}>
235235
<>
236236
<PerpsTabControlBar
237237
onManageBalancePress={handleManageBalancePress}

app/components/UI/Perps/utils/e2eBridgePerps.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
* without direct dependencies on E2E files. The bridge automatically
66
* configures itself when the isE2E flag is detected.
77
*/
8-
9-
import { Linking } from 'react-native';
108
import DevLogger from '../../../../core/SDKConnect/utils/DevLogger';
119
import { isE2E } from '../../../../util/test/utils';
1210
import { Linking } from 'react-native';
@@ -196,13 +194,15 @@ export function getE2EMockStreamManager(): unknown {
196194
* Apply controller mocks if available
197195
*/
198196
export function applyE2EControllerMocks(controller: unknown): void {
199-
if (
200-
process.env.IS_TEST === 'true' &&
201-
process.env.METAMASK_ENVIRONMENT === 'e2e'
202-
) {
197+
// Use unified isE2E flag so CI/local runs with either IS_TEST=true or METAMASK_ENVIRONMENT='e2e'
198+
if (isE2E) {
199+
DevLogger.log('[E2E Bridge] Applying E2E PerpsController mocks');
203200
autoConfigureE2EBridge();
204201
if (e2eBridgePerps.applyControllerMocks) {
205202
e2eBridgePerps.applyControllerMocks(controller);
203+
DevLogger.log('[E2E Bridge] PerpsController mocks applied');
204+
} else {
205+
DevLogger.log('[E2E Bridge] applyControllerMocks not available');
206206
}
207207
}
208208
}

e2e/controller-mocking/mock-config/perps-controller-mixin.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import type {
1717
PriceUpdate,
1818
ClosePositionParams,
1919
LiquidationPriceParams,
20+
Funding,
2021
} from '../../../app/components/UI/Perps/controllers/types';
2122
import type { PerpsControllerState } from '../../../app/components/UI/Perps/controllers/PerpsController';
2223

@@ -63,10 +64,14 @@ export class E2EControllerOverrides {
6364
params: LiquidationPriceParams,
6465
): Promise<string> {
6566
const entry = Number(params.entryPrice);
66-
if (Number.isFinite(entry)) {
67-
return entry.toFixed(2);
67+
if (!Number.isFinite(entry)) {
68+
return '0.00';
6869
}
69-
return '0.00';
70+
// Provide deterministic, realistic liquidation distance for E2E:
71+
// Long: 20% below entry, Short: 20% above entry
72+
const isLong = params.direction === 'long';
73+
const liq = isLong ? entry * 0.8 : entry * 1.2;
74+
return liq.toFixed(2);
7075
}
7176

7277
// Mock account state with Redux update

e2e/pages/Perps/PerpsMarketDetailsView.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,16 @@ class PerpsMarketDetailsView {
164164
}
165165

166166
async tapLongButton() {
167-
// Ensure button is enabled before tapping to avoid flaky interactions
168-
await Utilities.waitForElementToBeEnabled(this.longButton as DetoxElement);
169-
await Gestures.waitAndTap(this.longButton);
167+
// Ensure the Long button is rendered and visible, then enabled, then tap
168+
await Utilities.waitForElementToBeVisible(this.longButton, 5000);
169+
await Utilities.waitForElementToBeEnabled(
170+
this.longButton as DetoxElement,
171+
5000,
172+
);
173+
await Gestures.waitAndTap(this.longButton, {
174+
elemDescription: 'Perps Market Details - Long Button',
175+
checkStability: true,
176+
});
170177
}
171178

172179
async tapShortButton() {

e2e/pages/Perps/PerpsMarketListView.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,46 @@ class PerpsMarketListView {
5151
return Matchers.getElementByID(/^perps-market-row-item-.*/, 0);
5252
}
5353

54+
// Generic getter for market row item by index (0-based)
55+
getMarketRowItemAt(index: number) {
56+
return Matchers.getElementByID(/^perps-market-row-item-.*/, index);
57+
}
58+
59+
async getMarketRowItem(symbol: string) {
60+
// Match any element with testID that starts with 'perps-market-row-item-' and get the first one
61+
return await Matchers.getElementByID(`perps-market-row-item-${symbol}`);
62+
}
63+
64+
// Tap specific market by symbol
65+
async tapMarketRowItem(symbol: string) {
66+
const target = Matchers.getElementByID(
67+
getPerpsMarketRowItemSelector.rowItem(symbol),
68+
);
69+
await Gestures.scrollToElement(target, this.scrollableContainer, {
70+
direction: 'down',
71+
scrollAmount: 200,
72+
elemDescription: `Perps Market Row ${symbol}`,
73+
});
74+
await Gestures.waitAndTap(target, {
75+
elemDescription: `Perps Market Row ${symbol}`,
76+
checkStability: true,
77+
});
78+
}
79+
80+
// // Generic action to tap market row item by index (scrolls into view, then taps)
81+
// async tapMarketRowItemAt(index: number) {
82+
// const target = this.getMarketRowItemAt(index);
83+
// await Gestures.scrollToElement(target, this.scrollableContainer, {
84+
// direction: 'down',
85+
// scrollAmount: 200,
86+
// elemDescription: `Perps Market Row at index ${index}`,
87+
// });
88+
// await Gestures.waitAndTap(target, {
89+
// elemDescription: `Perps Market Row at index ${index}`,
90+
// checkStability: true,
91+
// });
92+
// }
93+
5494
get tokenSelectorContainer() {
5595
return Matchers.getElementByID(PerpsTokenSelectorSelectorsIDs.CONTAINER);
5696
}

e2e/pages/Perps/PerpsTabView.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ class PerpsTabView {
1616
}
1717

1818
get onboardingButton(): DetoxElement {
19-
// The onboarding button no longer exposes a testID; select by visible text
20-
return Matchers.getElementByText('Start trading');
19+
return Matchers.getElementByID(PerpsTabViewSelectorsIDs.ONBOARDING_BUTTON);
2120
}
2221

2322
get balanceValue(): DetoxElement {

e2e/pages/Perps/PerpsView.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ class PerpsView {
9494
return Matchers.getElementByText('Limit');
9595
}
9696

97+
get positionsSectionTitle(): DetoxElement {
98+
return Matchers.getElementByText('Positions');
99+
}
100+
97101
async expectOpenOrdersOnTab(): Promise<void> {
98102
await Assertions.expectElementToBeVisible(this.ordersSectionTitle, {
99103
description: 'Perps tab shows Open Orders section',
@@ -103,6 +107,12 @@ class PerpsView {
103107
});
104108
}
105109

110+
async expectOpenPositionsOnTab(): Promise<void> {
111+
await Assertions.expectElementToBeVisible(this.positionsSectionTitle, {
112+
description: 'Perps tab shows Open Positions section',
113+
});
114+
}
115+
106116
getTakeProfitPercentageButton(percentage: number) {
107117
// Support legacy tests passing index (1..4) by mapping to actual ROE%
108118
// TP quick buttons: [10, 25, 50, 100]

e2e/pages/wallet/TabBarComponent.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ class TabBarComponent {
1919
return Matchers.getElementByID(TabBarSelectorIDs.TRADE);
2020
}
2121

22+
get tabBarTradeButton(): DetoxElement {
23+
return Matchers.getElementByID(TabBarSelectorIDs.TRADE);
24+
}
25+
2226
get tabBarSettingButton(): DetoxElement {
2327
return Matchers.getElementByID(TabBarSelectorIDs.SETTING);
2428
}
@@ -40,6 +44,11 @@ class TabBarComponent {
4044
);
4145
}
4246

47+
async tapHome(): Promise<void> {
48+
const homeButton = Matchers.getElementByText('Home');
49+
await Gestures.waitAndTap(homeButton);
50+
}
51+
4352
async tapWallet(): Promise<void> {
4453
await Utilities.executeWithRetry(
4554
async () => {
@@ -59,6 +68,12 @@ class TabBarComponent {
5968
});
6069
}
6170

71+
async tapTrade(): Promise<void> {
72+
await Gestures.waitAndTap(this.tabBarTradeButton, {
73+
elemDescription: 'Tab Bar - Trade Button',
74+
});
75+
}
76+
6277
async tapSettings(): Promise<void> {
6378
await Utilities.executeWithRetry(
6479
async () => {

e2e/pages/wallet/WalletActionsBottomSheet.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ class WalletActionsBottomSheet {
5050
);
5151
}
5252

53-
53+
get startANewTradeButton(): DetoxElement {
54+
return Matchers.getElementByID(
55+
WalletActionsBottomSheetSelectorsIDs.START_A_NEW_TRADE_BUTTON,
56+
);
57+
}
58+
5459
async tapSendButton(): Promise<void> {
5560
await Gestures.waitAndTap(this.sendButton);
5661
}
@@ -86,6 +91,10 @@ class WalletActionsBottomSheet {
8691
async tapPredictButton(): Promise<void> {
8792
await Gestures.waitAndTap(this.predictButton);
8893
}
94+
95+
async tapStartANewTradeButton(): Promise<void> {
96+
await Gestures.waitAndTap(this.startANewTradeButton);
97+
}
8998

9099
async swipeDownActionsBottomSheet(): Promise<void> {
91100
await Gestures.swipe(this.sendButton, 'down', {

e2e/selectors/wallet/TabBar.selectors.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export const TabBarSelectorIDs = {
22
WALLET: 'tab-bar-item-Wallet',
33
BROWSER: 'tab-bar-item-Browser',
44
ACTIONS: 'trade-tab-bar-item-icon-container',
5+
TRADE: 'tab-bar-item-Trade',
56
SETTING: 'tab-bar-item-Setting',
67
ACTIVITY: 'tab-bar-item-Activity',
78
TRADE: 'tab-bar-item-Trade',

0 commit comments

Comments
 (0)