Commit b42b69e
fix: replace static hex colors with design tokens in test files (#26396)
## **Description**
Resolves #14299
Replaces hardcoded hex color literals with `brandColor` and `lightTheme`
tokens from `@metamask/design-tokens` across 37 test files (~120
replacements).
### Color mappings applied
| Hex Value | Design Token |
|-----------|-------------|
| `#ffffff` / `#FFFFFF` / `#fff` / `#FFF` | `brandColor.white` |
| `#000000` / `#000` | `brandColor.black` |
| `#4459ff` | `brandColor.blue500` |
| `#ca3542` | `lightTheme.colors.error.default` |
| `#457a39` | `lightTheme.colors.success.default` |
| `#b7bbc8` | `lightTheme.colors.border.default` |
| `#686e7d` | `brandColor.grey500` |
| `#9ca1af` | `brandColor.grey300` |
| `#121314` | `brandColor.grey900` |
| `#2c3dc5` | `brandColor.blue600` |
| `#1c7e33` | `brandColor.green500` |
| `#279f41` | `brandColor.green400` |
### What was intentionally skipped
- **Hex colors inside `jest.mock()` factories** — babel-jest hoists mock
factories before imports resolve, so referencing
`brandColor`/`lightTheme` there causes `ReferenceError: The module
factory of jest.mock() is not allowed to reference any out-of-scope
variables`
- **Test expectations that verify production code output** (e.g.
`toHaveBeenCalledWith` matching exact hex strings sent by non-test code)
- **Tests specifically exercising 3-char hex format handling** (e.g.
"renders gradient with 3-character hex colors")
- **Non-color hex values** (addresses, IDs, opacity-suffixed colors like
`#b7bbc866`)
- **Colors with no exact design token match** (`#FF0000`, `#666666`,
`#2244`, `#FB4F14`, etc.)
### Scope
This PR only touches test files — no production code changes.
## **Manual testing steps**
N/A — mechanical replacement of string literals with equivalent design
token references.
## **Screenshots/Recordings**
N/A
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs)
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR
- [x] I've properly set the title of this PR
- [x] If applicable, I've included the "Fixes #XXXX" keyword in the
description
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and round trip)
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket
- [ ] I confirm that this PR has no impact on gas, key management, or
other security-critical areas
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Test-only updates that swap hardcoded color literals for
`@metamask/design-tokens`/`mockTheme` values; low risk aside from
potential Jest mock/expectation mismatches if tokens change.
>
> **Overview**
> Updates multiple unit tests to **stop asserting/constructing UI colors
via hardcoded hex strings** and instead reference
`@metamask/design-tokens` (`brandColor`) and the shared `mockTheme` from
`util/theme`.
>
> Also refactors several test `useTheme` mocks to return `mockTheme`
(via `jest.requireActual`) so style/toast expectations align with the
app’s theme tokens.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
060894b. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Co-authored-by: TanayK07 <tanay.kedia07@gmail.com>1 parent 39190c9 commit b42b69e
8 files changed
Lines changed: 64 additions & 91 deletions
File tree
- app
- component-library/providers/ThemeProvider
- components
- UI
- ContextualNetworkPicker
- Earn/hooks
- Views
- ChoosePassword/FoxRiveLoaderAnimation
- ManualBackupStep2
- hooks/useTokenLogo
- reducers/rewards
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
39 | | - | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
Lines changed: 16 additions & 36 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
25 | 18 | | |
26 | 19 | | |
27 | 20 | | |
| |||
302 | 295 | | |
303 | 296 | | |
304 | 297 | | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
| 298 | + | |
319 | 299 | | |
320 | 300 | | |
321 | | - | |
| 301 | + | |
322 | 302 | | |
323 | | - | |
| 303 | + | |
324 | 304 | | |
325 | 305 | | |
326 | 306 | | |
327 | 307 | | |
328 | 308 | | |
329 | | - | |
| 309 | + | |
330 | 310 | | |
331 | | - | |
| 311 | + | |
332 | 312 | | |
333 | 313 | | |
334 | 314 | | |
335 | 315 | | |
336 | 316 | | |
337 | | - | |
338 | | - | |
| 317 | + | |
| 318 | + | |
339 | 319 | | |
340 | 320 | | |
341 | 321 | | |
| |||
346 | 326 | | |
347 | 327 | | |
348 | 328 | | |
349 | | - | |
| 329 | + | |
350 | 330 | | |
351 | 331 | | |
352 | 332 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
98 | | - | |
99 | | - | |
| 99 | + | |
| 100 | + | |
100 | 101 | | |
101 | 102 | | |
102 | 103 | | |
| |||
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
108 | | - | |
| 109 | + | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| |||
114 | 115 | | |
115 | 116 | | |
116 | 117 | | |
117 | | - | |
| 118 | + | |
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
| |||
Lines changed: 13 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| |||
123 | 124 | | |
124 | 125 | | |
125 | 126 | | |
126 | | - | |
127 | | - | |
| 127 | + | |
| 128 | + | |
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
| |||
136 | 137 | | |
137 | 138 | | |
138 | 139 | | |
139 | | - | |
140 | | - | |
| 140 | + | |
| 141 | + | |
141 | 142 | | |
142 | 143 | | |
143 | 144 | | |
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
148 | | - | |
149 | | - | |
| 149 | + | |
| 150 | + | |
150 | 151 | | |
151 | 152 | | |
152 | 153 | | |
| |||
156 | 157 | | |
157 | 158 | | |
158 | 159 | | |
159 | | - | |
160 | | - | |
| 160 | + | |
| 161 | + | |
161 | 162 | | |
162 | 163 | | |
163 | 164 | | |
164 | 165 | | |
165 | 166 | | |
166 | 167 | | |
167 | 168 | | |
168 | | - | |
169 | | - | |
| 169 | + | |
| 170 | + | |
170 | 171 | | |
171 | 172 | | |
172 | 173 | | |
173 | 174 | | |
174 | 175 | | |
175 | 176 | | |
176 | 177 | | |
177 | | - | |
178 | | - | |
| 178 | + | |
| 179 | + | |
179 | 180 | | |
180 | 181 | | |
181 | 182 | | |
| |||
Lines changed: 12 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
11 | 15 | | |
12 | 16 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
| |||
125 | 124 | | |
126 | 125 | | |
127 | 126 | | |
128 | | - | |
129 | | - | |
| 127 | + | |
| 128 | + | |
130 | 129 | | |
131 | 130 | | |
132 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
333 | 334 | | |
334 | 335 | | |
335 | 336 | | |
336 | | - | |
337 | | - | |
338 | | - | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
339 | 342 | | |
340 | 343 | | |
341 | 344 | | |
| |||
549 | 552 | | |
550 | 553 | | |
551 | 554 | | |
552 | | - | |
| 555 | + | |
553 | 556 | | |
554 | 557 | | |
555 | 558 | | |
| |||
579 | 582 | | |
580 | 583 | | |
581 | 584 | | |
582 | | - | |
| 585 | + | |
583 | 586 | | |
584 | 587 | | |
585 | 588 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
15 | 10 | | |
16 | 11 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | 12 | | |
22 | 13 | | |
23 | 14 | | |
24 | 15 | | |
25 | 16 | | |
26 | 17 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | 18 | | |
32 | 19 | | |
33 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
2645 | 2646 | | |
2646 | 2647 | | |
2647 | 2648 | | |
2648 | | - | |
| 2649 | + | |
2649 | 2650 | | |
2650 | 2651 | | |
2651 | 2652 | | |
| |||
2659 | 2660 | | |
2660 | 2661 | | |
2661 | 2662 | | |
2662 | | - | |
| 2663 | + | |
2663 | 2664 | | |
2664 | 2665 | | |
2665 | 2666 | | |
| |||
0 commit comments