mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-11-04 20:01:58 +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:
@@ -14,7 +14,6 @@ import { type TimestampToEventResponse, ConnectionError, HTTPError, MatrixError
|
||||
import dispatcher from "../../../../../src/dispatcher/dispatcher";
|
||||
import { Action } from "../../../../../src/dispatcher/actions";
|
||||
import { type ViewRoomPayload } from "../../../../../src/dispatcher/payloads/ViewRoomPayload";
|
||||
import { SdkContextClass } from "../../../../../src/contexts/SDKContext";
|
||||
import { formatFullDateNoTime } from "../../../../../src/DateUtils";
|
||||
import SettingsStore from "../../../../../src/settings/SettingsStore";
|
||||
import { UIFeature } from "../../../../../src/settings/UIFeature";
|
||||
@@ -26,6 +25,9 @@ import {
|
||||
waitEnoughCyclesForModal,
|
||||
} from "../../../../test-utils";
|
||||
import DateSeparator from "../../../../../src/components/views/messages/DateSeparator";
|
||||
import { ScopedRoomContextProvider } from "../../../../../src/contexts/ScopedRoomContext";
|
||||
import { type IRoomState } from "../../../../../src/components/structures/RoomView";
|
||||
import RoomContext from "../../../../../src/contexts/RoomContext";
|
||||
|
||||
jest.mock("../../../../../src/settings/SettingsStore");
|
||||
|
||||
@@ -40,13 +42,25 @@ describe("DateSeparator", () => {
|
||||
roomId,
|
||||
};
|
||||
|
||||
const mockRoomViewStore = {
|
||||
getRoomId: jest.fn().mockReturnValue(roomId),
|
||||
};
|
||||
|
||||
const defaultRoomContext = {
|
||||
...RoomContext,
|
||||
roomId,
|
||||
roomViewStore: mockRoomViewStore,
|
||||
} as unknown as IRoomState;
|
||||
|
||||
const mockClient = getMockClientWithEventEmitter({
|
||||
timestampToEvent: jest.fn(),
|
||||
});
|
||||
const getComponent = (props = {}) =>
|
||||
render(
|
||||
<MatrixClientContext.Provider value={mockClient}>
|
||||
<DateSeparator {...defaultProps} {...props} />
|
||||
<ScopedRoomContextProvider {...defaultRoomContext}>
|
||||
<DateSeparator {...defaultProps} {...props} />
|
||||
</ScopedRoomContextProvider>
|
||||
</MatrixClientContext.Provider>,
|
||||
);
|
||||
|
||||
@@ -74,7 +88,7 @@ describe("DateSeparator", () => {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
jest.spyOn(SdkContextClass.instance.roomViewStore, "getRoomId").mockReturnValue(roomId);
|
||||
mockRoomViewStore.getRoomId.mockReturnValue(roomId);
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
@@ -200,7 +214,7 @@ describe("DateSeparator", () => {
|
||||
// network request is taking a while, so we got bored, switched rooms; we
|
||||
// shouldn't jump back to the previous room after the network request
|
||||
// happens to finish later.
|
||||
jest.spyOn(SdkContextClass.instance.roomViewStore, "getRoomId").mockReturnValue("!some-other-room");
|
||||
mockRoomViewStore.getRoomId.mockReturnValue("!some-other-room");
|
||||
|
||||
// Jump to "last week"
|
||||
mockClient.timestampToEvent.mockResolvedValue({
|
||||
@@ -230,7 +244,7 @@ describe("DateSeparator", () => {
|
||||
// network request is taking a while, so we got bored, switched rooms; we
|
||||
// shouldn't jump back to the previous room after the network request
|
||||
// happens to finish later.
|
||||
jest.spyOn(SdkContextClass.instance.roomViewStore, "getRoomId").mockReturnValue("!some-other-room");
|
||||
mockRoomViewStore.getRoomId.mockReturnValue("!some-other-room");
|
||||
|
||||
// Try to jump to "last week" but we want an error to occur and ensure that
|
||||
// we don't show an error dialog for it since we already switched away to
|
||||
|
||||
@@ -16,6 +16,7 @@ import type { MediaEventHelper } from "../../../../../src/utils/MediaEventHelper
|
||||
import MVoiceMessageBody from "../../../../../src/components/views/messages/MVoiceMessageBody";
|
||||
import { PlaybackQueue } from "../../../../../src/audio/PlaybackQueue";
|
||||
import { createTestClient } from "../../../../test-utils";
|
||||
import { SdkContextClass } from "../../../../../src/contexts/SDKContext";
|
||||
|
||||
describe("<MVvoiceMessageBody />", () => {
|
||||
let event: MatrixEvent;
|
||||
@@ -25,7 +26,7 @@ describe("<MVvoiceMessageBody />", () => {
|
||||
|
||||
const matrixClient = createTestClient();
|
||||
const room = new Room("!TESTROOM", matrixClient, "@alice:example.org");
|
||||
const playbackQueue = new PlaybackQueue(room);
|
||||
const playbackQueue = new PlaybackQueue(room, SdkContextClass.instance.roomViewStore);
|
||||
|
||||
jest.spyOn(PlaybackQueue, "forRoom").mockReturnValue(playbackQueue);
|
||||
jest.spyOn(playbackQueue, "unsortedEnqueue").mockReturnValue(undefined);
|
||||
|
||||
Reference in New Issue
Block a user