diff --git a/apps/web/src/components/settings/KeybindingsSettings.environment.test.tsx b/apps/web/src/components/settings/KeybindingsSettings.environment.test.tsx index a33720e58348a823ab81f8ebc8698676b9b496b5..d18fe69bdad18e384b3189a436fe6a9e730f075d 100644 --- a/apps/web/src/components/settings/KeybindingsSettings.environment.test.tsx +++ b/apps/web/src/components/settings/KeybindingsSettings.environment.test.tsx @@ -7,6 +7,7 @@ import { reactHookHarness as hooks } from "../../test/reactHookHarness"; const state = vi.hoisted(() => ({ canOperate: false, canWriteSettings: true, + connected: true, openEditor: vi.fn(), upsert: vi.fn(), remove: vi.fn(), @@ -57,7 +58,9 @@ vi.mock("./SettingsScopeContext", () => ({ availableEditors: [], }, }; - return { environment, connectedEnvironments: [environment] }; + return state.connected + ? { environment, connectedEnvironments: [environment] } + : { environment: null, connectedEnvironments: [] }; }, })); @@ -104,6 +107,7 @@ describe("KeybindingsSettings editor permission", () => { hooks.reset(); state.canOperate = false; state.canWriteSettings = true; + state.connected = true; state.openEditor.mockReset().mockResolvedValue({ _tag: "Success", value: undefined }); state.upsert.mockReset().mockResolvedValue({ _tag: "Success", value: undefined }); state.remove.mockReset().mockResolvedValue({ _tag: "Success", value: undefined }); @@ -141,3 +145,30 @@ describe("KeybindingsSettings editor permission", () => { expect(openButton(renderPanel()).props.disabled).toBe(true); }); }); + +function noticeText(panel: unknown) { + const notice = visitElements(panel, (element) => element.type === "p"); + return notice?.props.children; +} + +describe("KeybindingsSettings write notice", () => { + beforeEach(() => { + hooks.reset(); + state.canWriteSettings = true; + state.connected = true; + }); + + // The hosted app has no environment until one is paired, so the editor is + // locked for a missing connection, not a missing permission. + it("asks for a connected environment when none is connected", () => { + state.connected = false; + expect(noticeText(renderPanel())).toBe("Connect an environment to change keybindings."); + }); + + it("names the permission when the connection cannot write settings", () => { + state.canWriteSettings = false; + expect(noticeText(renderPanel())).toBe( + "This connection can view keybindings but cannot change them.", + ); + }); +}); diff --git a/apps/web/src/components/settings/KeybindingsSettings.tsx b/apps/web/src/components/settings/KeybindingsSettings.tsx index 1aa0dc0e9d3a4d21e8abb0d4969d267f68b8d51c..cc2fc85f94f1ef120bfd65b4a44cbb8177def8e3 100644 --- a/apps/web/src/components/settings/KeybindingsSettings.tsx +++ b/apps/web/src/components/settings/KeybindingsSettings.tsx @@ -1502,7 +1502,9 @@ export function KeybindingsSettingsPanel() { {!canWriteSettings ? (
- This connection can view keybindings but cannot change them. + {connectedEnvironments.length === 0 + ? "Connect an environment to change keybindings." + : "This connection can view keybindings but cannot change them."}
) : null}