Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Disable upgraderoom command without developer mode enabled (#11744)
Browse files Browse the repository at this point in the history
* Disable upgraderoom command without developer mode enabled

Signed-off-by: Michael Telatynski <[email protected]>

* Update tests

Signed-off-by: Michael Telatynski <[email protected]>

---------

Signed-off-by: Michael Telatynski <[email protected]>
  • Loading branch information
t3chguy authored Oct 13, 2023
1 parent bdf2ebd commit 255f0f5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/SlashCommands.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export const Commands = [
command: "upgraderoom",
args: "<new_version>",
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);
Expand Down
18 changes: 17 additions & 1 deletion test/SlashCommands-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -88,7 +89,6 @@ describe("SlashCommands", () => {
});

describe.each([
["upgraderoom"],
["myroomnick"],
["roomavatar"],
["myroomavatar"],
Expand Down Expand Up @@ -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")!;
Expand Down

0 comments on commit 255f0f5

Please sign in to comment.