CONSOLE-5073: Bump redux-related shared modules to latest#16087
CONSOLE-5073: Bump redux-related shared modules to latest#16087logonoff wants to merge 2 commits intoopenshift:mainfrom
Conversation
|
@logonoff: This pull request references CONSOLE-5073 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
/label px-approved |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: logonoff The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@logonoff: This pull request references CONSOLE-5073 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
📝 WalkthroughWalkthroughThis pull request updates Redux ecosystem dependencies in the frontend package: react-redux from 8.1.3 to 9.2.0, redux from ^4.0.4 to ^5.0.1, and redux-thunk from 2.4.0 to 3.1.0, while removing redux-mock-store. Import statements for redux-thunk across test files are changed from default imports to named imports. Test mock variables are refactored with stricter TypeScript typing using 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
frontend/packages/console-shared/src/components/editor/__tests__/CodeEditorToolbar.spec.tsx (1)
27-31: Add defaultuseOLSConfigMockreturn inbeforeEachto strengthen test isolation.Tests at lines 33-36 and 38-41 don't set
useOLSConfigMock, yet rely on it being in a default state. Sincejest.clearAllMocks()preservesmockReturnValueimplementations and only clears call history, tests become order-dependent: if a prior test setsuseOLSConfigMock.mockReturnValue(true), that persists into tests expecting falsy behavior. AddinguseOLSConfigMock.mockReturnValue(false)inbeforeEachremoves this fragility and ensures each test starts with a predictable, documented baseline.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@frontend/packages/console-shared/src/components/editor/__tests__/CodeEditorToolbar.spec.tsx` around lines 27 - 31, The tests are order-dependent because useOLSConfigMock's mockReturnValue can leak between tests; update the beforeEach setup (the beforeEach block that currently calls jest.clearAllMocks(), useTranslationMock.mockReturnValue, and useDispatchMock.mockReturnValue) to also set a clear default for useOLSConfigMock by calling useOLSConfigMock.mockReturnValue(false) so each test starts with a predictable falsy OLS config; keep the other mockReturnValue calls (useTranslationMock and useDispatchMock) as-is and ensure mockDispatch remains used for useDispatchMock.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@frontend/packages/console-dynamic-plugin-sdk/release-notes/4.22.md`:
- Line 14: The release note text incorrectly references the package name
"react-thunk"; update that string to "redux-thunk" so the line reads that
plugins must use `redux-thunk` v3 to remain compatible with Console (replace
"react-thunk" with "redux-thunk" in the release note content), ensuring
consistency with package.json/shared-modules-meta.ts and all imports referencing
redux-thunk.
---
Nitpick comments:
In
`@frontend/packages/console-shared/src/components/editor/__tests__/CodeEditorToolbar.spec.tsx`:
- Around line 27-31: The tests are order-dependent because useOLSConfigMock's
mockReturnValue can leak between tests; update the beforeEach setup (the
beforeEach block that currently calls jest.clearAllMocks(),
useTranslationMock.mockReturnValue, and useDispatchMock.mockReturnValue) to also
set a clear default for useOLSConfigMock by calling
useOLSConfigMock.mockReturnValue(false) so each test starts with a predictable
falsy OLS config; keep the other mockReturnValue calls (useTranslationMock and
useDispatchMock) as-is and ensure mockDispatch remains used for useDispatchMock.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to data retention organization setting
⛔ Files ignored due to path filters (1)
frontend/yarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (16)
frontend/package.jsonfrontend/packages/console-app/src/components/detect-namespace/__tests__/namespace.spec.tsfrontend/packages/console-app/src/components/tour/__tests__/tour-context.spec.tsfrontend/packages/console-dynamic-plugin-sdk/release-notes/4.22.mdfrontend/packages/console-dynamic-plugin-sdk/src/utils/k8s/hooks/__tests__/useK8sModels.spec.tsxfrontend/packages/console-dynamic-plugin-sdk/src/utils/k8s/hooks/__tests__/useK8sWatchResource.spec.tsxfrontend/packages/console-dynamic-plugin-sdk/src/utils/k8s/hooks/__tests__/useK8sWatchResources.spec.tsxfrontend/packages/console-shared/src/components/editor/__tests__/CodeEditorToolbar.spec.tsxfrontend/packages/console-shared/src/hooks/__tests__/useGetUserSettingConfigMap.spec.tsfrontend/packages/console-shared/src/hooks/__tests__/useUser.spec.tsfrontend/packages/console-shared/src/hooks/__tests__/useUserPreference.spec.tsfrontend/packages/console-shared/src/test-utils/unit-test-utils.tsxfrontend/packages/dev-console/src/utils/__tests__/usePerspectiveDetection.spec.tsfrontend/packages/knative-plugin/src/components/add/__tests__/EventSink.spec.tsxfrontend/public/components/utils/__tests__/firehose.spec.tsxfrontend/public/redux.ts
| - Upgraded from `react-redux` v7 to v8. Plugins must use `react-redux` v8 to remain compatible with Console. | ||
| - Upgraded from `redux` v4 to v5. Plugins must use `redux` v5 to remain compatible with Console. | ||
| - Upgraded from `react-redux` v7 to v9. Plugins must use `react-redux` v9 to remain compatible with Console. | ||
| - Upgraded from `react-thunk` v2 to v3. Plugins must use `react-thunk` v3 to remain compatible with Console. |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
redux-thunk package v2 to v3 migration npm
💡 Result:
redux-thunk v2 → v3 (v3.1.0) migration (npm)
1) Update the dependency
npm i redux-thunk@^3
# or: npm i redux-thunk@^3.1.0v3.1.0 is the “latest v3” release and contains the breaking changes + a hotfix. [1]
2) Change imports: default export removed → named exports
Before (v2):
import thunk from 'redux-thunk'
const store = createStore(rootReducer, applyMiddleware(thunk))
thunk.withExtraArgument(api)After (v3):
import { thunk, withExtraArgument } from 'redux-thunk'
const store = createStore(rootReducer, applyMiddleware(thunk))
applyMiddleware(withExtraArgument(api))v3 removes the default export and exposes thunk + withExtraArgument as named exports. [1]
CommonJS (require) example:
const { thunk, withExtraArgument } = require('redux-thunk')(If you were doing require('redux-thunk').default, that will no longer be correct because there is no default export.) [1]
3) If you used redux-thunk/extend-redux (TypeScript): remove it
Redux Thunk v3 removes the TS-only entrypoint redux-thunk/extend-redux that globally patched dispatch / bindActionCreators types. Use store-inferred AppDispatch typing instead. [1]
Redux’s TS docs show the recommended approach (derive AppDispatch from the store and use that in your app). [3]
4) Be aware of packaging changes (ESM-first)
v3 updates the published artifacts for improved ESM/CJS compatibility (modern exports setup; ESM is the primary artifact) and drops UMD builds. This can affect older tooling / unusual bundler setups. [1] [2]
🏁 Script executed:
cat -n frontend/packages/console-dynamic-plugin-sdk/release-notes/4.22.md | head -20Repository: openshift/console
Length of output: 1246
🏁 Script executed:
rg "react-thunk|redux-thunk" --type md --type json --type ts --type js --type yamlRepository: openshift/console
Length of output: 1379
Fix package name in shared module compatibility guidance (line 14).
The package is redux-thunk, not react-thunk. The codebase (package.json, shared-modules-meta.ts, all imports) consistently uses redux-thunk v3. This release note will mislead plugin authors on required dependencies.
-- Upgraded from `react-thunk` v2 to v3. Plugins must use `react-thunk` v3 to remain compatible with Console.
+- Upgraded from `redux-thunk` v2 to v3. Plugins must use `redux-thunk` v3 to remain compatible with Console.📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| - Upgraded from `react-thunk` v2 to v3. Plugins must use `react-thunk` v3 to remain compatible with Console. | |
| - Upgraded from `redux-thunk` v2 to v3. Plugins must use `redux-thunk` v3 to remain compatible with Console. |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@frontend/packages/console-dynamic-plugin-sdk/release-notes/4.22.md` at line
14, The release note text incorrectly references the package name "react-thunk";
update that string to "redux-thunk" so the line reads that plugins must use
`redux-thunk` v3 to remain compatible with Console (replace "react-thunk" with
"redux-thunk" in the release note content), ensuring consistency with
package.json/shared-modules-meta.ts and all imports referencing redux-thunk.
ce63f16 to
dfa923d
Compare
|
@logonoff: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Version bumps:
react-redux8.1.3 -> 9.2.0redux4.0.4 -> 5.0.1redux-thunk2.4.0 -> 3.1.0Removed
redux-mock-storebecause the recommendation is to use a real store: https://redux.js.org/usage/writing-testsSummary by CodeRabbit