mirror of https://github.com/vector-im/riot-web
Disable upgraderoom command without developer mode enabled (#11744)
* Disable upgraderoom command without developer mode enabled Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update tests Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>pull/28788/head^2
parent
bdf2ebd301
commit
255f0f59f5
|
@ -149,7 +149,7 @@ export const Commands = [
|
||||||
command: "upgraderoom",
|
command: "upgraderoom",
|
||||||
args: "<new_version>",
|
args: "<new_version>",
|
||||||
description: _td("slash_command|upgraderoom"),
|
description: _td("slash_command|upgraderoom"),
|
||||||
isEnabled: (cli) => !isCurrentLocalRoom(cli),
|
isEnabled: (cli) => !isCurrentLocalRoom(cli) && SettingsStore.getValue("developerMode"),
|
||||||
runFn: function (cli, roomId, threadId, args) {
|
runFn: function (cli, roomId, threadId, args) {
|
||||||
if (args) {
|
if (args) {
|
||||||
const room = cli.getRoom(roomId);
|
const room = cli.getRoom(roomId);
|
||||||
|
|
|
@ -28,6 +28,7 @@ import WidgetUtils from "../src/utils/WidgetUtils";
|
||||||
import { WidgetType } from "../src/widgets/WidgetType";
|
import { WidgetType } from "../src/widgets/WidgetType";
|
||||||
import { warnSelfDemote } from "../src/components/views/right_panel/UserInfo";
|
import { warnSelfDemote } from "../src/components/views/right_panel/UserInfo";
|
||||||
import dispatcher from "../src/dispatcher/dispatcher";
|
import dispatcher from "../src/dispatcher/dispatcher";
|
||||||
|
import { SettingLevel } from "../src/settings/SettingLevel";
|
||||||
|
|
||||||
jest.mock("../src/components/views/right_panel/UserInfo");
|
jest.mock("../src/components/views/right_panel/UserInfo");
|
||||||
|
|
||||||
|
@ -88,7 +89,6 @@ describe("SlashCommands", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe.each([
|
describe.each([
|
||||||
["upgraderoom"],
|
|
||||||
["myroomnick"],
|
["myroomnick"],
|
||||||
["roomavatar"],
|
["roomavatar"],
|
||||||
["myroomavatar"],
|
["myroomavatar"],
|
||||||
|
@ -126,6 +126,22 @@ describe("SlashCommands", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("/upgraderoom", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
command = findCommand("upgraderoom")!;
|
||||||
|
setCurrentRoom();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should be disabled by default", () => {
|
||||||
|
expect(command.isEnabled(client)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should be enabled for developerMode", () => {
|
||||||
|
SettingsStore.setValue("developerMode", null, SettingLevel.DEVICE, true);
|
||||||
|
expect(command.isEnabled(client)).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("/op", () => {
|
describe("/op", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
command = findCommand("op")!;
|
command = findCommand("op")!;
|
||||||
|
|
Loading…
Reference in New Issue