diff --git a/src/MatrixClientPeg.ts b/src/MatrixClientPeg.ts index fefba6c117..4064ca5b33 100644 --- a/src/MatrixClientPeg.ts +++ b/src/MatrixClientPeg.ts @@ -330,8 +330,8 @@ class MatrixClientPegClass implements IMatrixClientPeg { } } -if (!window.mxMatrixClientPeg) { - window.mxMatrixClientPeg = new MatrixClientPegClass(); -} +export const MatrixClientPeg: IMatrixClientPeg = new MatrixClientPegClass(); -export const MatrixClientPeg = window.mxMatrixClientPeg; +if (!window.mxMatrixClientPeg) { + window.mxMatrixClientPeg = MatrixClientPeg; +} diff --git a/src/components/structures/RightPanel.tsx b/src/components/structures/RightPanel.tsx index be14c70f00..360e478153 100644 --- a/src/components/structures/RightPanel.tsx +++ b/src/components/structures/RightPanel.tsx @@ -1,6 +1,6 @@ /* Copyright 2019 Michael Telatynski <7t3chguy@gmail.com> -Copyright 2015 - 2021 The Matrix.org Foundation C.I.C. +Copyright 2015 - 2022 The Matrix.org Foundation C.I.C. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -23,7 +23,6 @@ import { MatrixEvent } from "matrix-js-sdk/src/models/event"; import { throttle } from 'lodash'; import dis from '../../dispatcher/dispatcher'; -import GroupStore from '../../stores/GroupStore'; import { RightPanelPhases } from '../../stores/right-panel/RightPanelStorePhases'; import RightPanelStore from "../../stores/right-panel/RightPanelStore"; import MatrixClientContext from "../../contexts/MatrixClientContext"; @@ -59,8 +58,7 @@ interface IProps { } interface IState { - phase: RightPanelPhases; - isUserPrivilegedInGroup?: boolean; + phase?: RightPanelPhases; searchQuery: string; cardState?: IRightPanelCardState; } @@ -73,9 +71,6 @@ export default class RightPanel extends React.Component { super(props, context); this.state = { - cardState: RightPanelStore.instance.currentCard?.state, - phase: RightPanelStore.instance.currentCard?.phase, - isUserPrivilegedInGroup: null, searchQuery: "", }; } @@ -88,7 +83,6 @@ export default class RightPanel extends React.Component { const cli = this.context; cli.on("RoomState.members", this.onRoomStateMember); RightPanelStore.instance.on(UPDATE_EVENT, this.onRightPanelStoreUpdate); - this.initGroupStore(this.props.groupId); } public componentWillUnmount(): void { @@ -96,32 +90,16 @@ export default class RightPanel extends React.Component { this.context.removeListener("RoomState.members", this.onRoomStateMember); } RightPanelStore.instance.off(UPDATE_EVENT, this.onRightPanelStoreUpdate); - this.unregisterGroupStore(); } - // TODO: [REACT-WARNING] Replace with appropriate lifecycle event - public UNSAFE_componentWillReceiveProps(newProps: IProps): void { // eslint-disable-line - if (newProps.groupId !== this.props.groupId) { - this.unregisterGroupStore(); - this.initGroupStore(newProps.groupId); - } + public static getDerivedStateFromProps(props: IProps): Partial { + const currentCard = RightPanelStore.instance.currentCardForRoom(props.room.roomId); + return { + cardState: currentCard.state, + phase: currentCard.phase, + }; } - private initGroupStore(groupId: string) { - if (!groupId) return; - GroupStore.registerListener(groupId, this.onGroupStoreUpdated); - } - - private unregisterGroupStore() { - GroupStore.unregisterListener(this.onGroupStoreUpdated); - } - - private onGroupStoreUpdated = () => { - this.setState({ - isUserPrivilegedInGroup: GroupStore.isUserPrivileged(this.props.groupId), - }); - }; - private onRoomStateMember = (ev: MatrixEvent, state: RoomState, member: RoomMember) => { if (!this.props.room || member.roomId !== this.props.room.roomId) { return; @@ -139,10 +117,10 @@ export default class RightPanel extends React.Component { }; private onRightPanelStoreUpdate = () => { - const currentPanel = RightPanelStore.instance.currentCard; + const currentCard = RightPanelStore.instance.currentCardForRoom(this.props.room.roomId); this.setState({ - cardState: currentPanel.state, - phase: currentPanel.phase, + cardState: currentCard.state, + phase: currentCard.phase, }); }; diff --git a/src/components/structures/RoomView.tsx b/src/components/structures/RoomView.tsx index 1bcd348ba7..2df218f2c7 100644 --- a/src/components/structures/RoomView.tsx +++ b/src/components/structures/RoomView.tsx @@ -248,7 +248,7 @@ export class RoomView extends React.Component { canPeek: false, showApps: false, isPeeking: false, - showRightPanel: RightPanelStore.instance.isOpenForRoom, + showRightPanel: false, joining: false, atEndOfLiveTimeline: true, atEndOfLiveTimelineInit: false, @@ -342,7 +342,7 @@ export class RoomView extends React.Component { // Show chat in right panel when a widget is maximised RightPanelStore.instance.setCard({ phase: RightPanelPhases.Timeline }); } else if ( - RightPanelStore.instance.isOpenForRoom && + RightPanelStore.instance.isOpen && RightPanelStore.instance.roomPhaseHistory.some(card => (card.phase === RightPanelPhases.Timeline)) ) { // hide chat in right panel when the widget is minimized @@ -411,6 +411,7 @@ export class RoomView extends React.Component { showDisplaynameChanges: SettingsStore.getValue("showDisplaynameChanges", roomId), wasContextSwitch: RoomViewStore.getWasContextSwitch(), initialEventId: null, // default to clearing this, will get set later in the method if needed + showRightPanel: RightPanelStore.instance.isOpenForRoom(roomId), }; const initialEventId = RoomViewStore.getInitialEventId(); @@ -782,7 +783,7 @@ export class RoomView extends React.Component { private onRightPanelStoreUpdate = () => { this.setState({ - showRightPanel: RightPanelStore.instance.isOpenForRoom, + showRightPanel: RightPanelStore.instance.isOpenForRoom(this.state.roomId), }); }; diff --git a/src/components/structures/SpaceRoomView.tsx b/src/components/structures/SpaceRoomView.tsx index c654dab755..cfab45171a 100644 --- a/src/components/structures/SpaceRoomView.tsx +++ b/src/components/structures/SpaceRoomView.tsx @@ -809,7 +809,7 @@ export default class SpaceRoomView extends React.PureComponent { this.state = { phase, - showRightPanel: RightPanelStore.instance.isOpenForRoom, + showRightPanel: RightPanelStore.instance.isOpenForRoom(this.props.space.roomId), myMembership: this.props.space.getMyMembership(), }; @@ -832,7 +832,7 @@ export default class SpaceRoomView extends React.PureComponent { private onRightPanelStoreUpdate = () => { this.setState({ - showRightPanel: RightPanelStore.instance.isOpenForRoom, + showRightPanel: RightPanelStore.instance.isOpenForRoom(this.props.space.roomId), }); }; diff --git a/src/components/views/right_panel/EncryptionPanel.tsx b/src/components/views/right_panel/EncryptionPanel.tsx index 808ae12f25..38c0ec747c 100644 --- a/src/components/views/right_panel/EncryptionPanel.tsx +++ b/src/components/views/right_panel/EncryptionPanel.tsx @@ -123,7 +123,7 @@ const EncryptionPanel: React.FC = (props: IProps) => { state: { member, verificationRequest: verificationRequest_ }, }); } - if (!RightPanelStore.instance.isOpenForRoom) RightPanelStore.instance.togglePanel(); + if (!RightPanelStore.instance.isOpen) RightPanelStore.instance.togglePanel(); }, [member]); const requested = diff --git a/src/components/views/right_panel/HeaderButtons.tsx b/src/components/views/right_panel/HeaderButtons.tsx index 30b75fb968..3be4ba3598 100644 --- a/src/components/views/right_panel/HeaderButtons.tsx +++ b/src/components/views/right_panel/HeaderButtons.tsx @@ -72,16 +72,16 @@ export default abstract class HeaderButtons

extends React.Component) { const rps = RightPanelStore.instance; - if (rps.currentCard.phase == phase && !cardState && rps.isOpenForRoom) { + if (rps.currentCard.phase == phase && !cardState && rps.isOpen) { rps.togglePanel(); } else { RightPanelStore.instance.setCard({ phase, state: cardState }); - if (!rps.isOpenForRoom) rps.togglePanel(); + if (!rps.isOpen) rps.togglePanel(); } } public isPhase(phases: string | string[]): boolean { - if (!RightPanelStore.instance.isOpenForRoom) return false; + if (!RightPanelStore.instance.isOpen) return false; if (Array.isArray(phases)) { return phases.includes(this.state.phase); } else { diff --git a/src/components/views/right_panel/WidgetCard.tsx b/src/components/views/right_panel/WidgetCard.tsx index 0bdbf8aa66..66bc627485 100644 --- a/src/components/views/right_panel/WidgetCard.tsx +++ b/src/components/views/right_panel/WidgetCard.tsx @@ -40,19 +40,19 @@ const WidgetCard: React.FC = ({ room, widgetId, onClose }) => { const apps = useWidgets(room); const app = apps.find(a => a.id === widgetId); - const isPinned = app && WidgetLayoutStore.instance.isInContainer(room, app, Container.Top); + const isRight = app && WidgetLayoutStore.instance.isInContainer(room, app, Container.Right); const [menuDisplayed, handle, openMenu, closeMenu] = useContextMenu(); useEffect(() => { - if (!app || isPinned) { + if (!app || !isRight) { // stop showing this card RightPanelStore.instance.popCard(); } - }, [app, isPinned]); + }, [app, isRight]); // Don't render anything as we are about to transition - if (!app || isPinned) return null; + if (!app || !isRight) return null; let contextMenu; if (menuDisplayed) { diff --git a/src/stores/ReadyWatchingStore.ts b/src/stores/ReadyWatchingStore.ts index b8b9e4a04f..4d03a482b5 100644 --- a/src/stores/ReadyWatchingStore.ts +++ b/src/stores/ReadyWatchingStore.ts @@ -1,5 +1,5 @@ /* - * Copyright 2021 The Matrix.org Foundation C.I.C. + * Copyright 2021 - 2022 The Matrix.org Foundation C.I.C. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ */ import { MatrixClient } from "matrix-js-sdk/src/client"; +import { SyncState } from "matrix-js-sdk/src/sync"; import { Dispatcher } from "flux"; import { EventEmitter } from "events"; @@ -65,7 +66,7 @@ export abstract class ReadyWatchingStore extends EventEmitter implements IDestro // Everything after this is unnecessary (we only need to know once we have a client) // and we intentionally don't set the client before this point to avoid stores // updating for every event emitted during the cached sync. - if (!(payload.prevState === 'PREPARED' && payload.state !== 'PREPARED')) { + if (!(payload.prevState === SyncState.Prepared && payload.state !== SyncState.Prepared)) { return; } diff --git a/src/stores/right-panel/RightPanelStore.ts b/src/stores/right-panel/RightPanelStore.ts index d815a97986..e00e311473 100644 --- a/src/stores/right-panel/RightPanelStore.ts +++ b/src/stores/right-panel/RightPanelStore.ts @@ -1,5 +1,5 @@ /* -Copyright 2019-2021 The Matrix.org Foundation C.I.C. +Copyright 2019-2022 The Matrix.org Foundation C.I.C. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -90,14 +90,30 @@ export default class RightPanelStore extends ReadyWatchingStore { } // Getters - public get isOpenForRoom(): boolean { + /** + * If you are calling this from a component that already knows about a + * specific room from props / state, then it's best to prefer + * `isOpenForRoom` below to ensure all your data is for a single room + * during room changes. + */ + public get isOpen(): boolean { return this.byRoom[this.viewedRoomId]?.isOpen ?? false; } + public isOpenForRoom(roomId: string): boolean { + return this.byRoom[roomId]?.isOpen ?? false; + } + public get roomPhaseHistory(): Array { return this.byRoom[this.viewedRoomId]?.history ?? []; } + /** + * If you are calling this from a component that already knows about a + * specific room from props / state, then it's best to prefer + * `currentCardForRoom` below to ensure all your data is for a single room + * during room changes. + */ public get currentCard(): IRightPanelCard { const hist = this.roomPhaseHistory; if (hist.length >= 1) { @@ -111,7 +127,7 @@ export default class RightPanelStore extends ReadyWatchingStore { if (hist.length > 0) { return hist[hist.length - 1]; } - return this.currentCard ?? { state: {}, phase: null }; + return { state: {}, phase: null }; } public get previousCard(): IRightPanelCard { @@ -123,7 +139,7 @@ export default class RightPanelStore extends ReadyWatchingStore { } // The Group associated getters are just for backwards compatibility. Can be removed when deprecating groups. - public get isOpenForGroup(): boolean { return this.isOpenForRoom; } + public get isOpenForGroup(): boolean { return this.isOpen; } public get groupPhaseHistory(): Array { return this.roomPhaseHistory; } public get currentGroup(): IRightPanelCard { return this.currentCard; } public get previousGroup(): IRightPanelCard { return this.previousCard; } @@ -216,13 +232,13 @@ export default class RightPanelStore extends ReadyWatchingStore { } public show() { - if (!this.isOpenForRoom) { + if (!this.isOpen) { this.togglePanel(); } } public hide() { - if (this.isOpenForRoom) { + if (this.isOpen) { this.togglePanel(); } } @@ -235,8 +251,8 @@ export default class RightPanelStore extends ReadyWatchingStore { this.byRoom[this.viewedRoomId] = this.byRoom[this.viewedRoomId] ?? convertToStatePanel(SettingsStore.getValue("RightPanel.phases", this.viewedRoomId), room); } else { - console.warn("Could not restore the right panel after load because there was no associated room object." + - "The right panel can only be restored for rooms and spaces but not for groups"); + console.warn("Could not restore the right panel after load because there was no associated room object. " + + "The right panel can only be restored for rooms and spaces but not for groups."); } } diff --git a/test/TextForEvent-test.ts b/test/TextForEvent-test.ts index 650c010e32..1cdf958338 100644 --- a/test/TextForEvent-test.ts +++ b/test/TextForEvent-test.ts @@ -1,7 +1,7 @@ import './skinned-sdk'; import { EventType, MatrixEvent } from "matrix-js-sdk"; -import renderer from 'react-test-renderer'; +import TestRenderer from 'react-test-renderer'; import { getSenderName, textForEvent } from "../src/TextForEvent"; import SettingsStore from "../src/settings/SettingsStore"; @@ -82,7 +82,7 @@ describe('TextForEvent', () => { it("mentions message when a single message was pinned, with no previously pinned messages", () => { const event = mockPinnedEvent(['message-1']); const plainText = textForEvent(event); - const component = renderer.create(textForEvent(event, true)); + const component = TestRenderer.create(textForEvent(event, true)); const expectedText = "@foo:example.com pinned a message to this room. See all pinned messages."; expect(plainText).toBe(expectedText); @@ -92,7 +92,7 @@ describe('TextForEvent', () => { it("mentions message when a single message was pinned, with multiple previously pinned messages", () => { const event = mockPinnedEvent(['message-1', 'message-2', 'message-3'], ['message-1', 'message-2']); const plainText = textForEvent(event); - const component = renderer.create(textForEvent(event, true)); + const component = TestRenderer.create(textForEvent(event, true)); const expectedText = "@foo:example.com pinned a message to this room. See all pinned messages."; expect(plainText).toBe(expectedText); @@ -102,7 +102,7 @@ describe('TextForEvent', () => { it("mentions message when a single message was unpinned, with a single message previously pinned", () => { const event = mockPinnedEvent([], ['message-1']); const plainText = textForEvent(event); - const component = renderer.create(textForEvent(event, true)); + const component = TestRenderer.create(textForEvent(event, true)); const expectedText = "@foo:example.com unpinned a message from this room. See all pinned messages."; expect(plainText).toBe(expectedText); @@ -112,7 +112,7 @@ describe('TextForEvent', () => { it("mentions message when a single message was unpinned, with multiple previously pinned messages", () => { const event = mockPinnedEvent(['message-2'], ['message-1', 'message-2']); const plainText = textForEvent(event); - const component = renderer.create(textForEvent(event, true)); + const component = TestRenderer.create(textForEvent(event, true)); const expectedText = "@foo:example.com unpinned a message from this room. See all pinned messages."; expect(plainText).toBe(expectedText); @@ -122,7 +122,7 @@ describe('TextForEvent', () => { it("shows generic text when multiple messages were pinned", () => { const event = mockPinnedEvent(['message-1', 'message-2', 'message-3'], ['message-1']); const plainText = textForEvent(event); - const component = renderer.create(textForEvent(event, true)); + const component = TestRenderer.create(textForEvent(event, true)); const expectedText = "@foo:example.com changed the pinned messages for the room."; expect(plainText).toBe(expectedText); @@ -132,7 +132,7 @@ describe('TextForEvent', () => { it("shows generic text when multiple messages were unpinned", () => { const event = mockPinnedEvent(['message-3'], ['message-1', 'message-2', 'message-3']); const plainText = textForEvent(event); - const component = renderer.create(textForEvent(event, true)); + const component = TestRenderer.create(textForEvent(event, true)); const expectedText = "@foo:example.com changed the pinned messages for the room."; expect(plainText).toBe(expectedText); @@ -142,7 +142,7 @@ describe('TextForEvent', () => { it("shows generic text when one message was pinned, and another unpinned", () => { const event = mockPinnedEvent(['message-2'], ['message-1']); const plainText = textForEvent(event); - const component = renderer.create(textForEvent(event, true)); + const component = TestRenderer.create(textForEvent(event, true)); const expectedText = "@foo:example.com changed the pinned messages for the room."; expect(plainText).toBe(expectedText); diff --git a/test/components/structures/RightPanel-test.tsx b/test/components/structures/RightPanel-test.tsx new file mode 100644 index 0000000000..f2ecba7f07 --- /dev/null +++ b/test/components/structures/RightPanel-test.tsx @@ -0,0 +1,145 @@ +/* +Copyright 2022 The Matrix.org Foundation C.I.C. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import React from "react"; +import TestRenderer from "react-test-renderer"; +import { jest } from "@jest/globals"; +import { Room } from "matrix-js-sdk/src/models/room"; +import { SyncState } from "matrix-js-sdk/src/sync"; + +// We can't use the usual `skinned-sdk`, as it stubs out the RightPanel +import "../../minimal-sdk"; +import RightPanel from "../../../src/components/structures/RightPanel"; +import { MatrixClientPeg } from "../../../src/MatrixClientPeg"; +import ResizeNotifier from "../../../src/utils/ResizeNotifier"; +import { stubClient } from "../../test-utils"; +import { Action } from "../../../src/dispatcher/actions"; +import dis from "../../../src/dispatcher/dispatcher"; +import DMRoomMap from "../../../src/utils/DMRoomMap"; +import MatrixClientContext from "../../../src/contexts/MatrixClientContext"; +import SettingsStore from "../../../src/settings/SettingsStore"; +import { RightPanelPhases } from "../../../src/stores/right-panel/RightPanelStorePhases"; +import RightPanelStore from "../../../src/stores/right-panel/RightPanelStore"; +import { UPDATE_EVENT } from "../../../src/stores/AsyncStore"; + +describe("RightPanel", () => { + it("renders info from only one room during room changes", async () => { + stubClient(); + const cli = MatrixClientPeg.get(); + cli.hasLazyLoadMembersEnabled = () => false; + + // Init misc. startup deps + DMRoomMap.makeShared(); + + const r1 = new Room("r1", cli, "@name:example.com"); + const r2 = new Room("r2", cli, "@name:example.com"); + + jest.spyOn(cli, "getRoom").mockImplementation(roomId => { + if (roomId === "r1") return r1; + if (roomId === "r2") return r2; + return null; + }); + + // Set up right panel state + const realGetValue = SettingsStore.getValue; + jest.spyOn(SettingsStore, "getValue").mockImplementation((name, roomId) => { + if (name !== "RightPanel.phases") return realGetValue(name, roomId); + if (roomId === "r1") { + return { + history: [{ phase: RightPanelPhases.RoomMemberList }], + isOpen: true, + }; + } + if (roomId === "r2") { + return { + history: [{ phase: RightPanelPhases.RoomSummary }], + isOpen: true, + }; + } + return null; + }); + + // Wake up any stores waiting for a client + dis.dispatch({ + action: "MatrixActions.sync", + prevState: SyncState.Prepared, + state: SyncState.Syncing, + matrixClient: cli, + }); + + const resizeNotifier = new ResizeNotifier(); + + // Run initial render with room 1, and also running lifecycle methods + const renderer = TestRenderer.create( + + ); + // Wait for RPS room 1 updates to fire + const rpsUpdated = new Promise(resolve => { + const update = () => { + if ( + RightPanelStore.instance.currentCardForRoom("r1").phase !== + RightPanelPhases.RoomMemberList + ) return; + RightPanelStore.instance.off(UPDATE_EVENT, update); + resolve(); + }; + RightPanelStore.instance.on(UPDATE_EVENT, update); + }); + dis.dispatch({ + action: Action.ViewRoom, + room_id: "r1", + }); + await rpsUpdated; + + // After all that setup, now to the interesting part... + // We want to verify that as we change to room 2, we should always have + // the correct right panel state for whichever room we are showing. + const instance = renderer.root.instance; + const rendered = new Promise(resolve => { + jest.spyOn(instance, "render").mockImplementation(() => { + const { props, state } = instance; + if (props.room.roomId === "r2" && state.phase === RightPanelPhases.RoomMemberList) { + throw new Error("Tried to render room 1 state for room 2"); + } + if (props.room.roomId === "r2" && state.phase === RightPanelPhases.RoomSummary) { + resolve(); + } + return null; + }); + }); + + console.log("Switch to room 2"); + dis.dispatch({ + action: Action.ViewRoom, + room_id: "r2", + }); + renderer.update( + + ); + + await rendered; + }); + + afterAll(() => { + jest.restoreAllMocks(); + }); +}); diff --git a/test/minimal-sdk.js b/test/minimal-sdk.js new file mode 100644 index 0000000000..f39893f78c --- /dev/null +++ b/test/minimal-sdk.js @@ -0,0 +1,29 @@ +/* +Copyright 2022 The Matrix.org Foundation C.I.C. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/* + * minimal-sdk.js + * + * Starts up the skin system with even less than `skinned-sdk`. + */ + +import * as sdk from "../src/index"; + +const components = {}; + +sdk.loadSkin({ components }); + +export default sdk; diff --git a/test/stores/RoomViewStore-test.js b/test/stores/RoomViewStore-test.js index 648a5617e1..bf8fa01e38 100644 --- a/test/stores/RoomViewStore-test.js +++ b/test/stores/RoomViewStore-test.js @@ -1,3 +1,19 @@ +/* +Copyright 2017 - 2022 The Matrix.org Foundation C.I.C. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + import '../skinned-sdk'; // Must be first for skinning to work import RoomViewStore from '../../src/stores/RoomViewStore'; import { Action } from '../../src/dispatcher/actions'; diff --git a/test/test-utils.js b/test/test-utils.js index 27869584cd..665def5e18 100644 --- a/test/test-utils.js +++ b/test/test-utils.js @@ -1,6 +1,5 @@ import React from 'react'; import EventEmitter from "events"; -import ShallowRenderer from 'react-test-renderer/shallow'; import { MatrixEvent } from "matrix-js-sdk/src/models/event"; import { JoinRule } from 'matrix-js-sdk/src/@types/partials'; @@ -10,11 +9,6 @@ import { makeType } from "../src/utils/TypeUtils"; import { ValidatedServerConfig } from "../src/utils/AutoDiscoveryUtils"; import MatrixClientContext from "../src/contexts/MatrixClientContext"; -export function getRenderer() { - // Old: ReactTestUtils.createRenderer(); - return new ShallowRenderer(); -} - /** * Stub out the MatrixClient, and configure the MatrixClientPeg object to * return it when get() is called.