snapshot of https://github.com/zulip/zulip.git @ 48c69911c7dd4e03b20552eb3bd77ad8151c1357 (2026-09-15)
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
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
This commit is contained in:
159
web/tests/left_sidebar_navigation_area.test.cjs
Normal file
159
web/tests/left_sidebar_navigation_area.test.cjs
Normal file
@@ -0,0 +1,159 @@
|
||||
"use strict";
|
||||
|
||||
const assert = require("node:assert/strict");
|
||||
|
||||
const {mock_esm, set_global, zrequire} = require("./lib/namespace.cjs");
|
||||
const {run_test} = require("./lib/test.cjs");
|
||||
const {$} = require("./lib/zjquery.cjs");
|
||||
|
||||
mock_esm("../src/resize", {
|
||||
resize_stream_filters_container() {},
|
||||
});
|
||||
|
||||
const {Filter} = zrequire("../src/filter");
|
||||
const left_sidebar_navigation_area = zrequire("left_sidebar_navigation_area");
|
||||
const scheduled_messages = zrequire("scheduled_messages");
|
||||
const message_reminder = zrequire("message_reminder");
|
||||
|
||||
run_test("narrowing", ({override_rewire}) => {
|
||||
override_rewire(
|
||||
left_sidebar_navigation_area,
|
||||
"select_top_left_corner_item",
|
||||
(narrow_to_activate) => {
|
||||
const targets = [
|
||||
".top_left_mentions",
|
||||
".top_left_starred_messages",
|
||||
".top_left_all_messages",
|
||||
".top_left_recent_view",
|
||||
".top_left_inbox",
|
||||
];
|
||||
for (const target of targets) {
|
||||
$(target).removeClass("top-left-active-filter");
|
||||
}
|
||||
if (narrow_to_activate !== "") {
|
||||
$(narrow_to_activate).addClass("top-left-active-filter");
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
let filter = new Filter([{operator: "is", operand: "mentioned"}]);
|
||||
|
||||
// activating narrow
|
||||
|
||||
left_sidebar_navigation_area.handle_narrow_activated(filter);
|
||||
assert.ok($(".top_left_mentions").hasClass("top-left-active-filter"));
|
||||
|
||||
filter = new Filter([{operator: "is", operand: "starred"}]);
|
||||
left_sidebar_navigation_area.handle_narrow_activated(filter);
|
||||
assert.ok($(".top_left_starred_messages").hasClass("top-left-active-filter"));
|
||||
|
||||
filter = new Filter([{operator: "in", operand: "home"}]);
|
||||
left_sidebar_navigation_area.handle_narrow_activated(filter);
|
||||
assert.ok($(".top_left_all_messages").hasClass("top-left-active-filter"));
|
||||
|
||||
// deactivating narrow
|
||||
|
||||
left_sidebar_navigation_area.handle_narrow_activated(new Filter([]));
|
||||
|
||||
assert.ok(!$(".top_left_all_messages").hasClass("top-left-active-filter"));
|
||||
assert.ok(!$(".top_left_mentions").hasClass("top-left-active-filter"));
|
||||
assert.ok(!$(".top_left_starred_messages").hasClass("top-left-active-filter"));
|
||||
assert.ok(!$(".top_left_recent_view").hasClass("top-left-active-filter"));
|
||||
assert.ok(!$(".top_left_inbox").hasClass("top-left-active-filter"));
|
||||
|
||||
set_global("setTimeout", (f) => {
|
||||
f();
|
||||
});
|
||||
left_sidebar_navigation_area.highlight_recent_view();
|
||||
assert.ok(!$(".top_left_all_messages").hasClass("top-left-active-filter"));
|
||||
assert.ok(!$(".top_left_mentions").hasClass("top-left-active-filter"));
|
||||
assert.ok(!$(".top_left_starred_messages").hasClass("top-left-active-filter"));
|
||||
assert.ok(!$(".top_left_inbox").hasClass("top-left-active-filter"));
|
||||
assert.ok($(".top_left_recent_view").hasClass("top-left-active-filter"));
|
||||
|
||||
left_sidebar_navigation_area.handle_narrow_activated(new Filter([]));
|
||||
left_sidebar_navigation_area.highlight_inbox_view();
|
||||
assert.ok(!$(".top_left_all_messages").hasClass("top-left-active-filter"));
|
||||
assert.ok(!$(".top_left_mentions").hasClass("top-left-active-filter"));
|
||||
assert.ok(!$(".top_left_starred_messages").hasClass("top-left-active-filter"));
|
||||
assert.ok(!$(".top_left_recent_view").hasClass("top-left-active-filter"));
|
||||
assert.ok($(".top_left_inbox").hasClass("top-left-active-filter"));
|
||||
|
||||
left_sidebar_navigation_area.highlight_all_messages_view();
|
||||
assert.ok(!$(".top_left_mentions").hasClass("top-left-active-filter"));
|
||||
assert.ok(!$(".top_left_starred_messages").hasClass("top-left-active-filter"));
|
||||
assert.ok(!$(".top_left_recent_view").hasClass("top-left-active-filter"));
|
||||
assert.ok(!$(".top_left_inbox").hasClass("top-left-active-filter"));
|
||||
assert.ok($(".top_left_all_messages").hasClass("top-left-active-filter"));
|
||||
});
|
||||
|
||||
run_test("update_count_in_dom", () => {
|
||||
function make_elem($elem, count_selector) {
|
||||
const $count = $(count_selector);
|
||||
$elem.set_find_results(".unread_count", $count);
|
||||
$count.set_parent($elem);
|
||||
|
||||
return $elem;
|
||||
}
|
||||
|
||||
const counts = {
|
||||
mentioned_message_count: 222,
|
||||
home_unread_messages: 333,
|
||||
stream_unread_messages: 666,
|
||||
stream_count: new Map(),
|
||||
};
|
||||
message_reminder.set_reminders_by_id_for_testing(new Map([[1, {id: 1}]]));
|
||||
scheduled_messages.set_scheduled_messages_by_id_for_testing(
|
||||
new Map([
|
||||
[1, {id: 1}],
|
||||
[2, {id: 2}],
|
||||
]),
|
||||
);
|
||||
|
||||
$(".selected-home-view").set_find_results(".sidebar-menu-icon", $("<menu-icon>"));
|
||||
|
||||
make_elem($(".top_left_mentions"), "<mentioned-count>");
|
||||
|
||||
make_elem($(".top_left_inbox"), "<home-count>");
|
||||
|
||||
make_elem($(".selected-home-view"), "<home-count>");
|
||||
|
||||
make_elem($(".top_left_condensed_unread_marker"), "<condensed-unread-count>");
|
||||
|
||||
make_elem($(".top_left_starred_messages"), "<starred-count>");
|
||||
|
||||
make_elem($(".top_left_scheduled_messages"), "<scheduled-count>");
|
||||
|
||||
make_elem($(".top_left_reminders"), "<reminders-count>");
|
||||
|
||||
left_sidebar_navigation_area.update_dom_with_unread_counts(counts, false);
|
||||
left_sidebar_navigation_area.update_starred_count(444, false);
|
||||
left_sidebar_navigation_area.update_scheduled_messages_row();
|
||||
left_sidebar_navigation_area.update_reminders_row();
|
||||
|
||||
assert.equal($("<mentioned-count>").text(), "222");
|
||||
assert.equal($("<home-count>").text(), "333");
|
||||
assert.equal($("<condensed-unread-count>").text(), "333");
|
||||
assert.equal($("<starred-count>").text(), "444");
|
||||
assert.equal($("<scheduled-count>").text(), "2");
|
||||
assert.equal($("<reminders-count>").text(), "1");
|
||||
assert.ok(!$(".top_left_scheduled_messages").hasClass("hidden-by-filters"));
|
||||
assert.ok(!$(".top_left_reminders").hasClass("hidden-by-filters"));
|
||||
|
||||
counts.mentioned_message_count = 0;
|
||||
message_reminder.set_reminders_by_id_for_testing(new Map());
|
||||
scheduled_messages.set_scheduled_messages_by_id_for_testing(new Map());
|
||||
|
||||
left_sidebar_navigation_area.update_dom_with_unread_counts(counts, false);
|
||||
// Starred count is hidden.
|
||||
left_sidebar_navigation_area.update_starred_count(444, true);
|
||||
left_sidebar_navigation_area.update_scheduled_messages_row();
|
||||
left_sidebar_navigation_area.update_reminders_row();
|
||||
|
||||
assert.ok(!$("<mentioned-count>").visible());
|
||||
assert.equal($("<mentioned-count>").text(), "");
|
||||
assert.equal($("<starred-count>").text(), "444");
|
||||
assert.ok($(".top_left_starred_messages").hasClass("hide_starred_message_count"));
|
||||
assert.ok($(".top_left_scheduled_messages").hasClass("hidden-by-filters"));
|
||||
assert.ok($(".top_left_reminders").hasClass("hidden-by-filters"));
|
||||
});
|
||||
Reference in New Issue
Block a user