diff --git a/apps/web/test/unit-tests/components/views/spaces/SpacePanel-test.tsx b/apps/web/test/unit-tests/components/views/spaces/SpacePanel-test.tsx
index 598d029f1f8..a2e3698ced6 100644
--- a/apps/web/test/unit-tests/components/views/spaces/SpacePanel-test.tsx
+++ b/apps/web/test/unit-tests/components/views/spaces/SpacePanel-test.tsx
@@ -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";
@@ -147,8 +147,21 @@ describe("", () => {
const spySettingsStore = jest.spyOn(SettingsStore, "getValue").mockImplementation((setting) => {
return setting === "feature_video_rooms" ? true : originalGetValue(setting);
});
- const renderResult = render();
- expect(renderResult.asFragment()).toMatchSnapshot();
+ render();
+
+ // 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();
});
diff --git a/apps/web/test/unit-tests/components/views/spaces/__snapshots__/SpacePanel-test.tsx.snap b/apps/web/test/unit-tests/components/views/spaces/__snapshots__/SpacePanel-test.tsx.snap
deleted file mode 100644
index efebdcdbc8f..00000000000
--- a/apps/web/test/unit-tests/components/views/spaces/__snapshots__/SpacePanel-test.tsx.snap
+++ /dev/null
@@ -1,311 +0,0 @@
-// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
-
-exports[` should show all activated MetaSpaces in the correct order 1`] = `
-
-
-
-`;