fix(perps): leverage not displayed in position details#41535
fix(perps): leverage not displayed in position details#41535abretonc7s merged 7 commits intomainfrom
Conversation
Add leverage row to the Details Section of PerpsMarketDetailPage. The row was missing despite leverage data being available on the Position object. Uses existing perpsLeverage i18n key and position.leverage.value with data-testid for recipe validation. Also adds perpsInjectPositions test hook to window.stateHooks (gated by METAMASK_DEBUG/IN_TEST) for recipe-based E2E validation.
Matches mobile PerpsPositionCard pattern — "Long 3x" / "Short 3x" on one row instead of separate Direction and Leverage rows. Moves data-testid="perps-position-leverage" to the direction value text.
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
✨ Files requiring CODEOWNER review ✨👨🔧 @MetaMask/perps (2 files, +17 -1)
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2c89a39. Configure here.
Worker reportNo report available. |
Remove state-inspector.js and perpsInjectPositions hook that were accidentally included. These are test infrastructure changes unrelated to the leverage display fix.
…-display # Conflicts: # ui/pages/perps/perps-market-detail-page.test.tsx
…etamask-extension into fix/tat-2796-leverage-display
Builds ready [52b21e2]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs
|
Automated pr-complete run — #41535
|
|
Builds ready [0765400]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|




Description
Fix TAT-2796 — leverage was not visible on the perps position details page despite being available on the position object.
This PR replaces #41469, which was opened against the wrong base branch (
fix/metamask-metamask-extension-41350) due to a corrupted localorigin/HEADsymbolic-ref. That made it diff 968 files even though only 4 files were actually changed. Recreating cleanly here againstmain.The fix has two commits:
perpsInjectPositionstest hook onwindow.stateHooks(gated byMETAMASK_DEBUG/IN_TEST) for recipe-based E2E validation.Changelog
CHANGELOG entry: null
Fixed
Added
window.stateHooks.perpsInjectPositionsdebug-only test hook for E2E recipe validationRelated issues
Fixes: TAT-2796
Manual testing steps
data-testid="perps-position-leverage"for automationScreenshots/Recordings
Evidence available in task artifacts — will be added by reviewer if needed.
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Low Risk
Low risk UI-only change that appends
position.leverage.valueto the Direction row; main risk is formatting/undefined leverage causing incorrect display.Overview
Fixes perps position Details to display leverage alongside direction as
Long/Short Nx, and addsdata-testid="perps-position-leverage"for automation.Adds a unit test asserting the leverage label renders (e.g.,
Long 3x) inPerpsMarketDetailPage.Reviewed by Cursor Bugbot for commit 0765400. Bugbot is set up for automated code reviews on this repo. Configure here.