Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
119 lines
3.7 KiB
JavaScript
119 lines
3.7 KiB
JavaScript
"use strict";
|
|
|
|
const assert = require("node:assert/strict");
|
|
|
|
const {make_realm} = require("./lib/example_realm.cjs");
|
|
const {mock_esm, zrequire} = require("./lib/namespace.cjs");
|
|
const {noop, run_test} = require("./lib/test.cjs");
|
|
|
|
const activity = mock_esm("../src/activity");
|
|
const buddy_list_presence = mock_esm("../src/buddy_list_presence");
|
|
const scroll_util = mock_esm("../src/scroll_util");
|
|
const pm_list = mock_esm("../src/pm_list");
|
|
const util = mock_esm("../src/util");
|
|
mock_esm("../src/sidebar_header_sticky_shadow", {initialize() {}});
|
|
|
|
const state_data = zrequire("state_data");
|
|
const activity_ui = zrequire("activity_ui");
|
|
|
|
run_test("redraw", ({override, override_rewire}) => {
|
|
override_rewire(activity_ui, "build_user_sidebar", noop);
|
|
activity_ui.set_cursor_and_filter();
|
|
override(pm_list, "update_private_messages", noop);
|
|
override(buddy_list_presence, "update_indicators", noop);
|
|
|
|
activity_ui.redraw();
|
|
});
|
|
|
|
run_test("defer buddy list redraw while a user card is open", ({override, override_rewire}) => {
|
|
const realm = make_realm();
|
|
state_data.set_realm(realm);
|
|
override(realm, "realm_presence_disabled", false);
|
|
override(pm_list, "update_private_messages", noop);
|
|
override(buddy_list_presence, "update_indicators", noop);
|
|
activity_ui.set_cursor_and_filter();
|
|
|
|
activity_ui.set_user_card_open(true);
|
|
assert.equal(activity_ui.build_user_sidebar(), undefined);
|
|
activity_ui.redraw_user(1);
|
|
|
|
let build_count = 0;
|
|
override_rewire(activity_ui, "build_user_sidebar", () => {
|
|
build_count += 1;
|
|
return undefined;
|
|
});
|
|
activity_ui.set_user_card_open(false);
|
|
assert.equal(build_count, 1);
|
|
|
|
activity_ui.set_user_card_open(true);
|
|
activity_ui.set_user_card_open(false);
|
|
assert.equal(build_count, 1);
|
|
});
|
|
|
|
run_test("initialize", ({override, override_rewire}) => {
|
|
const realm = make_realm();
|
|
state_data.set_realm(realm);
|
|
|
|
override(realm, "server_presence_ping_interval_seconds", 42);
|
|
|
|
override_rewire(activity_ui, "set_cursor_and_filter", noop);
|
|
override_rewire(activity_ui, "build_user_sidebar", noop);
|
|
|
|
override(scroll_util, "get_scroll_element", (selector) => {
|
|
assert.equal(selector.selector, "#buddy_list_wrapper");
|
|
return {
|
|
on(action, callback) {
|
|
assert.equal(action, "scroll");
|
|
// We don't test the actual logic of the scroll
|
|
// handler here. We did our job to set it up.
|
|
assert.ok(callback !== undefined);
|
|
},
|
|
};
|
|
});
|
|
|
|
let expected_redraw;
|
|
let num_presence_calls = 0;
|
|
|
|
override(activity, "send_presence_to_server", (redraw) => {
|
|
num_presence_calls += 1;
|
|
assert.equal(redraw, expected_redraw);
|
|
});
|
|
|
|
let f_to_call_periodically;
|
|
|
|
override(util, "call_function_periodically", (f, delay) => {
|
|
f_to_call_periodically = f;
|
|
assert.equal(delay, 42000);
|
|
});
|
|
|
|
let my_user_id;
|
|
|
|
function narrow_by_user_id(user_id) {
|
|
my_user_id = user_id;
|
|
}
|
|
|
|
activity_ui.initialize({narrow_by_user_id});
|
|
|
|
assert.equal(my_user_id, undefined);
|
|
activity_ui.get_narrow_by_user_id_function_for_test_code()(1);
|
|
assert.equal(my_user_id, 1);
|
|
|
|
// Simulate the subsequent calls to
|
|
// activity.send_presence_to_server.
|
|
expected_redraw = activity_ui.redraw;
|
|
|
|
assert.equal(num_presence_calls, 1);
|
|
f_to_call_periodically();
|
|
f_to_call_periodically();
|
|
f_to_call_periodically();
|
|
f_to_call_periodically();
|
|
f_to_call_periodically();
|
|
assert.equal(num_presence_calls, 6);
|
|
f_to_call_periodically();
|
|
f_to_call_periodically();
|
|
f_to_call_periodically();
|
|
f_to_call_periodically();
|
|
f_to_call_periodically();
|
|
assert.equal(num_presence_calls, 11);
|
|
});
|