Skip to content

Fix Jest test: Mock CallStore.getCall rather than individual hooks like useParticipants#30636

Merged
langleyd merged 1 commit intodevelopfrom
langleyd-fix-room-header-test
Aug 28, 2025
Merged

Fix Jest test: Mock CallStore.getCall rather than individual hooks like useParticipants#30636
langleyd merged 1 commit intodevelopfrom
langleyd-fix-room-header-test

Conversation

@langleyd
Copy link
Copy Markdown
Member

Relates to #30373

particularly the error here.

 ● RoomHeader › group call enabled › close lobby button is shown if there is an ongoing call but we are viewing the lobby

    TypeError: Cannot read properties of undefined (reading 'length')

      46 |         call ?? undefined,
      47 |         CallEvent.Participants,
    > 48 |         useCallback((state) => state ?? call?.participants ?? [], [call]),
         |                    ^
      49 |     );
      50 | };
      51 |

      at areHookInputsEqual (node_modules/react-dom/cjs/react-dom-client.development.js:5478:36)
      at updateCallback (node_modules/react-dom/cjs/react-dom-client.development.js:6595:28)
      at Object.useCallback (node_modules/react-dom/cjs/react-dom-client.development.js:23149:16)
      at Object.<anonymous>.process.env.NODE_ENV.exports.useCallback (node_modules/react/cjs/react.development.js:1161:34)
      at useParticipants (src/hooks/useCall.ts:48:20)
      at useParticipants (src/hooks/useCall.ts:53:26)
      at useRoomCall (src/hooks/room/useRoomCall.tsx:125:53)
      at RoomHeader (src/components/views/rooms/RoomHeader/RoomHeader.tsx:87:20)
      at Object.react_stack_bottom_frame (node_modules/react-dom/cjs/react-dom-client.development.js:23863:20)
      at renderWithHooks (node_modules/react-dom/cjs/react-dom-client.development.js:5529:22)
      at updateFunctionComponent (node_modules/react-dom/cjs/react-dom-client.development.js:8897:19)
      at beginWork (node_modules/react-dom/cjs/react-dom-client.development.js:10522:18)
      at runWithFiberInDEV (node_modules/react-dom/cjs/react-dom-client.development.js:1522:13)
      at performUnitOfWork (node_modules/react-dom/cjs/react-dom-client.development.js:15140:22)
      at workLoopSync (node_modules/react-dom/cjs/react-dom-client.development.js:14956:41)
      at renderRootSync (node_modules/react-dom/cjs/react-dom-client.development.js:14936:11)
      at performWorkOnRoot (node_modules/react-dom/cjs/react-dom-client.development.js:14462:44)
      at performSyncWorkOnRoot (node_modules/react-dom/cjs/react-dom-client.development.js:16231:7)
      at flushSyncWorkAcrossRoots_impl (node_modules/react-dom/cjs/react-dom-client.development.js:16079:21)
      at flushSyncWork$1 (node_modules/react-dom/cjs/react-dom-client.development.js:14721:12)
      at Object.f (node_modules/react-dom/cjs/react-dom-client.development.js:24396:26)
      at Object.<anonymous>.process.env.NODE_ENV.exports.flushSync (node_modules/react-dom/cjs/react-dom.development.js:140:23)
      at node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.umd.js:182:31

A change to floating-ui dependency seems to be calling flushSync which triggers a render of the component and doesn't play nice with this mocking specific hooks and not others.
It probably makes more sense to mock the store data so the hooks are consistent.

@langleyd langleyd added this pull request to the merge queue Aug 28, 2025
Merged via the queue into develop with commit 1a005ad Aug 28, 2025
46 checks passed
@langleyd langleyd deleted the langleyd-fix-room-header-test branch August 28, 2025 08:58
Dileep9999 pushed a commit to hemanth-nag/element-web that referenced this pull request Oct 8, 2025
snowping pushed a commit to Novaloop-AG/element-web that referenced this pull request Dec 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-Task Tasks for the team like planning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants