Skip to content

test: color-no-hex predict#27008

Merged
georgewrmarshall merged 11 commits intomainfrom
chore/color-no-hex-batch-4
Mar 5, 2026
Merged

test: color-no-hex predict#27008
georgewrmarshall merged 11 commits intomainfrom
chore/color-no-hex-batch-4

Conversation

@georgewrmarshall
Copy link
Copy Markdown
Contributor

@georgewrmarshall georgewrmarshall commented Mar 4, 2026

Description

This PR is the Predict-only split of the color-no-hex batch work, extracted from the original umbrella PR #26651 and the previously combined batch branch.

Scope:

  • Predict files only (app/components/UI/Predict/**)
  • temporary eslint rollout override for app/components/UI/Predict/**/*.{js,jsx,ts,tsx}

Reference PR: #26651

Changelog

CHANGELOG entry: null

Related issues

Fixes:

Manual testing steps

Feature: color-no-hex predict batch

  Scenario: validate predict lint and tests
    Given this branch is checked out
    When running eslint for Predict scope
    Then there are no lint errors

    When running jest for Predict scope with snapshot updates
    Then tests pass

Screenshots/Recordings

Before

N/A (test/lint/config updates only)

After

N/A (test/lint/config updates only)

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-only refactors plus an ESLint override for app/components/UI/Predict; low runtime risk, but it may surface new lint failures if any remaining hex colors exist in that folder.

Overview
Enables @metamask/design-tokens/color-no-hex enforcement for app/components/UI/Predict/**/* via an ESLint override.

Refactors Predict unit tests to comply by replacing inline hex strings with a new shared TEST_HEX_COLORS fixture and by standardizing theme mocks to reuse mockTheme from app/util/theme (including updating a few toast/theme color mocks).

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

@metamaskbot metamaskbot added the team-design-system All issues relating to design system in Mobile label Mar 4, 2026
@github-actions github-actions bot added the size-L label Mar 4, 2026
@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.

@github-actions github-actions bot added size-M and removed size-L labels Mar 4, 2026
@georgewrmarshall georgewrmarshall changed the title test: color-no-hex batch 4 for predict, ramp, rewards test: color-no-hex batch 4 for predict Mar 4, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 4, 2026

⚠️ E2E Fixture Validation — Structural changes detected

Category Count
New keys 60
Missing keys 7
Type mismatches 0
Value mismatches 7 (informational)

The committed fixture schema is out of date. To update, comment:

@metamaskbot update-mobile-fixture

View full details | Download diff report

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: Undefined reference to renamed import TEST_HEX_COLORS
    • Replaced incorrect TEST_HEX_COLORS references with the correctly imported mockTestHexColors in the test assertions.

Create PR

Or push these changes by commenting:

@cursor push ed339bf6fc
Preview (ed339bf6fc)
diff --git a/app/components/UI/Predict/hooks/usePredictClaim.test.ts b/app/components/UI/Predict/hooks/usePredictClaim.test.ts
--- a/app/components/UI/Predict/hooks/usePredictClaim.test.ts
+++ b/app/components/UI/Predict/hooks/usePredictClaim.test.ts
@@ -202,8 +202,8 @@
           },
         ],
         iconName: IconName.Error,
-        iconColor: TEST_HEX_COLORS.ERROR_DARK,
-        backgroundColor: TEST_HEX_COLORS.ACCENT_BLUE,
+        iconColor: mockTestHexColors.ERROR_DARK,
+        backgroundColor: mockTestHexColors.ACCENT_BLUE,
         hasNoTimeout: false,
         linkButtonOptions: {
           label: strings('predict.claim.toasts.error.try_again'),

@georgewrmarshall georgewrmarshall changed the title test: color-no-hex batch 4 for predict test: color-no-hex predict codeowner batch Mar 5, 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: Inconsistent hex color handling in ChartLegend test
    • Replaced hardcoded hex colors with TEST_HEX_COLORS constants and removed inline lint suppressions.

Create PR

Or push these changes by commenting:

@cursor push 6b7fa01195
Preview (6b7fa01195)
diff --git a/app/components/UI/Predict/components/PredictDetailsChart/components/ChartLegend.test.tsx b/app/components/UI/Predict/components/PredictDetailsChart/components/ChartLegend.test.tsx
--- a/app/components/UI/Predict/components/PredictDetailsChart/components/ChartLegend.test.tsx
+++ b/app/components/UI/Predict/components/PredictDetailsChart/components/ChartLegend.test.tsx
@@ -2,6 +2,7 @@
 import renderWithProvider from '../../../../../../util/test/renderWithProvider';
 import ChartLegend from './ChartLegend';
 import { ChartSeries } from '../PredictDetailsChart';
+import { TEST_HEX_COLORS } from '../../../testUtils/mockColors';
 
 jest.mock('../utils', () => ({
   formatTickValue: jest.fn((value: number, range: number) => {
@@ -22,8 +23,7 @@
   const mockSingleSeries: ChartSeries[] = [
     {
       label: 'Outcome A',
-      // eslint-disable-next-line @metamask/design-tokens/color-no-hex
-      color: '#4459FF',
+      color: TEST_HEX_COLORS.CHART_PRIMARY,
       data: [
         { timestamp: 1640995200000, value: 0.5 },
         { timestamp: 1640998800000, value: 0.6 },
@@ -35,8 +35,7 @@
   const mockMultipleSeries: ChartSeries[] = [
     {
       label: 'Outcome A',
-      // eslint-disable-next-line @metamask/design-tokens/color-no-hex
-      color: '#4459FF',
+      color: TEST_HEX_COLORS.CHART_PRIMARY,
       data: [
         { timestamp: 1640995200000, value: 0.5 },
         { timestamp: 1640998800000, value: 0.6 },
@@ -45,8 +44,7 @@
     },
     {
       label: 'Outcome B',
-      // eslint-disable-next-line @metamask/design-tokens/color-no-hex
-      color: '#FF6B6B',
+      color: TEST_HEX_COLORS.CHART_CORAL,
       data: [
         { timestamp: 1640995200000, value: 0.3 },
         { timestamp: 1640998800000, value: 0.2 },
@@ -135,8 +133,7 @@
       const seriesWithEmptyData: ChartSeries[] = [
         {
           label: 'Empty Series',
-          // eslint-disable-next-line @metamask/design-tokens/color-no-hex
-          color: '#4459FF',
+          color: TEST_HEX_COLORS.CHART_PRIMARY,
           data: [],
         },
       ];
@@ -207,8 +204,7 @@
       const seriesWithEmptyData: ChartSeries[] = [
         {
           label: 'Empty',
-          // eslint-disable-next-line @metamask/design-tokens/color-no-hex
-          color: '#4459FF',
+          color: TEST_HEX_COLORS.CHART_PRIMARY,
           data: [],
         },
       ];
@@ -222,8 +218,7 @@
       const seriesWithSinglePoint: ChartSeries[] = [
         {
           label: 'Single Point',
-          // eslint-disable-next-line @metamask/design-tokens/color-no-hex
-          color: '#4459FF',
+          color: TEST_HEX_COLORS.CHART_PRIMARY,
           data: [{ timestamp: 1640995200000, value: 0.42 }],
         },
       ];
@@ -256,8 +251,7 @@
       const seriesWithSmallValues: ChartSeries[] = [
         {
           label: 'Small',
-          // eslint-disable-next-line @metamask/design-tokens/color-no-hex
-          color: '#4459FF',
+          color: TEST_HEX_COLORS.CHART_PRIMARY,
           data: [{ timestamp: 1640995200000, value: 0.001 }],
         },
       ];
@@ -274,8 +268,7 @@
       const seriesWithLargeValues: ChartSeries[] = [
         {
           label: 'Large',
-          // eslint-disable-next-line @metamask/design-tokens/color-no-hex
-          color: '#4459FF',
+          color: TEST_HEX_COLORS.CHART_PRIMARY,
           data: [{ timestamp: 1640995200000, value: 999.99 }],
         },
       ];
@@ -311,8 +304,7 @@
       const seriesWithDifferentLengths: ChartSeries[] = [
         {
           label: 'Long',
-          // eslint-disable-next-line @metamask/design-tokens/color-no-hex
-          color: '#4459FF',
+          color: TEST_HEX_COLORS.CHART_PRIMARY,
           data: [
             { timestamp: 1, value: 0.1 },
             { timestamp: 2, value: 0.2 },
@@ -321,8 +313,7 @@
         },
         {
           label: 'Short',
-          // eslint-disable-next-line @metamask/design-tokens/color-no-hex
-          color: '#FF6B6B',
+          color: TEST_HEX_COLORS.CHART_CORAL,
           data: [{ timestamp: 1, value: 0.5 }],
         },
       ];

@georgewrmarshall georgewrmarshall changed the title test: color-no-hex predict codeowner batch test: color-no-hex predict Mar 5, 2026
@georgewrmarshall georgewrmarshall marked this pull request as ready for review March 5, 2026 02:36
@georgewrmarshall georgewrmarshall requested a review from a team as a code owner March 5, 2026 02:36
},
},
{
files: ['app/components/UI/Predict/**/*.{js,jsx,ts,tsx}'],
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 folder-level override is the key rollout guardrail: it enforces the rule for Predict while broader test migrations continue. Keeping the scope isolated to Predict lowers merge risk and makes rollback straightforward if CI uncovers missed literals.

* Keep hardcoded test-only colors in this file to avoid repeated
* `color-no-hex` suppressions across test suites.
*/
export const TEST_HEX_COLORS = {
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 file keeps Predict-specific static test colors in one place so individual tests can stay readable without repeating rule suppressions. Keeping the suppression scoped here also makes it easy to audit and remove later if tokenized fixtures are introduced.

@@ -1,4 +1,5 @@
import { NavigationProp } from '@react-navigation/native';
import { TEST_HEX_COLORS as mockTestHexColors } from '../testUtils/mockColors';
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 mock-prefixed alias is intentional here because Jest mock factories are hoisted and can only safely reference imported values when they follow the mock naming convention. This keeps the test aligned with centralized color fixtures while avoiding scope/hoist issues in the factory.

import renderWithProvider from '../../../../../../util/test/renderWithProvider';
import ChartLegend from './ChartLegend';
import { ChartSeries } from '../PredictDetailsChart';
import { TEST_HEX_COLORS } from '../../../testUtils/mockColors';
Copy link
Copy Markdown
Contributor Author

@georgewrmarshall georgewrmarshall Mar 5, 2026

Choose a reason for hiding this comment

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

This import keeps chart fixture colors consistent with the shared Predict test palette so updates happen in one place instead of drifting across chart tests.

@georgewrmarshall georgewrmarshall self-assigned this Mar 5, 2026
caieu
caieu previously approved these changes Mar 5, 2026
Copy link
Copy Markdown
Contributor

@caieu caieu left a comment

Choose a reason for hiding this comment

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

LGTM

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: Theme mock missing accent04 crashes hook initialization
    • Updated usePredictDeposit.test to mock theme colors with accent04 and error paths, preventing undefined access during hook initialization.

Create PR

Or push these changes by commenting:

@cursor push 873cdee03f
Preview (873cdee03f)
diff --git a/app/components/UI/Predict/hooks/usePredictDeposit.test.ts b/app/components/UI/Predict/hooks/usePredictDeposit.test.ts
--- a/app/components/UI/Predict/hooks/usePredictDeposit.test.ts
+++ b/app/components/UI/Predict/hooks/usePredictDeposit.test.ts
@@ -4,6 +4,7 @@
 import Logger from '../../../../util/Logger';
 import { PredictTradeStatus } from '../constants/eventNames';
 import { ConfirmationLoader } from '../../../Views/confirmations/components/confirm/confirm-component';
+import { TEST_HEX_COLORS as mockTestHexColors } from '../testUtils/mockColors';
 
 const mockGoBack = jest.fn();
 const mockNavigateToConfirmation = jest.fn();
@@ -32,12 +33,18 @@
   error: jest.fn(),
 }));
 
-jest.mock('../../../../util/theme', () => {
-  const { mockTheme } = jest.requireActual('../../../../util/theme');
-  return {
-    useAppThemeFromContext: () => mockTheme,
-  };
-});
+jest.mock('../../../../util/theme', () => ({
+  useAppThemeFromContext: jest.fn(() => ({
+    colors: {
+      error: {
+        default: mockTestHexColors.ERROR_DARK,
+      },
+      accent04: {
+        normal: mockTestHexColors.ACCENT_BLUE,
+      },
+    },
+  })),
+}));
 
 jest.mock('../../../../component-library/components/Toast', () => {
   const actualReact = jest.requireActual('react');

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 5, 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 infrastructure changes:

  1. ESLint configuration update (.eslintrc.js): Adds the @metamask/design-tokens/color-no-hex rule for the Predict directory to enforce design token usage.

  2. New test utility file (mockColors.ts): Creates a centralized file with hardcoded hex color constants for use in Predict unit tests, with an ESLint disable comment to allow hex colors in this specific file.

  3. 27 unit test file updates: Refactors all Predict component/hook/utility tests to import and use TEST_HEX_COLORS constants instead of inline hex color strings.

Why no E2E tests are needed:

  • No production code is modified - only unit test files and ESLint configuration
  • The changes are purely cosmetic/organizational - same color values, just referenced from a centralized location
  • Unit tests will validate the refactoring was done correctly
  • No functional changes to the Predict feature or any user-facing behavior
  • No changes to UI components, state management, API calls, or navigation

This is a low-risk code quality improvement that doesn't require E2E validation.

Performance Test Selection:
No performance tests are needed because this PR only modifies unit test files and ESLint configuration. There are no changes to production code, UI components, rendering logic, state management, or any code paths that could impact app performance. The changes are purely organizational - centralizing hex color constants used in unit tests.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 5, 2026

@georgewrmarshall georgewrmarshall requested a review from caieu March 5, 2026 21:14
Copy link
Copy Markdown
Contributor

@caieu caieu left a comment

Choose a reason for hiding this comment

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

LGTM

@georgewrmarshall georgewrmarshall added this pull request to the merge queue Mar 5, 2026
Merged via the queue into main with commit 950a7e6 Mar 5, 2026
64 checks passed
@georgewrmarshall georgewrmarshall deleted the chore/color-no-hex-batch-4 branch March 5, 2026 21:55
@github-actions github-actions bot locked and limited conversation to collaborators Mar 5, 2026
@metamaskbot metamaskbot added the release-7.70.0 Issue or pull request that will be included in release 7.70.0 label Mar 5, 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