diff --git a/web/package.json b/web/package.json index 616541d1b..19e77aae3 100644 --- a/web/package.json +++ b/web/package.json @@ -21,7 +21,7 @@ "@mui/x-data-grid-pro": "^6.0.0", "@mui/x-date-pickers": "^7.0.0", "@psu/cffdrs_ts": "git+https://github.com/cffdrs/cffdrs_ts#b9afdabc89dd4bdf04ccf1e406a4a5d8d552ff51", - "@reduxjs/toolkit": "^1.8.0", + "@reduxjs/toolkit": "^2.2.7", "@sentry/react": "^8.2.1", "@sentry/vite-plugin": "^2.22.4", "@types/esri-leaflet": "^3.0.0", @@ -56,7 +56,7 @@ "prettier": "^3.3.3", "react": "^18.3.1", "react-dom": "^18.3.1", - "react-redux": "^8.0.0", + "react-redux": "^9.1.2", "react-router-dom": "^6.22.3", "recharts": "^2.1.8", "typescript": "^5.2.2", diff --git a/web/src/app/store.ts b/web/src/app/store.ts index 6cb060c28..d39d11f33 100644 --- a/web/src/app/store.ts +++ b/web/src/app/store.ts @@ -1,5 +1,5 @@ import { configureStore, AnyAction, ThunkAction } from '@reduxjs/toolkit' -import thunk, { ThunkMiddleware } from 'redux-thunk' +import { thunk, ThunkMiddleware } from 'redux-thunk' import rootReducer, { RootState } from 'app/rootReducer' const thunkMiddleware: ThunkMiddleware = thunk diff --git a/web/src/features/auth/slices/authenticationSlice.test.ts b/web/src/features/auth/slices/authenticationSlice.test.ts index edf916dc5..d3388b2bb 100644 --- a/web/src/features/auth/slices/authenticationSlice.test.ts +++ b/web/src/features/auth/slices/authenticationSlice.test.ts @@ -53,7 +53,7 @@ describe('authenticationSlice', () => { it('should be initialized with correct state', () => { expect( authReducer(undefined, { - type: undefined + type: '' }) ).toEqual(initialState) }) diff --git a/web/src/features/hfiCalculator/slices/hfiCalculatorSlice.test.ts b/web/src/features/hfiCalculator/slices/hfiCalculatorSlice.test.ts index b20b4d3ad..751155cd2 100644 --- a/web/src/features/hfiCalculator/slices/hfiCalculatorSlice.test.ts +++ b/web/src/features/hfiCalculator/slices/hfiCalculatorSlice.test.ts @@ -11,7 +11,7 @@ describe('hfiCalculatorSlice', () => { describe('reducer', () => { const dummyError = 'an error' it('should be initialized with correct state flags', () => { - expect(hfiCalculatorDailiesReducer(undefined, { type: undefined })).toEqual(initialState) + expect(hfiCalculatorDailiesReducer(undefined, { type: '' })).toEqual(initialState) }) it('should set fuelTypesLoading = true when fetchFuelTypesStart is called', () => { expect(hfiCalculatorDailiesReducer(initialState, fetchFuelTypesStart())).toEqual({ diff --git a/web/src/features/hfiCalculator/slices/hfiReadySlice.test.ts b/web/src/features/hfiCalculator/slices/hfiReadySlice.test.ts index 2c50c7aca..dc0358391 100644 --- a/web/src/features/hfiCalculator/slices/hfiReadySlice.test.ts +++ b/web/src/features/hfiCalculator/slices/hfiReadySlice.test.ts @@ -12,7 +12,7 @@ describe('hfiReadySlice', () => { describe('reducer', () => { const dummyError = 'an error' it('should be initialized with correct state', () => { - expect(hfiReadyReducer(undefined, { type: undefined })).toEqual(initialState) + expect(hfiReadyReducer(undefined, { type: '' })).toEqual(initialState) }) it('should set loading = true when fetchFuelTypesStart is called', () => { expect(hfiReadyReducer(initialState, setHFIReadyStart())).toEqual({ diff --git a/web/src/features/moreCast2/components/editInputCell.test.tsx b/web/src/features/moreCast2/components/editInputCell.test.tsx index 250e4fe69..affc5555f 100644 --- a/web/src/features/moreCast2/components/editInputCell.test.tsx +++ b/web/src/features/moreCast2/components/editInputCell.test.tsx @@ -1,4 +1,4 @@ -import { render, fireEvent, within } from '@testing-library/react' +import { render, fireEvent, within, act } from '@testing-library/react' import { useDispatch } from 'react-redux' import { GridApiContext, GridCellMode, GridTreeNodeWithRender } from '@mui/x-data-grid-pro' import { EditInputCell } from '@/features/moreCast2/components/EditInputCell' @@ -44,8 +44,8 @@ vi.mock('@/features/moreCast2/slices/validInputSlice', () => ({ const mockDispatch = vi.fn() beforeEach(() => { - vi.clearAllMocks() - ;(useDispatch as jest.Mock).mockReturnValue(mockDispatch) + vi.clearAllMocks(); + (useDispatch as unknown as jest.Mock).mockReturnValue(mockDispatch) }) describe('EditInputCell', () => { @@ -77,7 +77,7 @@ describe('EditInputCell', () => { expect(mockSetEditCellValue).toHaveBeenCalledWith({ id: 1, field: 'test', value: '20' }) }) - test('should call stopCellEditMode on blur', () => { + test('should call stopCellEditMode on blur', async () => { const { getByTestId } = render( @@ -85,13 +85,14 @@ describe('EditInputCell', () => { ) const input = within(getByTestId('forecast-edit-cell')).getByRole('spinbutton') as HTMLInputElement - input.focus() - fireEvent.blur(input) - + await act(async () => { + input.focus() + fireEvent.blur(input) + }) expect(mockStopCellEditMode).toHaveBeenCalledWith({ id: 1, field: 'test' }) }) - test('should handle Escape key press', () => { + test('should handle Escape key press', async () => { const { getByTestId } = render( @@ -99,13 +100,15 @@ describe('EditInputCell', () => { ) const input = within(getByTestId('forecast-edit-cell')).getByRole('spinbutton') as HTMLInputElement - input.focus() - fireEvent.keyDown(input, { key: 'Escape', code: 'Escape', charCode: 27 }) + await act(async () => { + input.focus() + fireEvent.keyDown(input, { key: 'Escape', code: 'Escape', charCode: 27 }) + }) expect(mockStopCellEditMode).toHaveBeenCalledWith({ id: 1, field: 'test' }) }) - test('should not call stopCellEditMode when Escape key is pressed and there is an error', () => { + test('should not call stopCellEditMode when Escape key is pressed and there is an error', async () => { const { getByTestId } = render( @@ -113,9 +116,11 @@ describe('EditInputCell', () => { ) const input = within(getByTestId('forecast-edit-cell')).getByRole('spinbutton') as HTMLInputElement - input.focus() - // Simulate Escape key press - fireEvent.keyDown(input, { key: 'Escape', code: 'Escape', charCode: 27 }) + await act(async () => { + input.focus() + // Simulate Escape key press + fireEvent.keyDown(input, { key: 'Escape', code: 'Escape', charCode: 27 }) + }) // Verify that stopCellEditMode was not called expect(mockStopCellEditMode).not.toHaveBeenCalled() diff --git a/web/src/features/moreCast2/slices/dataSlice.test.ts b/web/src/features/moreCast2/slices/dataSlice.test.ts index e73d44bb1..247bae5f1 100644 --- a/web/src/features/moreCast2/slices/dataSlice.test.ts +++ b/web/src/features/moreCast2/slices/dataSlice.test.ts @@ -89,7 +89,7 @@ describe('dataSlice', () => { describe('reducer', () => { const dummyError = 'an error' it('should be initialized with correct state flags', () => { - expect(dataSliceReducer(undefined, { type: undefined })).toEqual(initialState) + expect(dataSliceReducer(undefined, { type: '' })).toEqual(initialState) }) it('should set loading = true when getWeatherIndeterminatesStart is called', () => { expect(dataSliceReducer(initialState, getWeatherIndeterminatesStart())).toEqual({ diff --git a/web/tsconfig.app.json b/web/tsconfig.app.json index b931148b8..c2a432d09 100644 --- a/web/tsconfig.app.json +++ b/web/tsconfig.app.json @@ -14,20 +14,13 @@ "jsx": "react-jsx", /* Linting */ "strict": true, - "types": [ - "vite/client", - "node" - ], + "types": ["vite/client", "node", "vitest/globals", "@testing-library/jest-dom"], "noUnusedLocals": false, // "noUnusedParameters": , "noFallthroughCasesInSwitch": true, //from old "target": "es2015", - "lib": [ - "dom", - "dom.iterable", - "esnext" - ], + "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, "esModuleInterop": true, @@ -36,36 +29,16 @@ "module": "esnext", "baseUrl": ".", "paths": { - "@/*": [ - "./src/*" - ], - "#root/*": [ - "./*" - ], - "app/*": [ - "./src/app/*" - ], - "utils/*": [ - "./src/utils/*" - ], - "api/*": [ - "./src/api/*" - ], - "features/*": [ - "./src/features/*" - ], - "components/*": [ - "src/components/*" - ], - "components": [ - "./src/components/index" - ], - "commonSlices/*": [ - "./src/commonSlices/*" - ], - }, + "@/*": ["./src/*"], + "#root/*": ["./*"], + "app/*": ["./src/app/*"], + "utils/*": ["./src/utils/*"], + "api/*": ["./src/api/*"], + "features/*": ["./src/features/*"], + "components/*": ["src/components/*"], + "components": ["./src/components/index"], + "commonSlices/*": ["./src/commonSlices/*"] + } }, - "include": [ - "src" - ] -} \ No newline at end of file + "include": ["src"] +} diff --git a/web/yarn.lock b/web/yarn.lock index 0594697db..26c7e7272 100644 --- a/web/yarn.lock +++ b/web/yarn.lock @@ -204,7 +204,7 @@ __metadata: languageName: node linkType: hard -"@babel/runtime@npm:^7.12.1, @babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.18.3, @babel/runtime@npm:^7.22.6, @babel/runtime@npm:^7.23.2, @babel/runtime@npm:^7.23.8, @babel/runtime@npm:^7.23.9, @babel/runtime@npm:^7.25.0, @babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.8.7, @babel/runtime@npm:^7.9.2": +"@babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.18.3, @babel/runtime@npm:^7.22.6, @babel/runtime@npm:^7.23.2, @babel/runtime@npm:^7.23.8, @babel/runtime@npm:^7.23.9, @babel/runtime@npm:^7.25.0, @babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.8.7": version: 7.25.0 resolution: "@babel/runtime@npm:7.25.0" dependencies: @@ -1240,23 +1240,23 @@ __metadata: languageName: node linkType: hard -"@reduxjs/toolkit@npm:^1.8.0": - version: 1.9.7 - resolution: "@reduxjs/toolkit@npm:1.9.7" +"@reduxjs/toolkit@npm:^2.2.7": + version: 2.2.7 + resolution: "@reduxjs/toolkit@npm:2.2.7" dependencies: - immer: "npm:^9.0.21" - redux: "npm:^4.2.1" - redux-thunk: "npm:^2.4.2" - reselect: "npm:^4.1.8" + immer: "npm:^10.0.3" + redux: "npm:^5.0.1" + redux-thunk: "npm:^3.1.0" + reselect: "npm:^5.1.0" peerDependencies: react: ^16.9.0 || ^17.0.0 || ^18 - react-redux: ^7.2.1 || ^8.0.2 + react-redux: ^7.2.1 || ^8.1.3 || ^9.0.0 peerDependenciesMeta: react: optional: true react-redux: optional: true - checksum: 10c0/fa0aa4b7c6973ac87ce0ac7e45faa02c73b66c4ee0bc950d178494539a42a1bb908d109297102458b7ea14d5e7dae356e7a7ce9a1b9849b0e8451e6dd70fca9c + checksum: 10c0/7761a91adac2b5e1d50a8163ba5441480bb86a3a80b7583037c27a88463394b132dd7592862fc2be03aa7ab98a6e1710549889986dc0d3f033c169a3ba2cb02e languageName: node linkType: hard @@ -2062,16 +2062,6 @@ __metadata: languageName: node linkType: hard -"@types/hoist-non-react-statics@npm:^3.3.1": - version: 3.3.5 - resolution: "@types/hoist-non-react-statics@npm:3.3.5" - dependencies: - "@types/react": "npm:*" - hoist-non-react-statics: "npm:^3.3.0" - checksum: 10c0/2a3b64bf3d9817d7830afa60ee314493c475fb09570a64e7737084cd482d2177ebdddf888ce837350bac51741278b077683facc9541f052d4bbe8487b4e3e618 - languageName: node - linkType: hard - "@types/istanbul-lib-coverage@npm:*, @types/istanbul-lib-coverage@npm:^2.0.0": version: 2.0.6 resolution: "@types/istanbul-lib-coverage@npm:2.0.6" @@ -2098,12 +2088,12 @@ __metadata: linkType: hard "@types/jest@npm:^29.5.12": - version: 29.5.12 - resolution: "@types/jest@npm:29.5.12" + version: 29.5.13 + resolution: "@types/jest@npm:29.5.13" dependencies: expect: "npm:^29.0.0" pretty-format: "npm:^29.0.0" - checksum: 10c0/25fc8e4c611fa6c4421e631432e9f0a6865a8cb07c9815ec9ac90d630271cad773b2ee5fe08066f7b95bebd18bb967f8ce05d018ee9ab0430f9dfd1d84665b6f + checksum: 10c0/9c31af0b155387b9860908830de63c6b79011d7c87c8b61b39da124e26e55423dd51b006749aafe4f0ef3a065016619a1f93ef4b055157d43727f448e67824b7 languageName: node linkType: hard @@ -5252,7 +5242,7 @@ __metadata: languageName: node linkType: hard -"hoist-non-react-statics@npm:^3.3.0, hoist-non-react-statics@npm:^3.3.1, hoist-non-react-statics@npm:^3.3.2": +"hoist-non-react-statics@npm:^3.3.1, hoist-non-react-statics@npm:^3.3.2": version: 3.3.2 resolution: "hoist-non-react-statics@npm:3.3.2" dependencies: @@ -5369,10 +5359,10 @@ __metadata: languageName: node linkType: hard -"immer@npm:^9.0.21": - version: 9.0.21 - resolution: "immer@npm:9.0.21" - checksum: 10c0/03ea3ed5d4d72e8bd428df4a38ad7e483ea8308e9a113d3b42e0ea2cc0cc38340eb0a6aca69592abbbf047c685dbda04e3d34bf2ff438ab57339ed0a34cc0a05 +"immer@npm:^10.0.3": + version: 10.1.1 + resolution: "immer@npm:10.1.1" + checksum: 10c0/b749e10d137ccae91788f41bd57e9387f32ea6d6ea8fd7eb47b23fd7766681575efc7f86ceef7fe24c3bc9d61e38ff5d2f49c2663b2b0c056e280a4510923653 languageName: node linkType: hard @@ -7588,35 +7578,22 @@ __metadata: languageName: node linkType: hard -"react-redux@npm:^8.0.0": - version: 8.1.3 - resolution: "react-redux@npm:8.1.3" +"react-redux@npm:^9.1.2": + version: 9.1.2 + resolution: "react-redux@npm:9.1.2" dependencies: - "@babel/runtime": "npm:^7.12.1" - "@types/hoist-non-react-statics": "npm:^3.3.1" "@types/use-sync-external-store": "npm:^0.0.3" - hoist-non-react-statics: "npm:^3.3.2" - react-is: "npm:^18.0.0" use-sync-external-store: "npm:^1.0.0" peerDependencies: - "@types/react": ^16.8 || ^17.0 || ^18.0 - "@types/react-dom": ^16.8 || ^17.0 || ^18.0 - react: ^16.8 || ^17.0 || ^18.0 - react-dom: ^16.8 || ^17.0 || ^18.0 - react-native: ">=0.59" - redux: ^4 || ^5.0.0-beta.0 + "@types/react": ^18.2.25 + react: ^18.0 + redux: ^5.0.0 peerDependenciesMeta: "@types/react": optional: true - "@types/react-dom": - optional: true - react-dom: - optional: true - react-native: - optional: true redux: optional: true - checksum: 10c0/64c8be2765568dc66a3c442a41dd0ed74fe048d5ceb7a4fe72e5bac3d3687996a7115f57b5156af7406521087065a0e60f9194318c8ca99c55e9ce48558980ce + checksum: 10c0/56ac98228e011b26e0202346af9c8dd408ad5ea8235d8761c8e05ea0953b8ca801cdf9d1f481fdec7b285d7f30ceef7238b46b3df7636ef77dd5c2ea8c5be5b2 languageName: node linkType: hard @@ -7736,21 +7713,19 @@ __metadata: languageName: node linkType: hard -"redux-thunk@npm:^2.4.2": - version: 2.4.2 - resolution: "redux-thunk@npm:2.4.2" +"redux-thunk@npm:^3.1.0": + version: 3.1.0 + resolution: "redux-thunk@npm:3.1.0" peerDependencies: - redux: ^4 - checksum: 10c0/e202d6ef7dfa7df08ed24cb221aa89d6c84dbaa7d65fe90dbd8e826d0c10d801f48388f9a7598a4fd970ecbc93d335014570a61ca7bc8bf569eab5de77b31a3c + redux: ^5.0.0 + checksum: 10c0/21557f6a30e1b2e3e470933247e51749be7f1d5a9620069a3125778675ce4d178d84bdee3e2a0903427a5c429e3aeec6d4df57897faf93eb83455bc1ef7b66fd languageName: node linkType: hard -"redux@npm:^4.2.1": - version: 4.2.1 - resolution: "redux@npm:4.2.1" - dependencies: - "@babel/runtime": "npm:^7.9.2" - checksum: 10c0/136d98b3d5dbed1cd6279c8c18a6a74c416db98b8a432a46836bdd668475de6279a2d4fd9d1363f63904e00f0678a8a3e7fa532c897163340baf1e71bb42c742 +"redux@npm:^5.0.1": + version: 5.0.1 + resolution: "redux@npm:5.0.1" + checksum: 10c0/b10c28357194f38e7d53b760ed5e64faa317cc63de1fb95bc5d9e127fab956392344368c357b8e7a9bedb0c35b111e7efa522210cfdc3b3c75e5074718e9069c languageName: node linkType: hard @@ -7841,6 +7816,13 @@ __metadata: languageName: node linkType: hard +"reselect@npm:^5.1.0": + version: 5.1.1 + resolution: "reselect@npm:5.1.1" + checksum: 10c0/219c30da122980f61853db3aebd173524a2accd4b3baec770e3d51941426c87648a125ca08d8c57daa6b8b086f2fdd2703cb035dd6231db98cdbe1176a71f489 + languageName: node + linkType: hard + "resolve-from@npm:^4.0.0": version: 4.0.0 resolution: "resolve-from@npm:4.0.0" @@ -9508,7 +9490,7 @@ __metadata: "@mui/x-data-grid-pro": "npm:^6.0.0" "@mui/x-date-pickers": "npm:^7.0.0" "@psu/cffdrs_ts": "git+https://github.com/cffdrs/cffdrs_ts#b9afdabc89dd4bdf04ccf1e406a4a5d8d552ff51" - "@reduxjs/toolkit": "npm:^1.8.0" + "@reduxjs/toolkit": "npm:^2.2.7" "@sentry/react": "npm:^8.2.1" "@sentry/vite-plugin": "npm:^2.22.4" "@testing-library/dom": "npm:^10.1.0" @@ -9555,7 +9537,7 @@ __metadata: prettier: "npm:^3.3.3" react: "npm:^18.3.1" react-dom: "npm:^18.3.1" - react-redux: "npm:^8.0.0" + react-redux: "npm:^9.1.2" react-router-dom: "npm:^6.22.3" recharts: "npm:^2.1.8" start-server-and-test: "npm:^2.0.0"