Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
webapp/src/components/markdownEditor.tsx (1)
66-66:⚠️ Potential issue | 🟡 MinorInconsistent null handling for
window.store.Line 66 still accesses
(window as any).storedirectly and passes it to<Provider>. Ifwindow.storeis undefined (which theuseMemonow guards against), this could cause the Provider to receive an undefined store, leading to runtime errors.Consider applying the same defensive pattern here or conditionally rendering the Provider.
Proposed fix
+ {(window as any).store && ( <Provider store={(window as any).store}> {messageHtmlToComponent(formatText(text || placeholderText || '', { atMentions: true, team: selectedTeam, channelNamesMap, }), { fetchMissingUsers: true, })} </Provider> + )}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@webapp/src/components/markdownEditor.tsx` at line 66, The component currently passes (window as any).store directly into <Provider>, which can be undefined; change it to use the memoized store from the existing useMemo (the local "store" variable) or conditionally render <Provider> only when that memoized store is non-null so Provider always receives a defined Redux store (adjust the JSX around <Provider> to guard on the memoized store variable rather than accessing (window as any).store directly).
🧹 Nitpick comments (2)
webapp/tests/setupFile.ts (1)
13-28: Consider extending the stub to includeentities.teamsfor selector compatibility.The
getChannelsNameMapInTeamselector from mattermost-redux may traverse intoentities.teamsor other state slices. The current stub only providesentities.channels. While tests that importmockMMStorefrommock_window.tsxexplicitly overridewindow.store, any test relying solely on this global stub might encounter issues if the selector accesses missing state paths.💡 Potential enhancement
;(window as any).store = { getState: () => ({ entities: { channels: { channels: {}, channelsInTeam: {}, myMembers: {}, stats: {}, messageCounts: {}, membersInChannel: {}, }, + teams: { + currentTeamId: '', + teams: {}, + myMembers: {}, + }, }, }), subscribe: () => () => {}, dispatch: () => {}, }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@webapp/tests/setupFile.ts` around lines 13 - 28, The global test stub (window.store) only provides entities.channels which can break selectors like getChannelsNameMapInTeam that also access entities.teams; update the stub in setupFile.ts to include an entities.teams object (e.g., teams, myTeamMembers, teamsInChannel or minimal keys your selectors expect) so selectors/readers that traverse entities.teams won't fail; ensure the shape matches what getChannelsNameMapInTeam and related selectors expect and keep subscribe/dispatch as-is..github/workflows/ci.yml (1)
30-31: Consider adding npm cache for faster CI runs.The
actions/setup-nodeaction supports built-in caching. This can significantly speed up CI by cachingnode_modules.Proposed improvement
- name: Setup Node uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: node-version-file: focalboard/.nvmrc + cache: 'npm' + cache-dependency-path: focalboard/webapp/package-lock.json - name: npm ci run: cd focalboard/webapp && npm ci🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/ci.yml around lines 30 - 31, Update the CI step that runs "npm ci" to leverage actions/setup-node's built-in caching: keep the existing setup-node usage and configure it with cache: 'npm' and point cache-dependency-path to the repo lockfile (e.g., package-lock.json or yarn.lock) so the "npm ci" step (named "npm ci") restores node_modules between runs; ensure the setup-node step remains before the "npm ci" step and remove any manual npm cache handling if present.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@webapp/src/components/markdownEditor.tsx`:
- Line 66: The component currently passes (window as any).store directly into
<Provider>, which can be undefined; change it to use the memoized store from the
existing useMemo (the local "store" variable) or conditionally render <Provider>
only when that memoized store is non-null so Provider always receives a defined
Redux store (adjust the JSX around <Provider> to guard on the memoized store
variable rather than accessing (window as any).store directly).
---
Nitpick comments:
In @.github/workflows/ci.yml:
- Around line 30-31: Update the CI step that runs "npm ci" to leverage
actions/setup-node's built-in caching: keep the existing setup-node usage and
configure it with cache: 'npm' and point cache-dependency-path to the repo
lockfile (e.g., package-lock.json or yarn.lock) so the "npm ci" step (named "npm
ci") restores node_modules between runs; ensure the setup-node step remains
before the "npm ci" step and remove any manual npm cache handling if present.
In `@webapp/tests/setupFile.ts`:
- Around line 13-28: The global test stub (window.store) only provides
entities.channels which can break selectors like getChannelsNameMapInTeam that
also access entities.teams; update the stub in setupFile.ts to include an
entities.teams object (e.g., teams, myTeamMembers, teamsInChannel or minimal
keys your selectors expect) so selectors/readers that traverse entities.teams
won't fail; ensure the shape matches what getChannelsNameMapInTeam and related
selectors expect and keep subscribe/dispatch as-is.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: ffb3a45a-aba2-42c5-abd6-2f5c91fb7668
⛔ Files ignored due to path filters (14)
webapp/src/components/__snapshots__/cardDialog.test.tsx.snapis excluded by!**/*.snapwebapp/src/components/__snapshots__/centerPanel.test.tsx.snapis excluded by!**/*.snapwebapp/src/components/__snapshots__/contentBlock.test.tsx.snapis excluded by!**/*.snapwebapp/src/components/__snapshots__/markdownEditor.test.tsx.snapis excluded by!**/*.snapwebapp/src/components/__snapshots__/viewTitle.test.tsx.snapis excluded by!**/*.snapwebapp/src/components/__snapshots__/workspace.test.tsx.snapis excluded by!**/*.snapwebapp/src/components/blocksEditor/__snapshots__/blocksEditor.test.tsx.snapis excluded by!**/*.snapwebapp/src/components/blocksEditor/__snapshots__/editor.test.tsx.snapis excluded by!**/*.snapwebapp/src/components/blocksEditor/__snapshots__/rootInput.test.tsx.snapis excluded by!**/*.snapwebapp/src/components/cardDetail/__snapshots__/cardDetailContents.test.tsx.snapis excluded by!**/*.snapwebapp/src/components/cardDetail/__snapshots__/commentsList.test.tsx.snapis excluded by!**/*.snapwebapp/src/components/content/__snapshots__/textElement.test.tsx.snapis excluded by!**/*.snapwebapp/src/components/globalHeader/__snapshots__/globalHeader.test.tsx.snapis excluded by!**/*.snapwebapp/src/components/sidebar/__snapshots__/sidebar.test.tsx.snapis excluded by!**/*.snap
📒 Files selected for processing (13)
.github/workflows/ci.ymlwebapp/package.jsonwebapp/src/components/blocksEditor/blocks/text/text.test.tsxwebapp/src/components/blocksEditor/editor.test.tsxwebapp/src/components/cardDetail/cardDetail.test.tsxwebapp/src/components/cardDetail/cardDetailContents.test.tsxwebapp/src/components/cardDetail/commentsList.test.tsxwebapp/src/components/content/textElement.test.tsxwebapp/src/components/contentBlock.test.tsxwebapp/src/components/markdownEditor.test.tsxwebapp/src/components/markdownEditor.tsxwebapp/tests/mock_window.tsxwebapp/tests/setupFile.ts
Summary
Fixed all the webapp tests for boards, added the CI rule to run webapp test.
Ticket Link
https://mattermost.atlassian.net/browse/MM-68079
Change Impact: 🟡 Medium
Regression Risk: Medium risk with localized potential for regression. The changes primarily affect the webapp test suite, but several factors elevate the risk:
setupFile.tsadd window-level mocks (scrollIntoView,window.store) that could have unexpected interactions with other teststeamsRedux slice is added to multiple test mocks, requiring consistent implementation across all affected test files to avoid state shape mismatchesmarkdownEditor.tsxrefactoring modifies production code to handlewindow.storeaccess, introducing a dependency on global state that could be fragile if the store isn't properly initializedmock_window.tsx) affect the test fixture data structure, requiring validation that all dependent tests are alignedQA Recommendation: Given that automated test coverage is being significantly expanded by enabling the previously disabled webapp-test CI job, manual QA can be minimized. However, focus manual testing on:
The straightforward nature of test fixes and the fact that no critical business logic or data handling was modified keep this to medium risk rather than high.