Skip to content

test: color-no-hex snaps#26958

Merged
georgewrmarshall merged 3 commits intomainfrom
chore/color-no-hex-core-platform-batch-2
Mar 5, 2026
Merged

test: color-no-hex snaps#26958
georgewrmarshall merged 3 commits intomainfrom
chore/color-no-hex-core-platform-batch-2

Conversation

@georgewrmarshall
Copy link
Copy Markdown
Contributor

@georgewrmarshall georgewrmarshall commented Mar 3, 2026

Description

Continues the color-no-hex cleanup in small codeowner batches by updating the Snaps (@MetaMask/core-platform) tests to remove hardcoded hex color expectations and local hex theme mocks.

This follows the same pattern as the original PR:

  • Original reference PR: test: enforce color-no-hex #26651
  • use shared mockTheme from util/theme
  • assert token-backed theme values (for example mockTheme.colors.info.default) instead of literal hex strings

Changelog

CHANGELOG entry: null

Related issues

Fixes:
Related: #26651

Manual testing steps

Feature: static hex prevention in tests

  Scenario: snaps tests rely on shared theme values
    Given the Snap UI Renderer test suite

    When user runs the updated copyable and link tests
    Then both tests pass without hardcoded hex color values in assertions or local theme mocks

Screenshots/Recordings

Before

After

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

Medium Risk
Low runtime risk since changes are limited to tests and ESLint config, but enabling color-no-hex as an error for all app/components/Snaps files could surface new lint failures across that folder.

Overview
Enables stricter linting for Snaps theming. ESLint now enforces @metamask/design-tokens/color-no-hex as an error for app/components/Snaps/**/*.

Updates Snaps tests to use token-backed theme values. Snap UI tests (copyable, link, and SnapUISpinner) stop using hardcoded hex colors/local theme mocks and instead import the shared mockTheme and assert against values like mockTheme.colors.info.default / mockTheme.colors.primary.default.

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 3, 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 3, 2026
@github-actions github-actions bot added the size-S label Mar 3, 2026
@georgewrmarshall georgewrmarshall force-pushed the chore/color-no-hex-core-platform-batch-2 branch from a88ed52 to 4541925 Compare March 4, 2026 04:54
@georgewrmarshall georgewrmarshall force-pushed the chore/color-no-hex-core-platform-batch-2 branch from 4541925 to 468e216 Compare March 5, 2026 01:52
@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:
All changes in this PR are to test files and ESLint configuration only - no production code is modified:

  1. .eslintrc.js: Adds an ESLint rule (@metamask/design-tokens/color-no-hex) for Snaps components. This is a linting configuration change that enforces code quality but doesn't affect runtime behavior.

  2. copyable.test.tsx: Refactors the test to import mockTheme from the shared utility (app/util/theme) instead of defining a local mock. No changes to the actual copyable.ts component.

  3. link.test.ts: Replaces hardcoded hex color values (#4459ff) with mockTheme.colors.info.default in test assertions. No changes to the actual link.ts component.

  4. SnapUISpinner.test.tsx: Replaces lightTheme import from @metamask/design-tokens with mockTheme from the theme utility. No changes to the actual SnapUISpinner.tsx component.

Since these are purely test refactoring changes (improving test consistency by using shared mocks) and a linting rule addition, no E2E tests are needed. The production Snaps UI components remain unchanged, so there's no risk to user-facing functionality.

Performance Test Selection:
No performance tests needed. All changes are to unit test files and ESLint configuration. No production code is modified, so there's no potential impact on app performance, rendering, or user flows.

View GitHub Actions results

},
},
{
files: ['app/components/Snaps/**/*.{js,jsx,ts,tsx}'],
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 scoped override is a good incremental rollout point for Snaps. It enforces color-no-hex in production + tests under app/components/Snaps/** without broadening conflicts in unrelated codeowner areas.

import { fireEvent, waitFor } from '@testing-library/react-native';
import ClipboardManager from '../../../../core/ClipboardManager';
import { Copyable } from '@metamask/snaps-sdk/jsx';
import { mockTheme } from '../../../../util/theme';
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.

Importing mockTheme from util/theme here removes duplicated local test-theme definitions and keeps this test aligned with the shared theme contract used across the app.

key: expect.any(String),
props: {
color: '#4459ff',
color: mockTheme.colors.info.default,
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.

Asserting mockTheme.colors.info.default instead of a literal hex makes this expectation resilient to token updates while still validating that link text uses the semantic info color.

@georgewrmarshall georgewrmarshall marked this pull request as ready for review March 5, 2026 02:10
@georgewrmarshall georgewrmarshall requested a review from a team as a code owner March 5, 2026 02:10
@georgewrmarshall georgewrmarshall changed the title test(snaps): replace hardcoded colors with shared mockTheme (batch 2) test(snaps): replace hardcoded colors with shared mockTheme Mar 5, 2026
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.51%. Comparing base (554b85c) to head (468e216).
⚠️ Report is 56 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #26958      +/-   ##
==========================================
- Coverage   81.68%   81.51%   -0.18%     
==========================================
  Files        4606     4627      +21     
  Lines      120574   121093     +519     
  Branches    26372    26453      +81     
==========================================
+ Hits        98496    98706     +210     
- Misses      15196    15480     +284     
- Partials     6882     6907      +25     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 5, 2026

@georgewrmarshall georgewrmarshall changed the title test(snaps): replace hardcoded colors with shared mockTheme test: color-no-hex snaps/core-platform Mar 5, 2026
@georgewrmarshall georgewrmarshall changed the title test: color-no-hex snaps/core-platform test: color-no-hex snaps Mar 5, 2026
@georgewrmarshall georgewrmarshall self-assigned this Mar 5, 2026
@georgewrmarshall georgewrmarshall added this pull request to the merge queue Mar 5, 2026
Merged via the queue into main with commit d9d8e01 Mar 5, 2026
77 checks passed
@georgewrmarshall georgewrmarshall deleted the chore/color-no-hex-core-platform-batch-2 branch March 5, 2026 15:58
@github-actions github-actions bot locked and limited conversation to collaborators Mar 5, 2026
@metamaskbot metamaskbot added the release-7.69.0 Issue or pull request that will be included in release 7.69.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.69.0 Issue or pull request that will be included in release 7.69.0 size-S team-design-system All issues relating to design system in Mobile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants