hotkey: Fix warning about unused login_to_access import.

This commit is contained in:
Aman Agrawal
2025-04-28 19:31:25 +05:30
committed by Tim Abbott
parent 142d1958a0
commit 645850ccfa
2 changed files with 11 additions and 6 deletions

View File

@@ -26,7 +26,7 @@ export function build_login_link(): string {
return login_link; return login_link;
} }
export function login_to_access(empty_narrow?: boolean): void { export let login_to_access = (empty_narrow?: boolean): void => {
// Hide all overlays, popover and go back to the previous hash if the // Hide all overlays, popover and go back to the previous hash if the
// hash has changed. // hash has changed.
const login_link = build_login_link(); const login_link = build_login_link();
@@ -49,4 +49,8 @@ export function login_to_access(empty_narrow?: boolean): void {
browser_history.return_to_web_public_hash(); browser_history.return_to_web_public_hash();
}, },
}); });
};
export function rewire_login_to_access(value: typeof login_to_access): void {
login_to_access = value;
} }

View File

@@ -96,9 +96,7 @@ mock_esm("../src/recent_view_ui", {
is_in_focus: () => false, is_in_focus: () => false,
}); });
const spectators = mock_esm("../src/spectators", { const spectators = zrequire("../src/spectators");
login_to_access() {},
});
message_lists.current = { message_lists.current = {
visibly_empty() { visibly_empty() {
@@ -569,11 +567,11 @@ run_test("test new user input hook called", () => {
assert.ok(hook_called); assert.ok(hook_called);
}); });
run_test("e shortcut works for anonymous users", () => { run_test("e shortcut works for anonymous users", ({override_rewire}) => {
page_params.is_spectator = true; page_params.is_spectator = true;
const stub = make_stub(); const stub = make_stub();
spectators.login_to_access = stub.f; override_rewire(spectators, "login_to_access", stub.f);
const e = { const e = {
which: "e".codePointAt(0), which: "e".codePointAt(0),
@@ -581,4 +579,7 @@ run_test("e shortcut works for anonymous users", () => {
process_keydown(e); process_keydown(e);
assert.equal(stub.num_calls, 0, "login_to_access should not be called for 'e' shortcut"); assert.equal(stub.num_calls, 0, "login_to_access should not be called for 'e' shortcut");
// Fake call to avoid warning about unused stub.
spectators.login_to_access();
assert.equal(stub.num_calls, 1);
}); });