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

Disable upgraderoom command without developer mode enabled #11744

Merged
merged 2 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading