mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-11-05 22:25:36 +00:00
Use context provided RoomViewStore within the RoomView component hierarchy (#31077)
* Update ContentMessages.ts Update ContentMessages.ts * update PlaybackQueue.ts * Update SpaceHierarchy.tsx * Update ThreadView.tsx * Update RoomCallBanner.tsx * Update useRoomCall.tsx * Update DateSeparator.tsx * Update TimelineCard.tsx * Update UserInfoBasicOptions * Update slask-commands/utils.ts * lint * Update PlaybackQueue, MVoiceMessageBody and UserInfoBasicOptionsView tests. * Update RoomHeader-test.tsx * lint * Add ts docs * Update utils-test.tsx * Update message-test.ts * coverage * lint * Improve naming --------- Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
@@ -30,7 +30,9 @@ import { CallStore } from "../../../../../src/stores/CallStore";
|
||||
import { WidgetMessagingStore } from "../../../../../src/stores/widgets/WidgetMessagingStore";
|
||||
import { MatrixClientPeg } from "../../../../../src/MatrixClientPeg";
|
||||
import { ConnectionState } from "../../../../../src/models/Call";
|
||||
import { SdkContextClass } from "../../../../../src/contexts/SDKContext";
|
||||
import { ScopedRoomContextProvider } from "../../../../../src/contexts/ScopedRoomContext";
|
||||
import { type IRoomState } from "../../../../../src/components/structures/RoomView";
|
||||
import RoomContext from "../../../../../src/contexts/RoomContext";
|
||||
|
||||
describe("<RoomCallBanner />", () => {
|
||||
let client: Mocked<MatrixClient>;
|
||||
@@ -42,6 +44,15 @@ describe("<RoomCallBanner />", () => {
|
||||
roomId: "!1:example.org",
|
||||
};
|
||||
|
||||
const mockRoomViewStore = {
|
||||
isViewingCall: jest.fn().mockReturnValue(false),
|
||||
on: jest.fn(),
|
||||
off: jest.fn(),
|
||||
emit: jest.fn(),
|
||||
};
|
||||
|
||||
let roomContext: IRoomState;
|
||||
|
||||
beforeEach(() => {
|
||||
stubClient();
|
||||
|
||||
@@ -59,6 +70,16 @@ describe("<RoomCallBanner />", () => {
|
||||
|
||||
setupAsyncStoreWithClient(CallStore.instance, client);
|
||||
setupAsyncStoreWithClient(WidgetMessagingStore.instance, client);
|
||||
|
||||
// Reset the mock RoomViewStore
|
||||
mockRoomViewStore.isViewingCall.mockReturnValue(false);
|
||||
|
||||
// Create a stable room context for this test
|
||||
roomContext = {
|
||||
...RoomContext,
|
||||
roomId: room.roomId,
|
||||
roomViewStore: mockRoomViewStore,
|
||||
} as unknown as IRoomState;
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
@@ -66,7 +87,11 @@ describe("<RoomCallBanner />", () => {
|
||||
});
|
||||
|
||||
const renderBanner = async (props = {}): Promise<void> => {
|
||||
render(<RoomCallBanner {...defaultProps} {...props} />);
|
||||
render(
|
||||
<ScopedRoomContextProvider {...roomContext}>
|
||||
<RoomCallBanner {...defaultProps} {...props} />
|
||||
</ScopedRoomContextProvider>,
|
||||
);
|
||||
await act(() => Promise.resolve()); // Let effects settle
|
||||
};
|
||||
|
||||
@@ -117,8 +142,7 @@ describe("<RoomCallBanner />", () => {
|
||||
});
|
||||
|
||||
it("doesn't show banner if the call is shown", async () => {
|
||||
jest.spyOn(SdkContextClass.instance.roomViewStore, "isViewingCall");
|
||||
mocked(SdkContextClass.instance.roomViewStore.isViewingCall).mockReturnValue(true);
|
||||
mockRoomViewStore.isViewingCall.mockReturnValue(true);
|
||||
await renderBanner();
|
||||
const banner = await screen.queryByText("Video call");
|
||||
expect(banner).toBeFalsy();
|
||||
|
||||
Reference in New Issue
Block a user