Skip to content

test: color-no-hex perps#26963

Merged
georgewrmarshall merged 7 commits intomainfrom
chore/color-no-hex-perps-batch-3
Mar 6, 2026
Merged

test: color-no-hex perps#26963
georgewrmarshall merged 7 commits intomainfrom
chore/color-no-hex-perps-batch-3

Conversation

@georgewrmarshall
Copy link
Copy Markdown
Contributor

@georgewrmarshall georgewrmarshall commented Mar 4, 2026

Description

This PR splits out the app/components/UI/Perps portion of the color-no-hex lint migration from #26651 into its own reviewable batch.

The change applies the same test-only updates from the original PR for Perps files, including replacing hardcoded hex usage in tests and aligning theme mocks to shared mockTheme patterns where applicable.

Changelog

CHANGELOG entry: null

Related issues

Fixes:

Manual testing steps

Feature: Perps color-no-hex lint batch split

  Scenario: validate updated Perps test files
    Given the branch `chore/color-no-hex-perps-batch-3`

    When running targeted test suites for updated files
    Then all targeted suites pass

    When running eslint on Perps files in this local workspace
    Then lint execution is blocked by local environment config (`@typescript-eslint/no-parameter-properties` rule missing)

Commands used:

  • yarn jest --watchman=false app/components/UI/Perps/Views/PerpsTPSLView/PerpsTPSLView.test.tsx app/components/UI/Perps/components/PerpsLeverageBottomSheet/PerpsLeverageBottomSheet.test.tsx app/components/UI/Perps/components/PerpsLimitPriceBottomSheet/PerpsLimitPriceBottomSheet.test.tsx app/components/UI/Perps/components/PerpsPositionCard/PerpsPositionCard.test.tsx --runInBand
  • yarn jest --watchman=false app/components/UI/Perps/utils/transactionDetailStyles.test.ts --runInBand
  • yarn eslint app/components/UI/Perps --max-warnings=0 (blocked locally by missing rule definition)

Screenshots/Recordings

Before

N/A (test-only changes)

After

N/A (test-only changes)

Pre-merge author checklist

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
Primarily test refactors plus an ESLint override to enforce color-no-hex in app/components/UI/Perps; main risk is new lint enforcement causing CI/local lint failures if any remaining hex usage was missed.

Overview
Adds app/components/UI/Perps/**/* to the ESLint override that errors on @metamask/design-tokens/color-no-hex.

Updates Perps unit/view tests to comply by removing hardcoded hex colors and #-prefixed bug/PR strings, standardizing theme/style mocks to use the shared mockTheme (and in a few cases calling real style functions) so assertions and mocked styles reference theme tokens instead of literal hex values.

Written by Cursor Bugbot for commit bdc53b5. This will update automatically on new commits. Configure here.

@georgewrmarshall georgewrmarshall requested a review from a team as a code owner March 4, 2026 04:55
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 4, 2026

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.

@metamaskbot metamaskbot added the team-design-system All issues relating to design system in Mobile label Mar 4, 2026
@georgewrmarshall georgewrmarshall self-assigned this Mar 4, 2026
@georgewrmarshall georgewrmarshall marked this pull request as draft March 4, 2026 04:56
@georgewrmarshall georgewrmarshall force-pushed the chore/color-no-hex-perps-batch-3 branch from 3ccdbfc to cae9700 Compare March 4, 2026 23:57
@github-actions github-actions bot added size-XL and removed size-L labels Mar 4, 2026
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 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Removed styles mock may break test with missing colors
    • Restored a local styles mock in the test to isolate from design tokens and avoid undefined color properties.

Create PR

Or push these changes by commenting:

@cursor push 08c4a21625
Preview (08c4a21625)
diff --git a/app/components/UI/Perps/components/PerpsLimitPriceBottomSheet/PerpsLimitPriceBottomSheet.test.tsx b/app/components/UI/Perps/components/PerpsLimitPriceBottomSheet/PerpsLimitPriceBottomSheet.test.tsx
--- a/app/components/UI/Perps/components/PerpsLimitPriceBottomSheet/PerpsLimitPriceBottomSheet.test.tsx
+++ b/app/components/UI/Perps/components/PerpsLimitPriceBottomSheet/PerpsLimitPriceBottomSheet.test.tsx
@@ -93,6 +93,25 @@
   strings: jest.fn((key) => key),
 }));
 
+// Mock styles to avoid relying on design tokens structure
+jest.mock('./PerpsLimitPriceBottomSheet.styles', () => ({
+  __esModule: true,
+  createStyles: () => ({
+    container: {},
+    inputLabel: {},
+    errorText: {},
+    limitPriceDisplay: {},
+    limitPriceValue: {},
+    limitPriceCurrency: {},
+    marketPriceText: {},
+    percentageButtonsRow: {},
+    percentageButton: {},
+    percentageButtonActive: {},
+    keypadContainer: {},
+    footerContainer: {},
+  }),
+}));
+
 // Mock BigNumber
 jest.mock('bignumber.js', () => ({
   BigNumber: jest.fn().mockImplementation((value) => ({

@github-actions github-actions bot added size-L and removed size-XL labels Mar 5, 2026
'./PerpsOrderBookView.styles',
).default;

if (styleSheet === perpsOrderBookViewStyleSheet) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This useStyles mock is intentionally scoped to the PerpsOrderBookView stylesheet so shared components like Text can keep their own vars-aware style factories. That avoids false negatives from test-only style wiring and keeps this test focused on order book behavior.

'../../../../../component-library/hooks',
);
useStyles.mockReturnValue({ styles: mockStyles });
useStyles.mockImplementation((styleSheet) => ({
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test now builds styles from the real stylesheet with mockTheme, which keeps token wiring consistent with runtime behavior and reduces maintenance when style keys evolve.

} from './useColorPulseAnimation';
import { mockTheme } from '../../../../util/theme';

jest.mock('../../../../component-library/hooks', () => ({
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using mockTheme directly in the hook-level useStyles mock keeps the default pulse color path aligned with runtime token values. That avoids color fixture drift while still allowing explicit color override coverage in this test file.

icon: { default: '#000000' },
},
},
theme: mockTheme,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching the mocked theme to mockTheme here centralizes token values and removes hardcoded color fixtures. This makes the view test less sensitive to local palette stubs and closer to production theming behavior.

beforeEach(() => {
jest.clearAllMocks();
mockUseTheme.mockReturnValue(mockTheme);
mockUseTheme.mockReturnValue(baseMockTheme);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The local style mock removal here intentionally pushes this test through the component's real style creation path. That keeps assertions focused on behavior while eliminating brittle color literals that can diverge from design tokens.

@georgewrmarshall georgewrmarshall changed the title test(perps): split color-no-hex lint batch from #26651 test: color-no-hex perps Mar 5, 2026
@georgewrmarshall georgewrmarshall marked this pull request as ready for review March 5, 2026 02:41
@georgewrmarshall georgewrmarshall force-pushed the chore/color-no-hex-perps-batch-3 branch from 2532d65 to 5fa86b5 Compare March 6, 2026 01:19
@georgewrmarshall georgewrmarshall force-pushed the chore/color-no-hex-perps-batch-3 branch from 5fa86b5 to bdc53b5 Compare March 6, 2026 20:15
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 6, 2026

🔍 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:
This PR contains only test file refactoring and ESLint configuration changes:

  1. ESLint Configuration (.eslintrc.js): Adds the @metamask/design-tokens/color-no-hex rule to the Perps directory, enforcing design token usage instead of hardcoded hex colors. This is a linting rule that affects development workflow, not runtime behavior.

  2. Unit Test Refactoring (43 test files): All changes are in *.test.tsx and *.test.ts files within app/components/UI/Perps/. The changes:

    • Replace locally-defined mock theme objects with hardcoded hex colors (e.g., { colors: { primary: { default: '#0376C9' } } })
    • Use the centralized mockTheme exported from app/util/theme/index.ts which uses lightTheme.colors from @metamask/design-tokens
    • Update test assertions to reference mockTheme.colors.* instead of hardcoded values
    • Minor comment formatting fixes (removing # from PR references in comments)

Why no E2E tests are needed:

  • No production code is modified - all changes are in test files and ESLint config
  • No functional behavior changes - tests are refactored to use a centralized mock but test the same functionality
  • No user-facing changes - this is purely a code quality/consistency improvement
  • The mockTheme utility already exists and is used elsewhere in the codebase

This is a standard test maintenance/refactoring PR with zero risk to production functionality.

Performance Test Selection:
No performance tests needed. This PR only modifies unit test files and ESLint configuration. There are no changes to production code, UI components, rendering logic, data loading, or any code paths that would affect app performance. The changes are purely test infrastructure refactoring to use centralized mock theme objects instead of hardcoded values.

View GitHub Actions results

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 1 potential issue.

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: PR/issue references lose # prefix to satisfy lint
    • Restored # in all affected PR/issue references and added targeted // eslint-disable-next-line @metamask/design-tokens/color-no-hex comments to prevent false positives.

Create PR

Or push these changes by commenting:

@cursor push 642255872b
Preview (642255872b)
diff --git a/app/components/UI/Perps/Views/PerpsMarketDetailsView/PerpsMarketDetailsView.view.test.tsx b/app/components/UI/Perps/Views/PerpsMarketDetailsView/PerpsMarketDetailsView.view.test.tsx
--- a/app/components/UI/Perps/Views/PerpsMarketDetailsView/PerpsMarketDetailsView.view.test.tsx
+++ b/app/components/UI/Perps/Views/PerpsMarketDetailsView/PerpsMarketDetailsView.view.test.tsx
@@ -136,7 +136,8 @@
     ).not.toBeOnTheScreen();
   });
 
-  describe('Bug 25315: Geo-restriction for Close and Modify actions', () => {
+  // eslint-disable-next-line @metamask/design-tokens/color-no-hex
+  describe('Bug #25315: Geo-restriction for Close and Modify actions', () => {
     it('shows geo block bottom sheet when Close is pressed (geo-restricted user)', async () => {
       renderPerpsMarketDetailsView();
 

diff --git a/app/components/UI/Perps/Views/PerpsMarketListView/PerpsMarketListView.view.test.tsx b/app/components/UI/Perps/Views/PerpsMarketListView/PerpsMarketListView.view.test.tsx
--- a/app/components/UI/Perps/Views/PerpsMarketListView/PerpsMarketListView.view.test.tsx
+++ b/app/components/UI/Perps/Views/PerpsMarketListView/PerpsMarketListView.view.test.tsx
@@ -38,7 +38,8 @@
 const marketDataWithCategories = [cryptoMarket, commodityMarket];
 
 describe('PerpsMarketListView', () => {
-  describe('Bug regression: 25571', () => {
+  // eslint-disable-next-line @metamask/design-tokens/color-no-hex
+  describe('Bug regression: #25571', () => {
     it('renders market list header and list with default state (no category filtering)', async () => {
       renderPerpsMarketListView();
 

diff --git a/app/components/UI/Perps/services/PerpsConnectionManager.test.ts b/app/components/UI/Perps/services/PerpsConnectionManager.test.ts
--- a/app/components/UI/Perps/services/PerpsConnectionManager.test.ts
+++ b/app/components/UI/Perps/services/PerpsConnectionManager.test.ts
@@ -867,7 +867,8 @@
     });
   });
 
-  describe('DEX Abstraction Cache Clearing (PR 25334)', () => {
+  // eslint-disable-next-line @metamask/design-tokens/color-no-hex
+  describe('DEX Abstraction Cache Clearing (PR #25334)', () => {
     beforeEach(() => {
       jest.clearAllMocks();
     });
@@ -972,7 +973,8 @@
 
   describe('foreground reconnection — single reconnection flow', () => {
     it('PerpsConnectionManager has no AppState listener — only the hook triggers foreground reconnect', () => {
-      // This test documents the fix for the race condition introduced by PR 26780.
+      // eslint-disable-next-line @metamask/design-tokens/color-no-hex
+      // This test documents the fix for the race condition introduced by PR #26780.
       // Previously, PerpsConnectionManager registered its own AppState listener in
       // setupStateMonitoring(), which competed with usePerpsConnectionLifecycle hook.
       //

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 6, 2026

@georgewrmarshall georgewrmarshall added this pull request to the merge queue Mar 6, 2026
Merged via the queue into main with commit 0dfec6d Mar 6, 2026
63 checks passed
@georgewrmarshall georgewrmarshall deleted the chore/color-no-hex-perps-batch-3 branch March 6, 2026 21:37
@github-actions github-actions bot locked and limited conversation to collaborators Mar 6, 2026
@metamaskbot metamaskbot added the release-7.70.0 Issue or pull request that will be included in release 7.70.0 label Mar 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.70.0 Issue or pull request that will be included in release 7.70.0 size-L team-design-system All issues relating to design system in Mobile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants