Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
keyboard_UI: Allow use of `e` hotkey for spectators.
Ines Falcato8d96b7879f01
diff --git a/web/src/hotkey.js b/web/src/hotkey.jsindex 809ca19cd80..1fae02100f3 100644--- a/web/src/hotkey.js+++ b/web/src/hotkey.js@@ -1150,7 +1150,12 @@ export function process_hotkey(e, hotkey) {if (// Allow UI only features for spectators which they can perform.page_params.is_spectator &&- !["toggle_conversation_view", "show_lightbox", "toggle_sender_info"].includes(event_name)+ ![+ "toggle_conversation_view",+ "show_lightbox",+ "toggle_sender_info",+ "edit_message",+ ].includes(event_name)) {spectators.login_to_access();return true;diff --git a/web/tests/hotkey.test.cjs b/web/tests/hotkey.test.cjsindex db24acd454a..fd244fda8f7 100644--- a/web/tests/hotkey.test.cjs+++ b/web/tests/hotkey.test.cjs@@ -2,10 +2,13 @@const assert = require("node:assert/strict");+const {process_keydown} = require("../src/hotkey.js");+const {mock_esm, set_global, with_overrides, zrequire} = require("./lib/namespace.cjs");const {make_stub} = require("./lib/stub.cjs");const {run_test} = require("./lib/test.cjs");const $ = require("./lib/zjquery.cjs");+const {page_params} = require("./lib/zpage_params.cjs");// Important note on these tests:@@ -93,6 +96,10 @@ mock_esm("../src/recent_view_ui", {is_in_focus: () => false,});+const spectators = mock_esm("../src/spectators", {+ login_to_access() {},+});+message_lists.current = {visibly_empty() {return false;@@ -561,3 +568,17 @@ run_test("test new user input hook called", () => {hotkey.process_keydown({which: "S".codePointAt(0)});assert.ok(hook_called);});++run_test("e shortcut works for anonymous users", () => {+ page_params.is_spectator = true;++ const stub = make_stub();+ spectators.login_to_access = stub.f;++ const e = {+ which: "e".codePointAt(0),+ };++ process_keydown(e);+ assert.equal(stub.num_calls, 0, "login_to_access should not be called for 'e' shortcut");+});