diff --git a/build-tools/utils/__tests__/token-versions.test.js b/build-tools/utils/__tests__/token-versions.test.js index 48e8c41f0b..aa0e07825c 100644 --- a/build-tools/utils/__tests__/token-versions.test.js +++ b/build-tools/utils/__tests__/token-versions.test.js @@ -7,27 +7,37 @@ const { getTokenVersions } = require('../token-versions'); const variablesMap = { borderRadiusButton: 'border-radius-button', borderWidthField: 'border-width-field', + colorChartsPurple300: 'color-charts-purple-300', colorBorderButtonNormalDefault: 'color-border-button-normal-default', + colorBackgroundPopover: 'color-background-popover', + colorTextControlDisabled: 'color-text-control-disabled', colorTextAccent: 'color-text-accent', spaceScaledM: 'space-scaled-m', + sizeIconMedium: 'size-icon-m', fontFamilyBase: 'font-family-base', + shadowModal: 'shadow-modal', }; -test('versions border tokens matched by the default groups and leaves others (incl. border colors) version-less', () => { +test('versions border + typography tokens matched by the default groups and leaves others (incl. border colors) version-less', () => { expect(getTokenVersions(variablesMap)).toEqual({ borderRadiusButton: 'v3-1', borderWidthField: 'v3-1', + fontFamilyBase: 'v3-1', }); }); test('assigns the version of the first matching group', () => { const groups = [ { pattern: /^color-border-/, version: 'v3-2' }, + { pattern: /^color-text-/, version: 'v3-2' }, { pattern: /^color-/, version: 'v3-1' }, ]; expect(getTokenVersions(variablesMap, groups)).toEqual({ + colorBackgroundPopover: 'v3-1', colorBorderButtonNormalDefault: 'v3-2', - colorTextAccent: 'v3-1', + colorChartsPurple300: 'v3-1', + colorTextAccent: 'v3-2', + colorTextControlDisabled: 'v3-2', }); }); @@ -37,6 +47,6 @@ test('a catch-all group versions every token', () => { }); test('returns an empty map when no group matches', () => { - const groups = [{ pattern: /^color-background-/, version: 'v3-1' }]; + const groups = [{ pattern: /^motion-duration-/, version: 'v3-1' }]; expect(getTokenVersions(variablesMap, groups)).toEqual({}); }); diff --git a/build-tools/utils/token-versions.js b/build-tools/utils/token-versions.js index 955cba72a6..28600b9577 100644 --- a/build-tools/utils/token-versions.js +++ b/build-tools/utils/token-versions.js @@ -4,8 +4,13 @@ const DEFAULT_TOKEN_VERSION = 'v3-1'; // 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 }]; +// Tokens matching no group stay version-less and keep the legacy value-based hashes. Tokens are +// being migrated in batches (one batch per line), and eventually all tokens will be migrated to +// the new format. +const versionGroups = [ + { pattern: /^border-/, version: DEFAULT_TOKEN_VERSION }, + { pattern: /^(font|letter-spacing|line-height)-/, version: DEFAULT_TOKEN_VERSION }, +]; // Builds the token -> version allowlist from the full token -> cssName map. function getTokenVersions(variablesMap, groups = versionGroups) {