Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Please see LICENSE files in the repository root for full details.
*/

import React from "react";
import { render, screen, fireEvent, act, cleanup, waitFor } from "jest-matrix-react";
import { render, screen, fireEvent, act, cleanup, waitFor, within } from "jest-matrix-react";
import { mocked } from "jest-mock";
import { type MatrixClient, type Room } from "matrix-js-sdk/src/matrix";

Expand Down Expand Up @@ -147,8 +147,21 @@ describe("<SpacePanel />", () => {
const spySettingsStore = jest.spyOn(SettingsStore, "getValue").mockImplementation((setting) => {
return setting === "feature_video_rooms" ? true : originalGetValue(setting);
});
const renderResult = render(<SpacePanel />);
expect(renderResult.asFragment()).toMatchSnapshot();
render(<SpacePanel />);

// Inspect the order of the rendered MetaSpaces, excluding the "Create a space" button.
const tree = screen.getByRole("tree", { name: "Spaces" });
const spaceButtons = within(tree)
.getAllByRole("treeitem")
.filter((el) => within(el).queryByRole("button", { name: "Create a space" }) === null);

const metaSpaceLabels = Array.from(spaceButtons).map((li) =>
within(li)
.getByRole("button", { name: /^(?!Options$).*/ }) // filter out the 'options' buttons within the buttons
.getAttribute("aria-label"),
);
expect(metaSpaceLabels).toEqual(["Home", "Other rooms", "Conferences"]);

spySettingsStore.mockRestore();
});

Expand Down

This file was deleted.

Loading