Skip to content

test(perps): migrate controller unit tests to core#8840

Open
abretonc7s wants to merge 1 commit into
mainfrom
feat/perps/controller-in-core
Open

test(perps): migrate controller unit tests to core#8840
abretonc7s wants to merge 1 commit into
mainfrom
feat/perps/controller-in-core

Conversation

@abretonc7s
Copy link
Copy Markdown
Contributor

@abretonc7s abretonc7s commented May 18, 2026

Explanation

This PR migrates the mobile perps controller unit tests into @metamask/perps-controller so Core owns the controller test suite. It ports the mobile coverage into Core-native tests/src files, splits the largest controller/provider/subscription suites into focused shards, adds shared test helpers, and switches package coverage collection from the placeholder test to real src/**/*.ts coverage.

The package now enforces at least 80% statement/line coverage for the perps controller package. This is test-only and does not change the published runtime API.

Validation performed:

  • yarn workspace @metamask/perps-controller run test --runInBand
    • 82.89% statements
    • 82.89% lines
    • 78.61% functions
    • 70.06% branches
  • yarn eslint 'packages/perps-controller/{src,tests}/**/*.ts'
  • yarn lint:misc --check
  • yarn workspace @metamask/perps-controller run changelog:validate

Known limitation: yarn tsc --build packages/perps-controller/tsconfig.build.json --verbose is blocked by existing workspace dependency type errors outside this PR, first in accounts-controller / snap-account-service keyring exports, so the perps package is skipped by project references.

References

No related Core GitHub issue found for perps controller tests core.

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate (not applicable; test-only migration)
  • I've communicated my changes to consumers by updating changelogs for packages I've changed (not applicable; test-only, no consumer-facing change)
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Low Risk
Test-only changes that add/reshuffle Jest tests and adjust coverage collection/thresholds; main risk is CI friction from new coverage enforcement or brittle mocks, not runtime behavior.

Overview
Moves PerpsController unit tests into Core under packages/perps-controller/tests, split into focused suites (configuration, lifecycle, operations) and backed by new shared mocks (providerMocks, serviceMocks) to standardize provider/messenger/infrastructure stubbing.

Updates jest.config.js to collect coverage from real src/**/*.ts (excluding barrel index.ts files) and relaxes/sets explicit global coverage thresholds (70% branches, 78% functions, 80% lines/statements) instead of the prior placeholder-only coverage setup.

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

@abretonc7s abretonc7s marked this pull request as ready for review May 19, 2026 07:19
@abretonc7s abretonc7s requested a review from a team as a code owner May 19, 2026 07:19
Copy link
Copy Markdown

@cursor cursor Bot left a comment

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 2 potential issues.

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 ca157fb. Configure here.

Comment thread packages/perps-controller/tests/helpers/providerMocks.ts
@abretonc7s abretonc7s added this pull request to the merge queue May 19, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants