Remove SpaceStore singleton (#34088)
* Remove dead code * Remove LegacyCallHandler singleton Route via SDKContext to cut import cycles * Remove SpaceStore singleton Route via SDKContext to cut import cycles * Fix tests * Fix tests * Fix tests * Fix tests * Iterate * Post-merge fixup * Iterate
This commit is contained in:
@@ -30,7 +30,13 @@ import LoggedInView from "../../../../src/components/structures/LoggedInView";
|
||||
import { SDKContext } from "../../../../src/contexts/SDKContext";
|
||||
import { StandardActions } from "../../../../src/notifications/StandardActions";
|
||||
import ResizeNotifier from "../../../../src/utils/ResizeNotifier";
|
||||
import { flushPromises, getMockClientWithEventEmitter, mockClientMethodsUser } from "../../../test-utils";
|
||||
import {
|
||||
flushPromises,
|
||||
getMockClientWithEventEmitter,
|
||||
mockClientMethodsRooms,
|
||||
mockClientMethodsServer,
|
||||
mockClientMethodsUser,
|
||||
} from "../../../test-utils";
|
||||
import { TestSDKContext } from "../../TestSDKContext";
|
||||
import defaultDispatcher from "../../../../src/dispatcher/dispatcher";
|
||||
import SettingsStore from "../../../../src/settings/SettingsStore";
|
||||
@@ -45,9 +51,9 @@ describe("<LoggedInView />", () => {
|
||||
const userId = "@alice:domain.org";
|
||||
const mockClient = getMockClientWithEventEmitter({
|
||||
...mockClientMethodsUser(userId),
|
||||
getClientWellKnown: jest.fn(),
|
||||
...mockClientMethodsServer(),
|
||||
...mockClientMethodsRooms([]),
|
||||
getAccountData: jest.fn(),
|
||||
getRoom: jest.fn(),
|
||||
getSyncState: jest.fn().mockReturnValue(null),
|
||||
getSyncStateData: jest.fn().mockReturnValue(null),
|
||||
getMediaHandler: jest.fn(),
|
||||
@@ -57,6 +63,9 @@ describe("<LoggedInView />", () => {
|
||||
setExtendedProfileProperty: jest.fn().mockResolvedValue(undefined),
|
||||
deleteExtendedProfileProperty: jest.fn().mockResolvedValue(undefined),
|
||||
doesServerSupportExtendedProfiles: jest.fn().mockResolvedValue(true),
|
||||
matrixRTC: {
|
||||
on: jest.fn(),
|
||||
},
|
||||
getAuthMetadata: jest.fn().mockRejectedValue(new Error("Legacy auth")),
|
||||
});
|
||||
const mediaHandler = new MediaHandler(mockClient);
|
||||
|
||||
@@ -25,13 +25,14 @@ import {
|
||||
makeBeaconInfoEvent,
|
||||
mockClientMethodsCrypto,
|
||||
mockClientMethodsEvents,
|
||||
mockClientMethodsServer,
|
||||
mockClientMethodsUser,
|
||||
mockClientPushProcessor,
|
||||
} from "../../../test-utils";
|
||||
import type ResizeNotifier from "../../../../src/utils/ResizeNotifier";
|
||||
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
|
||||
import { ScopedRoomContextProvider } from "../../../../src/contexts/ScopedRoomContext.tsx";
|
||||
import { SDKContextClass } from "../../../../src/contexts/SDKContextClass";
|
||||
import { TestSDKContext } from "../../TestSDKContext.ts";
|
||||
|
||||
jest.mock("../../../../src/utils/beacon", () => ({
|
||||
useBeacon: jest.fn(),
|
||||
@@ -47,14 +48,15 @@ describe("MessagePanel", function () {
|
||||
...mockClientMethodsEvents(),
|
||||
...mockClientMethodsCrypto(),
|
||||
...mockClientPushProcessor(),
|
||||
...mockClientMethodsServer(),
|
||||
getAccountData: jest.fn(),
|
||||
isUserIgnored: jest.fn().mockReturnValue(false),
|
||||
isRoomEncrypted: jest.fn().mockReturnValue(false),
|
||||
getRoom: jest.fn(),
|
||||
getClientWellKnown: jest.fn().mockReturnValue({}),
|
||||
supportsThreads: jest.fn().mockReturnValue(true),
|
||||
getVisibleRooms: jest.fn().mockReturnValue([]),
|
||||
});
|
||||
let sdkContext: SDKContextClass;
|
||||
let sdkContext: TestSDKContext;
|
||||
jest.spyOn(MatrixClientPeg, "get").mockReturnValue(client);
|
||||
|
||||
const room = new Room(roomId, client, userId);
|
||||
@@ -106,7 +108,8 @@ describe("MessagePanel", function () {
|
||||
return arg === "showDisplaynameChanges";
|
||||
});
|
||||
|
||||
sdkContext = new SDKContextClass();
|
||||
sdkContext = new TestSDKContext();
|
||||
sdkContext._client = client;
|
||||
|
||||
DMRoomMap.makeShared(client);
|
||||
});
|
||||
|
||||
@@ -18,7 +18,7 @@ import { RoomPermalinkCreator } from "../../../../src/utils/permalinks/Permalink
|
||||
import RightPanelStore from "../../../../src/stores/right-panel/RightPanelStore.ts";
|
||||
import DMRoomMap from "../../../../src/utils/DMRoomMap.ts";
|
||||
import { type IOpts } from "../../../../src/createRoom.ts";
|
||||
import SpaceStore from "../../../../src/stores/spaces/SpaceStore.ts";
|
||||
import { SDKContextClass } from "../../../../src/contexts/SDKContextClass.ts";
|
||||
|
||||
describe("SpaceRoomView", () => {
|
||||
let cli: MockedObject<MatrixClient>;
|
||||
@@ -132,7 +132,7 @@ describe("SpaceRoomView", () => {
|
||||
describe("Spaces: creating a new community space", () => {
|
||||
it("asks what topics you want to discuss, creates rooms for them and offers to share", async () => {
|
||||
cli.createRoom.mockResolvedValueOnce({ room_id: "room1" }).mockResolvedValueOnce({ room_id: "room2" });
|
||||
SpaceStore.instance.addRoomToSpace = jest.fn();
|
||||
SDKContextClass.instance.spaceStore.addRoomToSpace = jest.fn();
|
||||
|
||||
// Given we are creating a space
|
||||
const view = await renderSpaceRoomView({
|
||||
@@ -243,7 +243,7 @@ describe("SpaceRoomView", () => {
|
||||
describe("Spaces: creating a new private space", () => {
|
||||
it("creates rooms inside a private space for a team", async () => {
|
||||
cli.createRoom.mockResolvedValueOnce({ room_id: "room1" }).mockResolvedValueOnce({ room_id: "room2" });
|
||||
SpaceStore.instance.addRoomToSpace = jest.fn();
|
||||
SDKContextClass.instance.spaceStore.addRoomToSpace = jest.fn();
|
||||
|
||||
// When I create a private space
|
||||
const view = await renderSpaceRoomView({
|
||||
|
||||
Reference in New Issue
Block a user