Fix some features not being configurable via features
(#10276)
This commit is contained in:
parent
6746ce2da3
commit
ad8d27d2b2
12 changed files with 329 additions and 61 deletions
|
@ -16,6 +16,7 @@ limitations under the License.
|
|||
|
||||
import React from "react";
|
||||
import { render } from "@testing-library/react";
|
||||
import { defer } from "matrix-js-sdk/src/utils";
|
||||
|
||||
import LabsUserSettingsTab from "../../../../../../src/components/views/settings/tabs/user/LabsUserSettingsTab";
|
||||
import SettingsStore from "../../../../../../src/settings/SettingsStore";
|
||||
|
@ -25,6 +26,7 @@ import {
|
|||
mockClientMethodsUser,
|
||||
} from "../../../../../test-utils";
|
||||
import SdkConfig from "../../../../../../src/SdkConfig";
|
||||
import MatrixClientBackedController from "../../../../../../src/settings/controllers/MatrixClientBackedController";
|
||||
|
||||
describe("<SecurityUserSettingsTab />", () => {
|
||||
const sdkConfigSpy = jest.spyOn(SdkConfig, "get");
|
||||
|
@ -35,7 +37,7 @@ describe("<SecurityUserSettingsTab />", () => {
|
|||
const getComponent = () => <LabsUserSettingsTab {...defaultProps} />;
|
||||
|
||||
const userId = "@alice:server.org";
|
||||
getMockClientWithEventEmitter({
|
||||
const cli = getMockClientWithEventEmitter({
|
||||
...mockClientMethodsUser(userId),
|
||||
...mockClientMethodsServer(),
|
||||
});
|
||||
|
@ -70,4 +72,21 @@ describe("<SecurityUserSettingsTab />", () => {
|
|||
const labsSections = container.getElementsByClassName("mx_SettingsTab_section");
|
||||
expect(labsSections.length).toEqual(11);
|
||||
});
|
||||
|
||||
it("renders a labs flag which requires unstable support once support is confirmed", async () => {
|
||||
// enable labs
|
||||
sdkConfigSpy.mockImplementation((configName) => configName === "show_labs_settings");
|
||||
|
||||
const deferred = defer<boolean>();
|
||||
cli.doesServerSupportUnstableFeature.mockImplementation(async (featureName) => {
|
||||
return featureName === "org.matrix.msc3827.stable" ? deferred.promise : false;
|
||||
});
|
||||
MatrixClientBackedController.matrixClient = cli;
|
||||
|
||||
const { queryByText, findByText } = render(getComponent());
|
||||
|
||||
expect(queryByText("Explore public spaces in the new search dialog")).toBeFalsy();
|
||||
deferred.resolve(true);
|
||||
await expect(findByText("Explore public spaces in the new search dialog")).resolves.toBeDefined();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue