test: use mockTheme instead of hardcoded hex values in amount-keyboard assertions#26710
Conversation
|
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. |
| @@ -162,7 +162,7 @@ describe('Amount', () => { | |||
| const { getByRole } = renderComponent(undefined, ''); | |||
| expect( | |||
| getByRole('button', { name: 'Next' }).props.style.backgroundColor, | |||
There was a problem hiding this comment.
The disabled-button state maps to text.muted (not a border token) because getBackgroundColor uses theme.colors.text.muted for the submitDisabled path. Asserting via the token reference keeps the test correct regardless of what hex value the design system assigns to that token.
| mockTheme.colors.error.default, | ||
| ); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
These four assertions cover all branches of getBackgroundColor: default state (text.default), error only (error.default), disabled only (text.muted), and error taking precedence over disabled (error.default). The token references mean this test continues to validate correct branch logic even when token hex values change in future design system upgrades.
…eyboard assertions
0a68c6e to
95e250e
Compare
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: No application code is changed - the actual component (amount-keyboard.tsx) and styles (amount-keyboard.styles.ts) remain untouched. Since this is purely a unit test maintenance change with no functional impact on the application, no E2E tests are required to validate this change. Performance Test Selection: |
Description
Updates
amount-keyboard.test.tsxto usemockThemedesign token references instead of hardcoded hex values in test assertions, unblocking the design tokens upgrade to v8.2.1 (#26639).What this PR does:
#b7bbc8,#121314,#ca3542) withmockTheme.colors.*references in test assertions forgetBackgroundColorand the disabled Next buttonWhy this is an improvement:
Changelog
CHANGELOG entry: null
Related issues
Dependency of: #26639
Related: #26657
Manual testing steps
Screenshots/Recordings
N/A - Test-only changes
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Low Risk
Test-only updates that swap fixed hex assertions for
mockThemetoken references, reducing brittleness during design token upgrades. No production logic changes; risk limited to potential mismatches with token names/structure.Overview
Updates
amount-keyboard.test.tsxto stop asserting on hardcoded hex colors for the disabled Next/Continue button andgetBackgroundColoroutput.Assertions now reference
mockTheme.colors.text.*andmockTheme.colors.error.*, making the tests resilient to design token value changes while still verifying the correct token is used.Written by Cursor Bugbot for commit 95e250e. This will update automatically on new commits. Configure here.