Skip to content

test: cv test add perps coverage#30185

Merged
racitores merged 5 commits into
mainfrom
raci/cvtest-perps-coverage
May 20, 2026
Merged

test: cv test add perps coverage#30185
racitores merged 5 commits into
mainfrom
raci/cvtest-perps-coverage

Conversation

@racitores

@racitores racitores commented May 14, 2026

Copy link
Copy Markdown
Contributor

Description

Adds Perps Component View coverage as part of the E2E to CV migration work. The new coverage focuses on product-visible Perps trading and account-management rules instead of mirroring Detox steps directly.

This PR adds CV tests for:

  • PerpsOrderView: submitting a market long after reviewing calculated order details; switching to a limit order, using the Mid preset, and routing to TP/SL setup; blocking order submission when the account cannot satisfy the minimum order amount; and routing cross-margin positions to the warning modal instead of placing an order.
  • PerpsCloseAllPositionsView: confirming bulk close for all open positions and ensuring the destructive close action is not exposed when there are no open positions.
  • PerpsCancelAllOrdersView: confirming bulk cancellation for all open orders and ensuring the destructive cancel action is not exposed when there are no open orders.
  • PerpsWithdrawView: showing withdrawal quote details, submitting a max withdrawal, blocking too-small withdrawals with the minimum amount error, and keeping withdrawal unavailable when there is no withdrawable balance.

It also extends the Perps CV test framework support with:

  • mutable stream controls for account, market, order, position, and price updates;
  • a Perps renderer for PerpsOrderView;
  • QueryClient and hardware-wallet provider coverage in the shared Perps renderer;
  • Perps controller mock methods needed by the migrated CV tests;
  • Perps preset state needed by confirmation/payment-dependent views.

Changelog

CHANGELOG entry: null

Related issues

Related: https://consensyssoftware.atlassian.net/browse/MMQA-1723

Manual testing steps

Test-only change. Verified with:

yarn eslint app/components/UI/Perps/Views/PerpsCancelAllOrdersView/PerpsCancelAllOrdersView.view.test.tsx app/components/UI/Perps/Views/PerpsCloseAllPositionsView/PerpsCloseAllPositionsView.view.test.tsx app/components/UI/Perps/Views/PerpsOrderView/PerpsOrderView.view.test.tsx app/components/UI/Perps/Views/PerpsWithdrawView/PerpsWithdrawView.view.test.tsx

yarn jest -c jest.config.view.js app/components/UI/Perps/Views/PerpsCancelAllOrdersView/PerpsCancelAllOrdersView.view.test.tsx app/components/UI/Perps/Views/PerpsCloseAllPositionsView/PerpsCloseAllPositionsView.view.test.tsx app/components/UI/Perps/Views/PerpsOrderView/PerpsOrderView.view.test.tsx app/components/UI/Perps/Views/PerpsWithdrawView/PerpsWithdrawView.view.test.tsx --runInBand --silent --coverage=false

Result: 4 test suites passed, 11 tests passed.

Screenshots/Recordings

Not applicable. Test-only change.

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Low Risk
Low risk since changes are test-only, but they expand shared component-view mocks/presets and renderer providers, which could cause broader test instability if assumptions differ across suites.

Overview
Adds new Perps component-view tests covering key trading/account-management flows: placing orders (market and limit with TP/SL routing), bulk cancelling orders, bulk closing positions, and withdrawals (max/min/zero-balance validation).

Extends the Perps CV test harness to better match runtime dependencies by introducing a shared PerpsTestProviders wrapper (React Query + hardware wallet context + existing Perps providers), adding a renderPerpsOrderView renderer, enhancing stream overrides/controls, and expanding the component-view Engine/Perps controller mocks plus Perps state preset data needed for confirmation/payment-dependent views.

Reviewed by Cursor Bugbot for commit 9a29cd5. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

Copy link
Copy Markdown
Contributor

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.

@metamaskbotv2 metamaskbotv2 Bot added the team-qa QA team label May 14, 2026
@github-actions github-actions Bot added pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. size-XL labels May 14, 2026
@racitores racitores force-pushed the raci/cvtest-perps-coverage branch from f8885d9 to 9c1ab1c Compare May 19, 2026 10:53
@github-actions github-actions Bot added size-L and removed size-XL labels May 19, 2026
@racitores racitores marked this pull request as ready for review May 19, 2026 10:57
@racitores racitores requested review from a team as code owners May 19, 2026 10:57
@racitores racitores removed the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label May 19, 2026
@racitores racitores force-pushed the raci/cvtest-perps-coverage branch from 9c1ab1c to 5eebaa1 Compare May 19, 2026 13:32
@racitores racitores enabled auto-merge May 19, 2026 13:32

@cursor cursor Bot left a comment

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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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 d51d8fb. Configure here.

Comment thread app/components/UI/Perps/Views/PerpsWithdrawView/PerpsWithdrawView.view.test.tsx Outdated
@racitores racitores added the no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed label May 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: None (no tests recommended)
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 95%
click to see 🤖 AI reasoning details

E2E Test Selection:
All 8 changed files are exclusively unit/component test files and test infrastructure:

  1. tests/component-view/mocks.ts - Adds new Engine mock methods for PerpsController (placeOrder, withdraw, cancelOrders, closePositions, etc.) and TransactionController. This is Jest mock infrastructure for component-view tests only.

  2. tests/component-view/presets/perpsStatePreset.ts - Enriches Redux state fixtures for Perps component view tests with TransactionController, ApprovalController, CurrencyRateController, GasFeeController state. Test infrastructure only.

  3. tests/component-view/renderers/perpsViewRenderer.tsx - Refactors provider composition into PerpsTestProviders (adding QueryClientProvider and HardwareWalletContext), adds renderPerpsOrderView renderer. Test infrastructure only.

  4. 5 new/modified unit test files - New component view tests for PerpsOrderView, PerpsCancelAllOrdersView, PerpsCloseAllPositionsView, PerpsWithdrawView, and an additional test case in usePerpsOrderFees.test.ts.

No production app code was changed. The tests/component-view/ directory is Jest-based component testing infrastructure, completely separate from Detox E2E tests. These changes cannot break any E2E test flows since they only affect Jest unit/component test setup. No E2E tags are warranted.

Performance Test Selection:
All changes are confined to unit/component test files and test infrastructure. No production app code was modified, so there is no performance impact to measure.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@racitores racitores added this pull request to the merge queue May 20, 2026
Merged via the queue into main with commit ea9b510 May 20, 2026
153 of 163 checks passed
@racitores racitores deleted the raci/cvtest-perps-coverage branch May 20, 2026 16:13
@github-actions github-actions Bot locked and limited conversation to collaborators May 20, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.79.0 Issue or pull request that will be included in release 7.79.0 label May 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed release-7.79.0 Issue or pull request that will be included in release 7.79.0 size-L team-qa QA team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants