From e57d5b2a1c6dd1c24604bd91860bb51db746766c Mon Sep 17 00:00:00 2001 From: Chris Chudzicki Date: Thu, 19 Dec 2024 11:33:09 -0500 Subject: [PATCH] Update version of react used in tests to same as production (#1917) * update version of react used in tests * upgrade test version of react to 19, same major as prod --- frontends/api/package.json | 2 +- frontends/main/package.json | 8 +-- .../ChannelPage/ChannelPage.test.tsx | 10 ++-- frontends/main/src/test-utils/index.tsx | 4 +- frontends/ol-components/package.json | 6 +-- frontends/ol-utilities/package.json | 4 +- yarn.lock | 49 ++++++++++++++----- 7 files changed, 52 insertions(+), 31 deletions(-) diff --git a/frontends/api/package.json b/frontends/api/package.json index 12acd63404..85ece5ca75 100644 --- a/frontends/api/package.json +++ b/frontends/api/package.json @@ -15,7 +15,7 @@ "./test-utils": "./src/test-utils/index.ts" }, "peerDependencies": { - "react": "18.3.1" + "react": "^19" }, "devDependencies": { "@faker-js/faker": "^9.0.0", diff --git a/frontends/main/package.json b/frontends/main/package.json index ab065e386e..484671c5e6 100644 --- a/frontends/main/package.json +++ b/frontends/main/package.json @@ -25,8 +25,8 @@ "ol-components": "0.0.0", "ol-utilities": "0.0.0", "posthog-js": "^1.157.2", - "react": "^18", - "react-dom": "^18", + "react": "^19.0.0", + "react-dom": "^19.0.0", "react-slick": "^0.30.2", "slick-carousel": "^1.8.1", "tiny-invariant": "^1.3.3", @@ -40,8 +40,8 @@ "@types/jest": "^29.5.12", "@types/lodash": "^4.17.7", "@types/node": "^22.0.0", - "@types/react": "^18.3.5", - "@types/react-dom": "^18.3.0", + "@types/react": "^19", + "@types/react-dom": "^19", "@types/react-slick": "^0.23.13", "@types/slick-carousel": "^1", "eslint": "8.57.1", diff --git a/frontends/main/src/app-pages/ChannelPage/ChannelPage.test.tsx b/frontends/main/src/app-pages/ChannelPage/ChannelPage.test.tsx index 2c85049974..663fd61535 100644 --- a/frontends/main/src/app-pages/ChannelPage/ChannelPage.test.tsx +++ b/frontends/main/src/app-pages/ChannelPage/ChannelPage.test.tsx @@ -7,6 +7,7 @@ import { setMockResponse, waitFor, renderWithProviders, + expectLastProps, } from "@/test-utils" import ChannelSearch from "./ChannelSearch" import { assertHeadings, getByImageSrc } from "ol-test-utilities" @@ -176,18 +177,13 @@ describe.each(ALL_CHANNEL_TYPES)( setupTopicApis(channel) } await screen.findAllByText(channel.title) - const expectedProps = expect.objectContaining({ + + expectLastProps(mockedChannelSearch, { constantSearchParams: { platform: ["ocw", "mitxonline"], department: ["8", "9"], }, }) - const expectedContext = expect.anything() - - expect(mockedChannelSearch).toHaveBeenLastCalledWith( - expectedProps, - expectedContext, - ) }, 10000) it("Does not display the channel search if search_filter is undefined", async () => { const { channel } = setupApis({ diff --git a/frontends/main/src/test-utils/index.tsx b/frontends/main/src/test-utils/index.tsx index 877d8f684e..e757556e45 100644 --- a/frontends/main/src/test-utils/index.tsx +++ b/frontends/main/src/test-utils/index.tsx @@ -107,7 +107,7 @@ const expectProps = ( ) => { expect(fc).toHaveBeenCalledWith( expect.objectContaining(partialProps), - expect.anything(), + expect.toBeOneOf([expect.anything(), undefined]), ) } @@ -124,7 +124,7 @@ const expectLastProps = ( ) => { expect(fc).toHaveBeenLastCalledWith( expect.objectContaining(partialProps), - expect.anything(), + expect.toBeOneOf([expect.anything(), undefined]), ) } diff --git a/frontends/ol-components/package.json b/frontends/ol-components/package.json index afbb93a112..ca26a8b51c 100644 --- a/frontends/ol-components/package.json +++ b/frontends/ol-components/package.json @@ -24,7 +24,7 @@ "@mui/system": "^6.1.6", "@remixicon/react": "^4.2.0", "@testing-library/dom": "^10.4.0", - "@types/react-dom": "^18.3.0", + "@types/react-dom": "^19", "@types/tinycolor2": "^1.4.6", "api": "workspace:*", "classnames": "^2.5.1", @@ -34,8 +34,8 @@ "next": "^15.0.2", "ol-test-utilities": "0.0.0", "ol-utilities": "0.0.0", - "react": "18.3.1", - "react-dom": "^18.3.1", + "react": "^19.0.0", + "react-dom": "^19.0.0", "react-router": "^6.22.2", "react-router-dom": "^6.22.2", "react-select": "^5.7.7", diff --git a/frontends/ol-utilities/package.json b/frontends/ol-utilities/package.json index 167872da91..fc9ad43077 100644 --- a/frontends/ol-utilities/package.json +++ b/frontends/ol-utilities/package.json @@ -7,8 +7,8 @@ "./test-utils/factories": "./src/test-utils/factories.ts" }, "peerDependencies": { - "next": "^14.2.15", - "react": "18.3.1" + "next": "^15", + "react": "19" }, "sideEffects": false, "dependencies": { diff --git a/yarn.lock b/yarn.lock index d20a3dfc58..6a09e07318 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6529,7 +6529,7 @@ __metadata: lodash: "npm:^4.17.21" ol-test-utilities: "npm:0.0.0" peerDependencies: - react: 18.3.1 + react: ^19 languageName: unknown linkType: soft @@ -12675,8 +12675,8 @@ __metadata: "@types/jest": "npm:^29.5.12" "@types/lodash": "npm:^4.17.7" "@types/node": "npm:^22.0.0" - "@types/react": "npm:^18.3.5" - "@types/react-dom": "npm:^18.3.0" + "@types/react": "npm:^19" + "@types/react-dom": "npm:^19" "@types/react-slick": "npm:^0.23.13" "@types/slick-carousel": "npm:^1" api: "workspace:*" @@ -12693,8 +12693,8 @@ __metadata: ol-test-utilities: "npm:0.0.0" ol-utilities: "npm:0.0.0" posthog-js: "npm:^1.157.2" - react: "npm:^18" - react-dom: "npm:^18" + react: "npm:^19.0.0" + react-dom: "npm:^19.0.0" react-slick: "npm:^0.30.2" slick-carousel: "npm:^1.8.1" tiny-invariant: "npm:^1.3.3" @@ -14343,7 +14343,7 @@ __metadata: "@testing-library/dom": "npm:^10.4.0" "@testing-library/react": "npm:^16.0.1" "@testing-library/user-event": "npm:14.5.2" - "@types/react-dom": "npm:^18.3.0" + "@types/react-dom": "npm:^19" "@types/react-slick": "npm:^0" "@types/tinycolor2": "npm:^1.4.6" api: "workspace:*" @@ -14356,8 +14356,8 @@ __metadata: ol-test-utilities: "npm:0.0.0" ol-utilities: "npm:0.0.0" prop-types: "npm:^15.8.1" - react: "npm:18.3.1" - react-dom: "npm:^18.3.1" + react: "npm:^19.0.0" + react-dom: "npm:^19.0.0" react-router: "npm:^6.22.2" react-router-dom: "npm:^6.22.2" react-select: "npm:^5.7.7" @@ -14411,8 +14411,8 @@ __metadata: striptags: "npm:^3.2.0" tiny-invariant: "npm:^1.3.1" peerDependencies: - next: ^14.2.15 - react: 18.3.1 + next: ^15 + react: 19 languageName: unknown linkType: soft @@ -15455,7 +15455,7 @@ __metadata: languageName: node linkType: hard -"react-dom@npm:^16.8.0 || ^17.0.0 || ^18.0.0, react-dom@npm:^18, react-dom@npm:^18.3.1": +"react-dom@npm:^16.8.0 || ^17.0.0 || ^18.0.0": version: 18.3.1 resolution: "react-dom@npm:18.3.1" dependencies: @@ -15467,6 +15467,17 @@ __metadata: languageName: node linkType: hard +"react-dom@npm:^19.0.0": + version: 19.0.0 + resolution: "react-dom@npm:19.0.0" + dependencies: + scheduler: "npm:^0.25.0" + peerDependencies: + react: ^19.0.0 + checksum: 10/aa64a2f1991042f516260e8b0eca0ae777b6c8f1aa2b5ae096e80bbb6ac9b005aef2bca697969841d34f7e1819556263476bdfea36c35092e8d9aefde3de2d9a + languageName: node + linkType: hard + "react-element-to-jsx-string@npm:^15.0.0": version: 15.0.0 resolution: "react-element-to-jsx-string@npm:15.0.0" @@ -15630,7 +15641,7 @@ __metadata: languageName: node linkType: hard -"react@npm:18.3.1, react@npm:^16.8.0 || ^17.0.0 || ^18.0.0, react@npm:^18": +"react@npm:^16.8.0 || ^17.0.0 || ^18.0.0": version: 18.3.1 resolution: "react@npm:18.3.1" dependencies: @@ -15639,6 +15650,13 @@ __metadata: languageName: node linkType: hard +"react@npm:^19.0.0": + version: 19.0.0 + resolution: "react@npm:19.0.0" + checksum: 10/2490969c503f644703c88990d20e4011fa6119ddeca451e9de48f6d7ab058d670d2852a5fcd3aa3cd90a923ab2815d532637bd4a814add402ae5c0d4f129ee71 + languageName: node + linkType: hard + "read-package-json-fast@npm:^3.0.0": version: 3.0.2 resolution: "read-package-json-fast@npm:3.0.2" @@ -16259,6 +16277,13 @@ __metadata: languageName: node linkType: hard +"scheduler@npm:^0.25.0": + version: 0.25.0 + resolution: "scheduler@npm:0.25.0" + checksum: 10/e661e38503ab29a153429a99203fefa764f28b35c079719eb5efdd2c1c1086522f6653d8ffce388209682c23891a6d1d32fa6badf53c35fb5b9cd0c55ace42de + languageName: node + linkType: hard + "schema-utils@npm:^3.1.1, schema-utils@npm:^3.2.0": version: 3.3.0 resolution: "schema-utils@npm:3.3.0"