Skip to content

chore: css typography token unit tests #697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

georgewrmarshall
Copy link
Contributor

@georgewrmarshall georgewrmarshall commented May 25, 2025

Description

This PR adds comprehensive CSS typography tests to ensure consistency between Figma design tokens and the generated CSS variables. The tests validate that all typography-related CSS variables (font sizes, line heights, font weights, letter spacing, and font families) match their corresponding values in the Figma tokens.

What is the reason for the change?
We needed automated testing to verify that our CSS typography variables are correctly generated from the Figma design tokens and remain consistent across updates.

What is the improvement/solution?

  • Added a new test suite typography.test.ts that validates all typography CSS variables against their Figma token counterparts
  • Tests cover base typography values (font sizes, line heights, font weights, letter spacing)
  • Tests validate typography scale tokens for both small and large screen variants
  • Tests ensure font family variables are correctly defined
  • Fixed letter spacing values for body XS variants (changed from letter-spacing-0 to letter-spacing-1)

Related issues

Fixes: #158

Manual testing steps

  1. Run yarn workspace @metamask/design-tokens test to execute the new typography tests
  2. Verify all tests pass
  3. Check that the test coverage includes all typography-related CSS variables
  4. Confirm that any future changes to typography tokens will be caught by these tests

Screenshots/Recordings

Before

No automated testing for CSS typography variables - potential for inconsistencies between Figma tokens and CSS output to go unnoticed.

After

Comprehensive test suite with 100% coverage ensuring typography CSS variables match Figma design tokens:

  • ✅ Font size variables tested
  • ✅ Line height variables tested
  • ✅ Font weight variables tested
  • ✅ Letter spacing variables tested
  • ✅ Typography scale tokens tested
  • ✅ Font family variables tested

Pre-merge author checklist

  • I've followed MetaMask Contributor Docs
  • I've completed the PR template to the best of my ability
  • I've included tests if applicable
  • I've documented my code using JSDoc format if applicable
  • I've applied the right labels on the PR (see labeling guidelines). Not required for external contributors.

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.

Copy link
Contributor

📖 Storybook Preview

@@ -11,14 +11,6 @@ describe('Typography', () => {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to separate PR #699

Copy link
Contributor

📖 Storybook Preview

@@ -33,7 +33,7 @@ export const AvatarBase = forwardRef<HTMLDivElement, AvatarBaseProps>(

const mergedClassName = twMerge(
// Base styles
'inline-flex items-center justify-center overflow-hidden bg-section',
'bg-section inline-flex items-center justify-center overflow-hidden',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Prettier fix after rebase from main

@@ -92,11 +92,11 @@
--typography-s-body-xs-medium-font-size: var(--font-size-2);
--typography-s-body-xs-medium-line-height: var(--line-height-2);
--typography-s-body-xs-medium-font-weight: var(--font-weight-medium);
--typography-s-body-xs-medium-letter-spacing: var(--letter-spacing-0);
--typography-s-body-xs-medium-letter-spacing: var(--letter-spacing-1);
Copy link
Contributor Author

@georgewrmarshall georgewrmarshall May 28, 2025

Choose a reason for hiding this comment

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

Fix from unit tests to align with figma!

Copy link
Contributor

📖 Storybook Preview

Copy link
Contributor

📖 Storybook Preview

Copy link
Contributor

github-actions bot commented Jun 2, 2025

📖 Storybook Preview

@georgewrmarshall georgewrmarshall marked this pull request as ready for review June 2, 2025 08:51
@georgewrmarshall georgewrmarshall requested a review from a team as a code owner June 2, 2025 08:51
@georgewrmarshall georgewrmarshall marked this pull request as draft June 2, 2025 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Design Tokens]: Create Unit Tests for CSS Typography Variables Alignment with Figma Token JSON
1 participant