diff --git a/src/SlashCommands.tsx b/src/SlashCommands.tsx index 60e81a8d2be..f309ca4bc54 100644 --- a/src/SlashCommands.tsx +++ b/src/SlashCommands.tsx @@ -149,7 +149,7 @@ export const Commands = [ command: "upgraderoom", args: "", description: _td("slash_command|upgraderoom"), - isEnabled: (cli) => !isCurrentLocalRoom(cli), + isEnabled: (cli) => !isCurrentLocalRoom(cli) && SettingsStore.getValue("developerMode"), runFn: function (cli, roomId, threadId, args) { if (args) { const room = cli.getRoom(roomId); diff --git a/test/SlashCommands-test.tsx b/test/SlashCommands-test.tsx index 0580aa86e05..ae90d2bbc42 100644 --- a/test/SlashCommands-test.tsx +++ b/test/SlashCommands-test.tsx @@ -28,6 +28,7 @@ import WidgetUtils from "../src/utils/WidgetUtils"; import { WidgetType } from "../src/widgets/WidgetType"; import { warnSelfDemote } from "../src/components/views/right_panel/UserInfo"; import dispatcher from "../src/dispatcher/dispatcher"; +import { SettingLevel } from "../src/settings/SettingLevel"; jest.mock("../src/components/views/right_panel/UserInfo"); @@ -88,7 +89,6 @@ describe("SlashCommands", () => { }); describe.each([ - ["upgraderoom"], ["myroomnick"], ["roomavatar"], ["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", () => { beforeEach(() => { command = findCommand("op")!;