Skip to content

test: color-no-hex confirmations batch#27149

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

test: color-no-hex confirmations batch#27149
georgewrmarshall merged 3 commits intomainfrom
chore/color-no-hex-confirmations-batch

Conversation

@georgewrmarshall
Copy link
Copy Markdown
Contributor

@georgewrmarshall georgewrmarshall commented Mar 6, 2026

Description

Split from #26651 to reduce CODEOWNERS fanout.

Batch: confirmations
Source branch: `origin/remove-static-hex-from-tests`

When `@metamask/design-tokens` upgrades change color values, tests that hardcode hex literals (e.g. `'#ffffff'`) break because the component renders the new token value while the test still asserts the old one — even though nothing is actually wrong. This PR fixes that brittleness across the confirmations scope.

Two strategies are applied:

  1. Replace hardcoded hex with token references — test mocks and assertions use `mockTheme.colors.` (or `brandColor.` for production code) so the test always agrees with whatever the current token value is. Package upgrades no longer cause spurious failures.

  2. Add targeted `eslint-disable` comments — strings like `'chore: bump walletconnect/* deps #12345'` or `'ENS / IPFS resolution is broken #456'` are NFT token IDs that happen to look like hex colors. The `color-no-hex` rule can't distinguish them from CSS colors, so suppress comments are added inline to keep the rule enforced everywhere else without false positives.

Together these changes make the `@metamask/design-tokens/color-no-hex` lint rule enforceable across this scope, so future hex literals won't accidentally creep in.

Changelog

CHANGELOG entry: null

Related issues

Fixes:

Manual testing steps

```gherkin
Feature: color-no-hex lint compliance (confirmations batch)

Scenario: user runs lint
Given the confirmations test files have been updated
When user runs the lint checks
Then no color-no-hex violations are reported
```

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.

@georgewrmarshall georgewrmarshall requested a review from a team as a code owner March 6, 2026 20:19
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 6, 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 6, 2026
@github-actions github-actions bot added the size-S label Mar 6, 2026
@georgewrmarshall georgewrmarshall marked this pull request as draft March 6, 2026 21:06
@georgewrmarshall georgewrmarshall self-assigned this Mar 10, 2026
import styleSheet from './bottom-modal.styles';

const OPAQUE_GRAY = '#414141';
const OPAQUE_GRAY = brandColor.grey600;
Copy link
Copy Markdown
Contributor Author

@georgewrmarshall georgewrmarshall Mar 10, 2026

Choose a reason for hiding this comment

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

We should avoid using colors outside of our design tokens. brandColor.grey600 (#4b505c) is the closest token to #414141, so we should use that instead of introducing a new hex value.

We also do not currently have a fully opaque overlay token. I am curious what hideBackground is intended for. From a quick look, hideBackground does not appear to be used. Should it be removed? We should likely be using BottomSheet instead of BottomModal anway?

@MetaMask/confirmations

backdropColor={hideBackground ? OPAQUE_GRAY : colors.overlay.default}

@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
The PR changes a UI constant (hardcoded color replaced with brandColor.grey600) in bottom-modal.tsx within the confirmations component tree. No logic or state changes were introduced. Since the bottom modal is part of transaction and signature confirmation flows, SmokeConfirmations is required to ensure the UI renders correctly during transaction and signature approval flows. No other wallet, network, trade, or controller logic was modified.

Performance Test Selection:
The change only replaces a hardcoded color with a design token constant. No rendering logic, state management, list rendering, controller logic, or initialization behavior was modified. No performance impact expected.

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: brandColor.grey600 may not exist, causing undefined backdrop
    • Replaced brandColor.grey600 with confirmed token brandColor.grey900 to ensure a defined backdrop color.

Create PR

Or push these changes by commenting:

@cursor push d6400f12c4
Preview (d6400f12c4)
diff --git a/app/components/Views/confirmations/components/UI/bottom-modal/bottom-modal.tsx b/app/components/Views/confirmations/components/UI/bottom-modal/bottom-modal.tsx
--- a/app/components/Views/confirmations/components/UI/bottom-modal/bottom-modal.tsx
+++ b/app/components/Views/confirmations/components/UI/bottom-modal/bottom-modal.tsx
@@ -8,7 +8,7 @@
 import { useStyles } from '../../../../../hooks/useStyles';
 import styleSheet from './bottom-modal.styles';
 
-const OPAQUE_GRAY = brandColor.grey600;
+const OPAQUE_GRAY = brandColor.grey900;
 interface BottomModalProps {
   avoidKeyboard?: boolean;
   children: ReactChild;

import styleSheet from './bottom-modal.styles';

const OPAQUE_GRAY = '#414141';
const OPAQUE_GRAY = brandColor.grey600;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

brandColor.grey600 may not exist, causing undefined backdrop

High Severity

OPAQUE_GRAY was changed from '#414141' to brandColor.grey600, but grey600 may not be a valid property on the brandColor export from @metamask/design-tokens. Other usages of brandColor in the codebase (e.g., KYCFailed.tsx) only reference brandColor.white. If grey600 is undefined, the modal's backdropColor will be undefined when hideBackground is true, resulting in no visible backdrop — a production visual regression for the confirmation modal.

Fix in Cursor Fix in Web

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.

It exists... chill

Screenshot 2026-03-10 at 10 09 47 AM Screenshot 2026-03-10 at 10 09 51 AM

headerTitleAlign: 'center' as const,
headerStyle: {
backgroundColor: '#ffffff',
backgroundColor: mockTheme.colors.background.default,
Copy link
Copy Markdown
Contributor Author

@georgewrmarshall georgewrmarshall Mar 10, 2026

Choose a reason for hiding this comment

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

When '#ffffff' is hardcoded in a test assertion, any @metamask/design-tokens upgrade that changes background.default will cause this test to fail even though the component is rendering the correct token value. By referencing mockTheme.colors.background.default, the assertion always matches whatever the current token resolves to, making this test resilient to package upgrades.

},
},
})),
theme: mockTheme,
Copy link
Copy Markdown
Contributor Author

