Skip to content

chore: Stable hashes for border tokens - #4718

Merged
pan-kot merged 1 commit into
mainfrom
chore-stable-theme-hashes
Jul 17, 2026
Merged

pan-kot merged 1 commit into
mainfrom
chore-stable-theme-hashes

Conversation

@pan-kot

@pan-kot pan-kot commented Jul 14, 2026

Copy link
Copy Markdown
Member

Description

A follow-up for cloudscape-design/theming-core#190

How has this been tested?

  • Existing screenshot tests
Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.59%. Comparing base (726348b) to head (47e8275).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4718   +/-   ##
=======================================
  Coverage   97.59%   97.59%           
=======================================
  Files         950      950           
  Lines       30662    30662           
  Branches    11240    11240           
=======================================
  Hits        29926    29926           
  Misses        689      689           
  Partials       47       47           

☔ View full report in Codecov by Harness.
📢 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.

counters.unset = (counters.unset ?? 0) + 1;
}
}
console.log(`Design token versions: ${JSON.stringify(counters)}`);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do we need this log? I am thinking we could make it separate function. because the it seems lke getTokenVersions is doing two things (logging the count of token version, and returning the token versions).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Logging is just the debugging - it helps to understand what portion of the tokens is already covered with versions, that's it.

const versionGroups = [{ pattern: /^border-/, version: DEFAULT_TOKEN_VERSION }];

// Builds the token -> version allowlist from the full token -> cssName map.
function getTokenVersions(variablesMap, groups = versionGroups) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Consider separating this function into three functions: getTokenVersions, findVersion, and logVersionCount (if this is needed, if not let's remove the counter, and log). That way we can also test the findVersion separately.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Why to test findVersion separately? The entire function and the pattern we use for border tokens are already covered with tests. The logging does not need to be tested - that is just for debugging.


// Groups map a token-name pattern (matched against the token's CSS variable name) to a version.
// Tokens matching no group stay version-less and keep the legacy value-based hashes.
const versionGroups = [{ pattern: /^border-/, version: DEFAULT_TOKEN_VERSION }];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

From the comments and implementation it's not clear that the order in our version group matters, for the getTokenVersions (which is a very important thing). Can we make this more robust? so that our tests fail when the order changes? or we don't need the method getTokenVersions to be dependent on the order of the versionGroups.

Do we also need a way to detect a conflicting groups?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@pan-kot
pan-kot added this pull request to the merge queue Jul 17, 2026
Merged via the queue into main with commit 58313f2 Jul 17, 2026
59 checks passed
@pan-kot
pan-kot deleted the chore-stable-theme-hashes branch July 17, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants