Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .nx/version-plans/version-plan-1775222101294.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
gamut-illustrations: major
gamut-patterns: major
gamut-styles: major
gamut-icons: major
gamut-tests: major
variance: major
gamut: major
---

Update to React 19 compatibility
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"@vidstack/react": "^1.12.12",
"core-js": "3.7.0",
"lodash": "^4.17.23",
"react": "18.3.1",
"react-dom": "18.3.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-helmet-async": "^2.0.5"
},
"devDependencies": {
Expand Down Expand Up @@ -42,18 +42,18 @@
"@svgr/cli": "5.5.0",
"@swc-node/register": "^1.11.1",
"@swc/core": "^1.15.18",
"@testing-library/dom": "^8.11.1",
"@testing-library/dom": "^10.0.0",
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "15.0.6",
"@testing-library/react": "^16.0.0",
"@testing-library/react-hooks": "^7.0.2",
"@testing-library/user-event": "^14.5.2",
"@types/classnames": "2.2.10",
"@types/invariant": "2.2.29",
"@types/konami-code-js": "^0.8.0",
"@types/lodash": "4.17.23",
"@types/react": "18.3.27",
"@types/react-dom": "18.3.1",
"@types/react-test-renderer": "18.3.0",
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
"@types/react-test-renderer": "^19.0.0",
"@types/stylis": "^4.2.0",
"@typescript-eslint/eslint-plugin": "^5.15.0",
"@typescript-eslint/parser": "^5.15.0",
Expand Down Expand Up @@ -82,7 +82,7 @@
"onchange": "^7.0.2",
"playwright": "^1.49.1",
"prettier": "^2.8.7",
"react-test-renderer": "18.3.1",
"react-test-renderer": "^19.0.0",
"start-server-and-test": "^2.1.5",
"storybook": "^10.3.1",
"storybook-addon-deep-controls": "^0.9.5",
Expand Down Expand Up @@ -113,13 +113,13 @@
"repository": "git@github.com:Codecademy/gamut.git",
"resolutions": {
"@react-aria/interactions": "3.25.0",
"@types/react": "18.3.27",
"@types/react-dom": "18.3.1",
"@types/react-dom": "^19.0.0",
"@types/react": "^19.0.0",
"@typescript-eslint/utils": "^5.15.0",
"axios": "1.14.0",
"error-ex": "1.3.4",
"react": "18.3.1",
"react-dom": "18.3.1"
"react-dom": "^19.0.0",
"react": "^19.0.0"
},
"scripts": {
"build": "nx run-many --target=build --all",
Expand Down
2 changes: 1 addition & 1 deletion packages/gamut-icons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@emotion/react": "^11.4.0",
"@emotion/styled": "^11.3.0",
"lodash": "^4.17.23",
"react": "^17.0.2 || ^18.3.0"
"react": "^17.0.2 || ^18.3.0 || ^19.0.0"
},
"publishConfig": {
"access": "public"
Expand Down
4 changes: 2 additions & 2 deletions packages/gamut-illustrations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"peerDependencies": {
"@emotion/react": "^11.4.0",
"@emotion/styled": "^11.3.0",
"react": "^17.0.2 || ^18.3.0",
"react-dom": "^17.0.2 || ^18.3.0"
"react": "^17.0.2 || ^18.3.0 || ^19.0.0",
"react-dom": "^17.0.2 || ^18.3.0 || ^19.0.0"
},
"publishConfig": {
"access": "public"
Expand Down
4 changes: 2 additions & 2 deletions packages/gamut-patterns/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"peerDependencies": {
"@emotion/react": "^11.4.0",
"@emotion/styled": "^11.3.0",
"react": "^17.0.2 || ^18.3.0",
"react-dom": "^17.0.2 || ^18.3.0"
"react": "^17.0.2 || ^18.3.0 || ^19.0.0",
"react-dom": "^17.0.2 || ^18.3.0 || ^19.0.0"
},
"publishConfig": {
"access": "public"
Expand Down
4 changes: 2 additions & 2 deletions packages/gamut-styles/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dependencies": {
"@codecademy/variance": "0.26.1",
"@emotion/is-prop-valid": "^1.1.0",
"framer-motion": "^11.18.0",
"framer-motion": "^12.0.0",
"get-nonce": "^1.0.0",
"polished": "^4.1.2"
},
Expand All @@ -26,7 +26,7 @@
"@emotion/react": "^11.4.0",
"@emotion/styled": "^11.3.0",
"lodash": "^4.17.23",
"react": "^17.0.2 || ^18.3.0",
"react": "^17.0.2 || ^18.3.0 || ^19.0.0",
"stylis": "^4.0.7"
},
"publishConfig": {
Expand Down
60 changes: 43 additions & 17 deletions packages/gamut-styles/src/__tests__/AssetProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { render } from '@testing-library/react';

import { AssetProvider, createFontLinks } from '../AssetProvider';
import { coreTheme, percipioTheme } from '../themes';
import { getFontsMock } from './fontUtilsMock';
import { setupRtl } from './testUtils';

const renderView = setupRtl(AssetProvider, {});

jest.mock('../utils/fontUtils', () => ({
getFonts: jest.fn(),
getFonts: require('./fontUtilsMock').getFontsMock,
}));

jest.mock('../remoteAssets/fonts', () => ({
Expand Down Expand Up @@ -43,11 +44,36 @@ jest.mock('../remoteAssets/fonts', () => ({
},
}));

const mockGetFonts = require('../utils/fontUtils').getFonts;
const mockGetFonts = getFontsMock;

function getPreloadLinks(container: HTMLElement): NodeListOf<Element> {
const inContainer = container.querySelectorAll('link[rel="preload"]');
if (inContainer.length > 0) return inContainer;
return document.querySelectorAll('link[rel="preload"]');
}

const defaultFonts = [
{
filePath: 'https://www.codecademy.com/gamut/apercu-regular-pro',
extensions: ['woff2', 'woff'],
name: 'Apercu',
},
{
filePath: 'https://www.codecademy.com/gamut/apercu-bold-pro',
extensions: ['woff2', 'woff'],
name: 'Apercu',
weight: 'bold',
},
];

describe('AssetProvider', () => {
beforeEach(() => {
jest.clearAllMocks();
mockGetFonts.mockReturnValue(defaultFonts);
});

afterEach(() => {
mockGetFonts.mockReturnValue(defaultFonts);
});

describe('createFontLinks', () => {
Expand All @@ -66,7 +92,7 @@ describe('AssetProvider', () => {
];

const { container } = render(<>{createFontLinks(fonts)}</>);
const links = container.querySelectorAll('link[rel="preload"]');
const links = getPreloadLinks(container);

expect(links).toHaveLength(1);
expect(links[0]).toHaveAttribute(
Expand All @@ -80,13 +106,13 @@ describe('AssetProvider', () => {

it('should handle empty fonts array', () => {
const { container } = render(<>{createFontLinks([])}</>);
const links = container.querySelectorAll('link[rel="preload"]');
const links = getPreloadLinks(container);
expect(links).toHaveLength(0);
});

it('should handle undefined fonts parameter', () => {
const { container } = render(<>{createFontLinks(undefined)}</>);
const links = container.querySelectorAll('link[rel="preload"]');
const links = getPreloadLinks(container);
expect(links).toHaveLength(2);
});

Expand All @@ -110,7 +136,7 @@ describe('AssetProvider', () => {
];

const { container } = render(<>{createFontLinks(fonts)}</>);
const links = container.querySelectorAll('link[rel="preload"]');
const links = getPreloadLinks(container);
expect(links).toHaveLength(1);
expect(links[0]).toHaveAttribute(
'href',
Expand Down Expand Up @@ -139,7 +165,7 @@ describe('AssetProvider', () => {
];

const { container } = render(<>{createFontLinks(fonts)}</>);
const links = container.querySelectorAll('link[rel="preload"]');
const links = getPreloadLinks(container);
expect(links).toHaveLength(2);
});
});
Expand All @@ -155,14 +181,14 @@ describe('AssetProvider', () => {
]);

const { view } = renderView();
const links = view.container.querySelectorAll('link[rel="preload"]');
const links = getPreloadLinks(view.container);

expect(mockGetFonts).toHaveBeenCalledWith('core');
expect(links).toHaveLength(1);
expect(links[0]).toHaveAttribute(
'href',
'https://www.codecademy.com/gamut/apercu-regular-pro.woff2'
);
expect(mockGetFonts).toHaveBeenCalledWith('core');
});

it('should render font links for percipio theme', () => {
Expand All @@ -175,7 +201,7 @@ describe('AssetProvider', () => {
]);

const { view } = renderView({ theme: percipioTheme as any });
const links = view.container.querySelectorAll('link[rel="preload"]');
const links = getPreloadLinks(view.container);

expect(links).toHaveLength(1);
expect(links[0]).toHaveAttribute(
Expand Down Expand Up @@ -207,31 +233,31 @@ describe('AssetProvider', () => {
});

const { view } = renderView();
const links = view.container.querySelectorAll('link[rel="preload"]');
const links = getPreloadLinks(view.container);
expect(links).toHaveLength(0);
});

it('should fallback to core fonts when getFonts returns undefined', () => {
mockGetFonts.mockReturnValue(undefined);

const { view } = renderView();
const links = view.container.querySelectorAll('link[rel="preload"]');
const links = getPreloadLinks(view.container);
expect(links).toHaveLength(2);
});

it('should fallback to core fonts when getFonts returns null', () => {
mockGetFonts.mockReturnValue(null);

const { view } = renderView();
const links = view.container.querySelectorAll('link[rel="preload"]');
const links = getPreloadLinks(view.container);
expect(links).toHaveLength(2);
});

it('should fallback to core fonts when getFonts returns non-array', () => {
mockGetFonts.mockReturnValue('not-an-array');

const { view } = renderView();
const links = view.container.querySelectorAll('link[rel="preload"]');
const links = getPreloadLinks(view.container);
expect(links).toHaveLength(0);
});

Expand All @@ -255,7 +281,7 @@ describe('AssetProvider', () => {
]);

const { view } = renderView();
const links = view.container.querySelectorAll('link[rel="preload"]');
const links = getPreloadLinks(view.container);

expect(links).toHaveLength(3);
expect(links[0]).toHaveAttribute(
Expand Down Expand Up @@ -292,7 +318,7 @@ describe('AssetProvider', () => {
]);

const { view } = renderView();
const links = view.container.querySelectorAll('link[rel="preload"]');
const links = getPreloadLinks(view.container);

expect(links).toHaveLength(1);
expect(links[0]).toHaveAttribute(
Expand Down Expand Up @@ -321,7 +347,7 @@ describe('AssetProvider', () => {
]);

const { view } = renderView();
const links = view.container.querySelectorAll('link[rel="preload"]');
const links = getPreloadLinks(view.container);

expect(links).toHaveLength(1);
expect(links[0]).toHaveAttribute(
Expand Down
Loading
Loading