From 9e6423bbc6b48a42539571b4022ec4fca4e27311 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 30 May 2023 10:41:20 +0100 Subject: [PATCH 1/7] When joining room in sub-space join the parents too --- src/components/structures/SpaceHierarchy.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/structures/SpaceHierarchy.tsx b/src/components/structures/SpaceHierarchy.tsx index fe246f6b354..cc095b94f64 100644 --- a/src/components/structures/SpaceHierarchy.tsx +++ b/src/components/structures/SpaceHierarchy.tsx @@ -429,7 +429,7 @@ interface IHierarchyLevelProps { parents: Set; selectedMap?: Map>; onViewRoomClick(roomId: string, roomType?: RoomType): void; - onJoinRoomClick(roomId: string): Promise; + onJoinRoomClick(roomId: string, parents: Set): Promise; onToggleClick?(parentId: string, childId: string): void; } @@ -511,7 +511,7 @@ export const HierarchyLevel: React.FC = ({ suggested={hierarchy.isSuggested(root.room_id, room.room_id)} selected={selectedMap?.get(root.room_id)?.has(room.room_id)} onViewRoomClick={() => onViewRoomClick(room.room_id, room.room_type as RoomType)} - onJoinRoomClick={() => onJoinRoomClick(room.room_id)} + onJoinRoomClick={() => onJoinRoomClick(room.room_id, newParents)} hasPermissions={hasPermissions} onToggleClick={onToggleClick ? () => onToggleClick(root.room_id, room.room_id) : undefined} /> @@ -532,7 +532,7 @@ export const HierarchyLevel: React.FC = ({ suggested={hierarchy.isSuggested(root.room_id, space.room_id)} selected={selectedMap?.get(root.room_id)?.has(space.room_id)} onViewRoomClick={() => onViewRoomClick(space.room_id, RoomType.Space)} - onJoinRoomClick={() => onJoinRoomClick(space.room_id)} + onJoinRoomClick={() => onJoinRoomClick(space.room_id, newParents)} hasPermissions={hasPermissions} onToggleClick={onToggleClick ? () => onToggleClick(root.room_id, space.room_id) : undefined} > @@ -839,7 +839,12 @@ const SpaceHierarchy: React.FC = ({ space, initialText = "", showRoom, a selectedMap={selected} onToggleClick={hasPermissions ? onToggleClick : undefined} onViewRoomClick={(roomId, roomType) => showRoom(cli, hierarchy, roomId, roomType)} - onJoinRoomClick={(roomId) => joinRoom(cli, hierarchy, roomId)} + onJoinRoomClick={async (roomId, parents) => { + for (const parent of parents) { + await joinRoom(cli, hierarchy, parent); + } + await joinRoom(cli, hierarchy, roomId); + }} /> ); From 8e1f3602ffdbb48002f55a92c8b72dc1e109a033 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 30 May 2023 10:41:37 +0100 Subject: [PATCH 2/7] Fix joined state not updating on sync --- src/components/structures/SpaceHierarchy.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/structures/SpaceHierarchy.tsx b/src/components/structures/SpaceHierarchy.tsx index cc095b94f64..dac53c6bc9d 100644 --- a/src/components/structures/SpaceHierarchy.tsx +++ b/src/components/structures/SpaceHierarchy.tsx @@ -32,7 +32,7 @@ import { Room, RoomEvent } from "matrix-js-sdk/src/models/room"; import { RoomHierarchy } from "matrix-js-sdk/src/room-hierarchy"; import { EventType, RoomType } from "matrix-js-sdk/src/@types/event"; import { IHierarchyRelation, IHierarchyRoom } from "matrix-js-sdk/src/@types/spaces"; -import { MatrixClient, MatrixError } from "matrix-js-sdk/src/matrix"; +import { ClientEvent, MatrixClient, MatrixError } from "matrix-js-sdk/src/matrix"; import classNames from "classnames"; import { sortBy, uniqBy } from "lodash"; import { GuestAccess, HistoryVisibility } from "matrix-js-sdk/src/@types/partials"; @@ -101,7 +101,7 @@ const Tile: React.FC = ({ children, }) => { const cli = useContext(MatrixClientContext); - const [joinedRoom, setJoinedRoom] = useState(() => { + const joinedRoom = useTypedEventEmitterState(cli, ClientEvent.Room, () => { const cliRoom = cli?.getRoom(room.room_id); return cliRoom?.getMyMembership() === "join" ? cliRoom : undefined; }); @@ -128,7 +128,6 @@ const Tile: React.FC = ({ ev.stopPropagation(); onJoinRoomClick() .then(() => awaitRoomDownSync(cli, room.room_id)) - .then(setJoinedRoom) .finally(() => { setBusy(false); }); From 3255305a2f0b34e7f1eef790817473a11575b46d Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 30 May 2023 11:15:32 +0100 Subject: [PATCH 3/7] Add membership check --- src/components/structures/SpaceHierarchy.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/structures/SpaceHierarchy.tsx b/src/components/structures/SpaceHierarchy.tsx index dac53c6bc9d..77d85bf55bb 100644 --- a/src/components/structures/SpaceHierarchy.tsx +++ b/src/components/structures/SpaceHierarchy.tsx @@ -840,7 +840,9 @@ const SpaceHierarchy: React.FC = ({ space, initialText = "", showRoom, a onViewRoomClick={(roomId, roomType) => showRoom(cli, hierarchy, roomId, roomType)} onJoinRoomClick={async (roomId, parents) => { for (const parent of parents) { - await joinRoom(cli, hierarchy, parent); + if (cli.getRoom(parent)?.getMyMembership() !== "join") { + await joinRoom(cli, hierarchy, parent); + } } await joinRoom(cli, hierarchy, roomId); }} From 3b8b69250ceb5fb7d0ecc07d3836ba61123df665 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 30 May 2023 11:38:32 +0100 Subject: [PATCH 4/7] Update tests --- .../structures/SpaceHierarchy-test.tsx | 87 ++++-- .../SpaceHierarchy-test.tsx.snap | 263 +++++++++++++++--- 2 files changed, 288 insertions(+), 62 deletions(-) diff --git a/test/components/structures/SpaceHierarchy-test.tsx b/test/components/structures/SpaceHierarchy-test.tsx index b81a84facaa..b94f6dcf339 100644 --- a/test/components/structures/SpaceHierarchy-test.tsx +++ b/test/components/structures/SpaceHierarchy-test.tsx @@ -16,7 +16,7 @@ limitations under the License. import React from "react"; import { mocked } from "jest-mock"; -import { render } from "@testing-library/react"; +import { fireEvent, render } from "@testing-library/react"; import { MatrixClient } from "matrix-js-sdk/src/client"; import { Room } from "matrix-js-sdk/src/models/room"; import { RoomHierarchy } from "matrix-js-sdk/src/room-hierarchy"; @@ -167,13 +167,21 @@ describe("SpaceHierarchy", () => { } as unknown as DMRoomMap; jest.spyOn(DMRoomMap, "shared").mockReturnValue(dmRoomMap); - const root = mkStubRoom("room-id-1", "Room 1", client); - const room1 = mkStubRoom("room-id-2", "Room 2", client); - const room2 = mkStubRoom("room-id-3", "Room 3", client); + const root = mkStubRoom("space-id-1", "Space 1", client); + const room1 = mkStubRoom("room-id-2", "Room 1", client); + const room2 = mkStubRoom("room-id-3", "Room 2", client); + const space1 = mkStubRoom("space-id-4", "Space 2", client); + const room3 = mkStubRoom("room-id-5", "Room 3", client); + mocked(client.getRooms).mockReturnValue([root]); + mocked(client.getRoom).mockImplementation( + (roomId) => client.getRooms().find((room) => room.roomId === roomId) ?? null, + ); + [room1, room2, space1, room3].forEach((r) => mocked(r.getMyMembership).mockReturnValue("leave")); const hierarchyRoot = { room_id: root.roomId, num_joined_members: 1, + room_type: "m.space", children_state: [ { state_key: room1.roomId, @@ -183,39 +191,72 @@ describe("SpaceHierarchy", () => { state_key: room2.roomId, content: { order: "2" }, }, + { + state_key: space1.roomId, + content: { order: "3" }, + }, ], } as IHierarchyRoom; const hierarchyRoom1 = { room_id: room1.roomId, num_joined_members: 2 } as IHierarchyRoom; - const hierarchyRoom2 = { room_id: root.roomId, num_joined_members: 3 } as IHierarchyRoom; + const hierarchyRoom2 = { room_id: room2.roomId, num_joined_members: 3 } as IHierarchyRoom; + const hierarchyRoom3 = { + name: "Nested room", + room_id: room3.roomId, + num_joined_members: 3, + } as IHierarchyRoom; + const hierarchySpace1 = { + room_id: space1.roomId, + name: "Nested space", + num_joined_members: 1, + room_type: "m.space", + children_state: [ + { + state_key: room3.roomId, + content: { order: "1" }, + }, + ], + } as IHierarchyRoom; const roomHierarchy = { roomMap: new Map([ [root.roomId, hierarchyRoot], + [space1.roomId, hierarchySpace1], [room1.roomId, hierarchyRoom1], [room2.roomId, hierarchyRoom2], + [room3.roomId, hierarchyRoom3], ]), isSuggested: jest.fn(), } as unknown as RoomHierarchy; + const defaultProps = { + root: hierarchyRoot, + roomSet: new Set([hierarchyRoom1, hierarchyRoom2, hierarchySpace1, hierarchyRoom3]), + hierarchy: roomHierarchy, + parents: new Set(), + selectedMap: new Map>(), + onViewRoomClick: jest.fn(), + onJoinRoomClick: jest.fn(), + onToggleClick: jest.fn(), + }; + const getComponent = (props = {}): React.ReactElement => ( + + ; + + ); + it("renders", () => { - const defaultProps = { - root: hierarchyRoot, - roomSet: new Set([hierarchyRoom1, hierarchyRoom2]), - hierarchy: roomHierarchy, - parents: new Set(), - selectedMap: new Map>(), - onViewRoomClick: jest.fn(), - onJoinRoomClick: jest.fn(), - onToggleClick: jest.fn(), - }; - const getComponent = (props = {}): React.ReactElement => ( - - ; - - ); - - const { container } = render(getComponent()); - expect(container).toMatchSnapshot(); + const { asFragment } = render(getComponent()); + expect(asFragment()).toMatchSnapshot(); + }); + + it("should join subspace when joining nested room", async () => { + const onJoinRoomClick = jest.fn().mockResolvedValue({}); + + const { getByText } = render(getComponent({ onJoinRoomClick })); + const button = getByText("Nested room")!.closest("li")!.querySelector(".mx_AccessibleButton_kind_primary")!; + fireEvent.click(button); + + expect(onJoinRoomClick).toHaveBeenCalledWith(room3.roomId, new Set([root.roomId, space1.roomId])); }); }); }); diff --git a/test/components/structures/__snapshots__/SpaceHierarchy-test.tsx.snap b/test/components/structures/__snapshots__/SpaceHierarchy-test.tsx.snap index 83c347affe8..65feba02b84 100644 --- a/test/components/structures/__snapshots__/SpaceHierarchy-test.tsx.snap +++ b/test/components/structures/__snapshots__/SpaceHierarchy-test.tsx.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`SpaceHierarchy renders 1`] = ` -
+
  • renders 1`] = `
    - + + + +
    Unnamed Room -
    - Joined -
    2 members - · -
  • - View + Join
    renders 1`] = `
    - + + + +
    Unnamed Room -
    - Joined -
    3 members - · - +
    +
    +
    + Join +
    + + +
    + +
  • +
    +
    +
    + + + + +
    +
    + Nested space +
    +
    + 1 member · 1 room
    - View + Join
    renders 1`] = `
    +
    +
    +
    +
  • +
  • +
    +
    +
    + + + + +
    +
    + Nested room +
    +
    + 3 members +
    +
    +
    +
    + Join +
    +
    + + +
  • ; -
    + `; From 19f4e88fcd385eede401a41df855bcf2c4d4a1c0 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 1 Jun 2023 12:24:18 +0100 Subject: [PATCH 5/7] Improve coverage --- .../structures/SpaceHierarchy-test.tsx | 64 +- .../SpaceHierarchy-test.tsx.snap | 574 ++++++++++-------- test/test-utils/test-utils.ts | 1 + 3 files changed, 351 insertions(+), 288 deletions(-) diff --git a/test/components/structures/SpaceHierarchy-test.tsx b/test/components/structures/SpaceHierarchy-test.tsx index b94f6dcf339..753832ec293 100644 --- a/test/components/structures/SpaceHierarchy-test.tsx +++ b/test/components/structures/SpaceHierarchy-test.tsx @@ -16,7 +16,7 @@ limitations under the License. import React from "react"; import { mocked } from "jest-mock"; -import { fireEvent, render } from "@testing-library/react"; +import { fireEvent, render, screen, waitFor, waitForElementToBeRemoved } from "@testing-library/react"; import { MatrixClient } from "matrix-js-sdk/src/client"; import { Room } from "matrix-js-sdk/src/models/room"; import { RoomHierarchy } from "matrix-js-sdk/src/room-hierarchy"; @@ -25,7 +25,7 @@ import { IHierarchyRoom } from "matrix-js-sdk/src/@types/spaces"; import { MatrixClientPeg } from "../../../src/MatrixClientPeg"; import { mkStubRoom, stubClient } from "../../test-utils"; import dispatcher from "../../../src/dispatcher/dispatcher"; -import { HierarchyLevel, showRoom, toLocalRoom } from "../../../src/components/structures/SpaceHierarchy"; +import SpaceHierarchy, { showRoom, toLocalRoom } from "../../../src/components/structures/SpaceHierarchy"; import { Action } from "../../../src/dispatcher/actions"; import MatrixClientContext from "../../../src/contexts/MatrixClientContext"; import DMRoomMap from "../../../src/utils/DMRoomMap"; @@ -158,7 +158,18 @@ describe("SpaceHierarchy", () => { }); }); - describe("", () => { + describe("", () => { + beforeEach(() => { + // IntersectionObserver isn't available in test environment + const mockIntersectionObserver = jest.fn(); + mockIntersectionObserver.mockReturnValue({ + observe: () => null, + unobserve: () => null, + disconnect: () => null, + }); + window.IntersectionObserver = mockIntersectionObserver; + }); + stubClient(); const client = MatrixClientPeg.get(); @@ -197,12 +208,13 @@ describe("SpaceHierarchy", () => { }, ], } as IHierarchyRoom; - const hierarchyRoom1 = { room_id: room1.roomId, num_joined_members: 2 } as IHierarchyRoom; - const hierarchyRoom2 = { room_id: room2.roomId, num_joined_members: 3 } as IHierarchyRoom; + const hierarchyRoom1 = { room_id: room1.roomId, num_joined_members: 2, children_state: [] } as IHierarchyRoom; + const hierarchyRoom2 = { room_id: room2.roomId, num_joined_members: 3, children_state: [] } as IHierarchyRoom; const hierarchyRoom3 = { name: "Nested room", room_id: room3.roomId, num_joined_members: 3, + children_state: [], } as IHierarchyRoom; const hierarchySpace1 = { room_id: space1.roomId, @@ -217,46 +229,42 @@ describe("SpaceHierarchy", () => { ], } as IHierarchyRoom; - const roomHierarchy = { - roomMap: new Map([ - [root.roomId, hierarchyRoot], - [space1.roomId, hierarchySpace1], - [room1.roomId, hierarchyRoom1], - [room2.roomId, hierarchyRoom2], - [room3.roomId, hierarchyRoom3], - ]), - isSuggested: jest.fn(), - } as unknown as RoomHierarchy; + mocked(client.getRoomHierarchy).mockResolvedValue({ + rooms: [hierarchyRoot, hierarchyRoom1, hierarchyRoom2, hierarchySpace1, hierarchyRoom3], + }); const defaultProps = { - root: hierarchyRoot, - roomSet: new Set([hierarchyRoom1, hierarchyRoom2, hierarchySpace1, hierarchyRoom3]), - hierarchy: roomHierarchy, - parents: new Set(), - selectedMap: new Map>(), - onViewRoomClick: jest.fn(), - onJoinRoomClick: jest.fn(), - onToggleClick: jest.fn(), + space: root, + showRoom: jest.fn(), }; const getComponent = (props = {}): React.ReactElement => ( - ; + ; ); - it("renders", () => { + it("renders", async () => { const { asFragment } = render(getComponent()); + // Wait for spinners to go away + await waitForElementToBeRemoved(screen.getAllByRole("progressbar")); expect(asFragment()).toMatchSnapshot(); }); it("should join subspace when joining nested room", async () => { - const onJoinRoomClick = jest.fn().mockResolvedValue({}); + mocked(client.joinRoom).mockResolvedValue({} as Room); - const { getByText } = render(getComponent({ onJoinRoomClick })); + const { getByText } = render(getComponent()); + // Wait for spinners to go away + await waitForElementToBeRemoved(screen.getAllByRole("progressbar")); const button = getByText("Nested room")!.closest("li")!.querySelector(".mx_AccessibleButton_kind_primary")!; fireEvent.click(button); - expect(onJoinRoomClick).toHaveBeenCalledWith(room3.roomId, new Set([root.roomId, space1.roomId])); + await waitFor(() => { + expect(client.joinRoom).toHaveBeenCalledTimes(2); + }); + // Joins subspace + expect(client.joinRoom).toHaveBeenCalledWith(space1.roomId, expect.any(Object)); + expect(client.joinRoom).toHaveBeenCalledWith(room3.roomId, expect.any(Object)); }); }); }); diff --git a/test/components/structures/__snapshots__/SpaceHierarchy-test.tsx.snap b/test/components/structures/__snapshots__/SpaceHierarchy-test.tsx.snap index 65feba02b84..ea82ff880e3 100644 --- a/test/components/structures/__snapshots__/SpaceHierarchy-test.tsx.snap +++ b/test/components/structures/__snapshots__/SpaceHierarchy-test.tsx.snap @@ -1,326 +1,285 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`SpaceHierarchy renders 1`] = ` +exports[`SpaceHierarchy renders 1`] = ` -
  • +
    +
    +
    +

    + Rooms and spaces +

    +
    -
    - - - - -
    -
    - Unnamed Room -
    -
    - 2 members -
    + Remove
    -
    - Join -
    - - -
    -
  • -
  • +
      -
      - - - -
      -
      - Unnamed Room -
      -
      - 3 members +
      +
      + Unnamed Room +
      +
      + 2 members +
      -
      -
      - Join -
      - - -
      + -
      + - + class="mx_Checkbox_background" + > +
      +
      + + +
      - - -
    • -
      +
    • - - - -
      -
      - Nested space -
      -
      - 1 member · 1 room +
      +
      + Unnamed Room +
      +
      + 3 members +
      - -
      - Join -
      - - -
      -
      -
      -
      -
    • -
    • -
      +
    • - - - -
      -
      - Nested room -
      -
      - 3 members -
      -
      -
      -
      - Join +
      +
      + Nested space +
      +
      + 1 member · 1 room +
      +
      + Join +
      renders 1`] = `
      +
      - -
    • +
      + +
    • +
      +
      +
      + + + + +
      +
      + Nested room +
      +
      + 3 members +
      +
      +
      +
      + Join +
      +
      + + +
      +
      +
    • +
    ; `; diff --git a/test/test-utils/test-utils.ts b/test/test-utils/test-utils.ts index 3d46c0ba5f7..21bcf741195 100644 --- a/test/test-utils/test-utils.ts +++ b/test/test-utils/test-utils.ts @@ -235,6 +235,7 @@ export function createTestClient(): MatrixClient { searchUserDirectory: jest.fn().mockResolvedValue({ limited: false, results: [] }), setDeviceVerified: jest.fn(), + joinRoom: jest.fn(), } as unknown as MatrixClient; client.reEmitter = new ReEmitter(client); From 5af259a74ec5a2efbb40290643b575d9639bfb20 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 1 Jun 2023 12:52:33 +0100 Subject: [PATCH 6/7] Make TS happier --- .../structures/SpaceHierarchy-test.tsx | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/test/components/structures/SpaceHierarchy-test.tsx b/test/components/structures/SpaceHierarchy-test.tsx index 753832ec293..2ac995c108d 100644 --- a/test/components/structures/SpaceHierarchy-test.tsx +++ b/test/components/structures/SpaceHierarchy-test.tsx @@ -207,14 +207,30 @@ describe("SpaceHierarchy", () => { content: { order: "3" }, }, ], + world_readable: true, + guest_can_join: true, + } as IHierarchyRoom; + const hierarchyRoom1 = { + room_id: room1.roomId, + num_joined_members: 2, + children_state: [], + world_readable: true, + guest_can_join: true, + } as IHierarchyRoom; + const hierarchyRoom2 = { + room_id: room2.roomId, + num_joined_members: 3, + children_state: [], + world_readable: true, + guest_can_join: true, } as IHierarchyRoom; - const hierarchyRoom1 = { room_id: room1.roomId, num_joined_members: 2, children_state: [] } as IHierarchyRoom; - const hierarchyRoom2 = { room_id: room2.roomId, num_joined_members: 3, children_state: [] } as IHierarchyRoom; const hierarchyRoom3 = { name: "Nested room", room_id: room3.roomId, num_joined_members: 3, children_state: [], + world_readable: true, + guest_can_join: true, } as IHierarchyRoom; const hierarchySpace1 = { room_id: space1.roomId, @@ -227,6 +243,8 @@ describe("SpaceHierarchy", () => { content: { order: "1" }, }, ], + world_readable: true, + guest_can_join: true, } as IHierarchyRoom; mocked(client.getRoomHierarchy).mockResolvedValue({ From aee420a7d1b8f3c654ef9a85fea84585843f9297 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 1 Jun 2023 12:53:57 +0100 Subject: [PATCH 7/7] Make TS happier --- .../structures/SpaceHierarchy-test.tsx | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/test/components/structures/SpaceHierarchy-test.tsx b/test/components/structures/SpaceHierarchy-test.tsx index 2ac995c108d..95842df7d63 100644 --- a/test/components/structures/SpaceHierarchy-test.tsx +++ b/test/components/structures/SpaceHierarchy-test.tsx @@ -189,7 +189,7 @@ describe("SpaceHierarchy", () => { ); [room1, room2, space1, room3].forEach((r) => mocked(r.getMyMembership).mockReturnValue("leave")); - const hierarchyRoot = { + const hierarchyRoot: IHierarchyRoom = { room_id: root.roomId, num_joined_members: 1, room_type: "m.space", @@ -197,42 +197,51 @@ describe("SpaceHierarchy", () => { { state_key: room1.roomId, content: { order: "1" }, + origin_server_ts: 111, + type: "m.space.child", + sender: "@other:server", }, { state_key: room2.roomId, content: { order: "2" }, + origin_server_ts: 111, + type: "m.space.child", + sender: "@other:server", }, { state_key: space1.roomId, content: { order: "3" }, + origin_server_ts: 111, + type: "m.space.child", + sender: "@other:server", }, ], world_readable: true, guest_can_join: true, - } as IHierarchyRoom; - const hierarchyRoom1 = { + }; + const hierarchyRoom1: IHierarchyRoom = { room_id: room1.roomId, num_joined_members: 2, children_state: [], world_readable: true, guest_can_join: true, - } as IHierarchyRoom; - const hierarchyRoom2 = { + }; + const hierarchyRoom2: IHierarchyRoom = { room_id: room2.roomId, num_joined_members: 3, children_state: [], world_readable: true, guest_can_join: true, - } as IHierarchyRoom; - const hierarchyRoom3 = { + }; + const hierarchyRoom3: IHierarchyRoom = { name: "Nested room", room_id: room3.roomId, num_joined_members: 3, children_state: [], world_readable: true, guest_can_join: true, - } as IHierarchyRoom; - const hierarchySpace1 = { + }; + const hierarchySpace1: IHierarchyRoom = { room_id: space1.roomId, name: "Nested space", num_joined_members: 1, @@ -241,11 +250,14 @@ describe("SpaceHierarchy", () => { { state_key: room3.roomId, content: { order: "1" }, + origin_server_ts: 111, + type: "m.space.child", + sender: "@other:server", }, ], world_readable: true, guest_can_join: true, - } as IHierarchyRoom; + }; mocked(client.getRoomHierarchy).mockResolvedValue({ rooms: [hierarchyRoot, hierarchyRoom1, hierarchyRoom2, hierarchySpace1, hierarchyRoom3],