Polish & delabs Exploring public spaces
feature (#11423)
* Iterate search public spaces UX * Tweak iconography in spotlight * Delabs `Exploring public spaces` * Tweak msc3827 v1.4 support discovery * i18n * Delete stale test * Fix tests * Iterate * Iterate PR based on review * Improve types * Add shortcut to search for public spaces to create space menu * Update import * Add org.matrix.msc3827.stable filtering * Fix tests * silence some errors
This commit is contained in:
parent
d81f71f993
commit
dd6097c568
17 changed files with 180 additions and 107 deletions
|
@ -27,7 +27,8 @@ import {
|
|||
import sanitizeHtml from "sanitize-html";
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
|
||||
import SpotlightDialog, { Filter } from "../../../../src/components/views/dialogs/spotlight/SpotlightDialog";
|
||||
import SpotlightDialog from "../../../../src/components/views/dialogs/spotlight/SpotlightDialog";
|
||||
import { Filter } from "../../../../src/components/views/dialogs/spotlight/Filter";
|
||||
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
|
||||
import { LocalRoom, LOCAL_ROOM_ID_PREFIX } from "../../../../src/models/LocalRoom";
|
||||
import { DirectoryMember, startDmOnFirstMessage } from "../../../../src/utils/direct-messages";
|
||||
|
@ -352,12 +353,12 @@ describe("Spotlight Dialog", () => {
|
|||
});
|
||||
|
||||
it("should find Rooms", () => {
|
||||
expect(options.length).toBe(3);
|
||||
expect(options).toHaveLength(4);
|
||||
expect(options[0]!.innerHTML).toContain(testRoom.name);
|
||||
});
|
||||
|
||||
it("should not find LocalRooms", () => {
|
||||
expect(options.length).toBe(3);
|
||||
expect(options).toHaveLength(4);
|
||||
expect(options[0]!.innerHTML).not.toContain(testLocalRoom.name);
|
||||
});
|
||||
});
|
||||
|
@ -573,22 +574,4 @@ describe("Spotlight Dialog", () => {
|
|||
|
||||
expect(screen.getByText("Failed to query public rooms")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should show error both 'Show rooms' and 'Show spaces' are unchecked", async () => {
|
||||
jest.spyOn(SettingsStore, "getValue").mockImplementation((settingName, roomId, excludeDefault) => {
|
||||
if (settingName === "feature_exploring_public_spaces") {
|
||||
return true;
|
||||
} else {
|
||||
return []; // SpotlightSearch.recentSearches
|
||||
}
|
||||
});
|
||||
render(<SpotlightDialog initialFilter={Filter.PublicRooms} onFinished={() => null} />);
|
||||
|
||||
jest.advanceTimersByTime(200);
|
||||
await flushPromisesWithFakeTimers();
|
||||
|
||||
fireEvent.click(screen.getByText("Show rooms"));
|
||||
|
||||
expect(screen.getByText("You cannot search for rooms that are neither a room nor a space")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -71,7 +71,7 @@ describe("<LabsUserSettingsTab />", () => {
|
|||
// non-beta labs section
|
||||
expect(screen.getByText("Early previews")).toBeInTheDocument();
|
||||
const labsSections = container.getElementsByClassName("mx_SettingsSubsection");
|
||||
expect(labsSections).toHaveLength(10);
|
||||
expect(labsSections).toHaveLength(9);
|
||||
});
|
||||
|
||||
it("allow setting a labs flag which requires unstable support once support is confirmed", async () => {
|
||||
|
@ -80,21 +80,21 @@ describe("<LabsUserSettingsTab />", () => {
|
|||
|
||||
const deferred = defer<boolean>();
|
||||
cli.doesServerSupportUnstableFeature.mockImplementation(async (featureName) => {
|
||||
return featureName === "org.matrix.msc3827.stable" ? deferred.promise : false;
|
||||
return featureName === "org.matrix.msc3952_intentional_mentions" ? deferred.promise : false;
|
||||
});
|
||||
MatrixClientBackedController.matrixClient = cli;
|
||||
|
||||
const { queryByText } = render(getComponent());
|
||||
|
||||
expect(
|
||||
queryByText("Explore public spaces in the new search dialog")!
|
||||
queryByText("Enable intentional mentions")!
|
||||
.closest(".mx_SettingsFlag")!
|
||||
.querySelector(".mx_AccessibleButton"),
|
||||
).toHaveAttribute("aria-disabled", "true");
|
||||
deferred.resolve(true);
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
queryByText("Explore public spaces in the new search dialog")!
|
||||
queryByText("Enable intentional mentions")!
|
||||
.closest(".mx_SettingsFlag")!
|
||||
.querySelector(".mx_AccessibleButton"),
|
||||
).toHaveAttribute("aria-disabled", "false");
|
||||
|
|
|
@ -24,7 +24,7 @@ import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
|
|||
import { MetaSpace, SpaceKey } from "../../../../src/stores/spaces";
|
||||
import { shouldShowComponent } from "../../../../src/customisations/helpers/UIComponents";
|
||||
import { UIComponent } from "../../../../src/settings/UIFeature";
|
||||
import { mkStubRoom, wrapInSdkContext } from "../../../test-utils";
|
||||
import { mkStubRoom, wrapInMatrixClientContext, wrapInSdkContext } from "../../../test-utils";
|
||||
import { SdkContextClass } from "../../../../src/contexts/SDKContext";
|
||||
import SpaceStore from "../../../../src/stores/spaces/SpaceStore";
|
||||
import DMRoomMap from "../../../../src/utils/DMRoomMap";
|
||||
|
@ -122,9 +122,12 @@ describe("<SpacePanel />", () => {
|
|||
isGuest: jest.fn(),
|
||||
getAccountData: jest.fn(),
|
||||
on: jest.fn(),
|
||||
off: jest.fn(),
|
||||
removeListener: jest.fn(),
|
||||
isVersionSupported: jest.fn().mockResolvedValue(true),
|
||||
doesServerSupportUnstableFeature: jest.fn().mockResolvedValue(false),
|
||||
} as unknown as MatrixClient;
|
||||
const SpacePanel = wrapInSdkContext(UnwrappedSpacePanel, SdkContextClass.instance);
|
||||
const SpacePanel = wrapInSdkContext(wrapInMatrixClientContext(UnwrappedSpacePanel), SdkContextClass.instance);
|
||||
|
||||
beforeAll(() => {
|
||||
jest.spyOn(MatrixClientPeg, "get").mockReturnValue(mockClient);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue