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:
@@ -26,6 +26,8 @@ import {
|
||||
clearAllModals,
|
||||
flushPromises,
|
||||
getMockClientWithEventEmitter,
|
||||
mockClientMethodsRooms,
|
||||
mockClientMethodsServer,
|
||||
mockClientMethodsUser,
|
||||
} from "../../../../test-utils";
|
||||
import { filterBoolean } from "../../../../../src/utils/arrays";
|
||||
@@ -33,14 +35,16 @@ import JoinRuleSettings, {
|
||||
type JoinRuleSettingsProps,
|
||||
} from "../../../../../src/components/views/settings/JoinRuleSettings";
|
||||
import { PreferredRoomVersions } from "../../../../../src/utils/PreferredRoomVersions";
|
||||
import SpaceStore from "../../../../../src/stores/spaces/SpaceStore";
|
||||
import SettingsStore from "../../../../../src/settings/SettingsStore";
|
||||
import { SDKContextClass } from "../../../../../src/contexts/SDKContextClass.ts";
|
||||
import DMRoomMap from "../../../../../src/utils/DMRoomMap.ts";
|
||||
|
||||
describe("<JoinRuleSettings />", () => {
|
||||
const userId = "@alice:server.org";
|
||||
const client = getMockClientWithEventEmitter({
|
||||
...mockClientMethodsUser(userId),
|
||||
getRoom: jest.fn(),
|
||||
...mockClientMethodsServer(),
|
||||
...mockClientMethodsRooms([]),
|
||||
getDomain: jest.fn(),
|
||||
getLocalAliases: jest.fn().mockReturnValue([]),
|
||||
sendStateEvent: jest.fn(),
|
||||
@@ -50,6 +54,7 @@ describe("<JoinRuleSettings />", () => {
|
||||
isRoomEncrypted: jest.fn().mockReturnValue(false),
|
||||
getRoomDirectoryVisibility: jest.fn(),
|
||||
setRoomDirectoryVisibility: jest.fn(),
|
||||
matrixRTC: { on: jest.fn() },
|
||||
});
|
||||
const roomId = "!room:server.org";
|
||||
const newRoomId = "!roomUpgraded:server.org";
|
||||
@@ -112,6 +117,7 @@ describe("<JoinRuleSettings />", () => {
|
||||
client.upgradeRoom.mockResolvedValue({ replacement_room: newRoomId });
|
||||
client.getRoom.mockReturnValue(null);
|
||||
jest.spyOn(SettingsStore, "getValue").mockImplementation((setting) => setting === "feature_ask_to_join");
|
||||
DMRoomMap.makeShared(client);
|
||||
});
|
||||
|
||||
type TestCase = [string, { label: string; unsupportedRoomVersion: string; preferredRoomVersion: string }];
|
||||
@@ -165,7 +171,9 @@ describe("<JoinRuleSettings />", () => {
|
||||
// room that doesn't support the join rule
|
||||
const room = new Room(roomId, client, userId);
|
||||
const parentSpace = new Room("!parentSpace:server.org", client, userId);
|
||||
jest.spyOn(SpaceStore.instance, "getKnownParents").mockReturnValue(new Set([parentSpace.roomId]));
|
||||
jest.spyOn(SDKContextClass.instance.spaceStore, "getKnownParents").mockReturnValue(
|
||||
new Set([parentSpace.roomId]),
|
||||
);
|
||||
setRoomStateEvents(room, unsupportedRoomVersion);
|
||||
const memberAlice = new RoomMember(roomId, "@alice:server.org");
|
||||
const memberBob = new RoomMember(roomId, "@bob:server.org");
|
||||
|
||||
Reference in New Issue
Block a user