@georgewrmarshall georgewrmarshall Mar 10, 2026

Choose a reason for hiding this comment

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

The previous mock returned theme: { colors: { text: { alternative: '#6a737d' } } } — a partial, hardcoded copy of a design token value. If @metamask/design-tokens upgrades that color, the component renders the new value but the test mock still returns the old hex, producing a spurious failure. Replacing it with mockTheme (the full canonical test theme) means the mock always stays in sync with the token package automatically.

import { InfoRowDivider } from './divider';
import renderWithProvider from '../../../../../../../util/test/renderWithProvider';
import { lightTheme } from '@metamask/design-tokens';
import { mockTheme } from '../../../../../../../util/theme';
Copy link
Copy Markdown
Contributor Author

@georgewrmarshall georgewrmarshall Mar 10, 2026

Choose a reason for hiding this comment

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

Using lightTheme directly here achieves the same thing, we will not see a test failure if the design tokens are updated. mockTheme uses lightTheme and is the convention we are using to mock colors.

const mockNft = createMockNft({
standard: 'ERC721',
collectionName: 'Bored Apes',
// eslint-disable-next-line @metamask/design-tokens/color-no-hex
Copy link
Copy Markdown
Contributor Author

@georgewrmarshall georgewrmarshall Mar 10, 2026

Choose a reason for hiding this comment

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

Strings like '#456', '#12345', '#22222' are NFT token IDs — # is a display prefix (e.g. #<tokenId>), not a CSS hex color. The color-no-hex rule can't distinguish between them, so these targeted suppressions are intentional. The rule is being enforced across the codebase to prevent real static hex values from creeping into tests (which would make them brittle on package upgrades), so the inline disables are the right way to allow these legitimate domain strings without weakening the broader rule.

@georgewrmarshall georgewrmarshall marked this pull request as ready for review March 10, 2026 17:13
@github-actions
Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
11 value mismatches detected (expected — fixture represents an existing user).
View details

@sonarqubecloud
Copy link
Copy Markdown

@georgewrmarshall georgewrmarshall added this pull request to the merge queue Mar 11, 2026
Merged via the queue into main with commit 8834b40 Mar 11, 2026
108 checks passed
@georgewrmarshall georgewrmarshall deleted the chore/color-no-hex-confirmations-batch branch March 11, 2026 09:07
@github-actions github-actions bot locked and limited conversation to collaborators Mar 11, 2026
@metamaskbot metamaskbot added the release-7.70.0 Issue or pull request that will be included in release 7.70.0 label Mar 11, 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-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.

3 participants