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:
121
web/tests/ui_util.test.cjs
Normal file
121
web/tests/ui_util.test.cjs
Normal file
@@ -0,0 +1,121 @@
|
||||
"use strict";
|
||||
|
||||
const assert = require("node:assert/strict");
|
||||
|
||||
const {zrequire} = require("./lib/namespace.cjs");
|
||||
const {run_test} = require("./lib/test.cjs");
|
||||
const {$} = require("./lib/zjquery.cjs");
|
||||
|
||||
const ui_util = zrequire("ui_util");
|
||||
|
||||
run_test("potentially_collapse_quotes", ({override_rewire}) => {
|
||||
const $element = $.create("message-content");
|
||||
|
||||
$element.set_children([
|
||||
$.create("normal paragraph 1")[0],
|
||||
$.create("blockquote")[0],
|
||||
$.create("normal paragraph 2")[0],
|
||||
$.create("user said paragraph")[0],
|
||||
$.create("message quote")[0],
|
||||
$.create("normal paragraph 3")[0],
|
||||
]);
|
||||
override_rewire(ui_util, "get_collapsible_status_array", () => [
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
]);
|
||||
// When there are both collapsible and non-collapsible elements, for
|
||||
// multiple collapsible elements in a row, only the first element
|
||||
// should be collapsed, and the rest's text should be removed. Non-
|
||||
// collapsible elements should not be touched.
|
||||
let collapsed = ui_util.potentially_collapse_quotes($element);
|
||||
assert.equal(collapsed, true);
|
||||
let expected_texts = ["never-been-set", "[…]", "never-been-set", "[…]", "", "never-been-set"];
|
||||
assert.deepEqual(
|
||||
[...$element.children()].map((element) => element.textContent),
|
||||
expected_texts,
|
||||
);
|
||||
|
||||
$element.set_children([
|
||||
$.create("normal paragraph 4")[0],
|
||||
$.create("normal paragraph 5")[0],
|
||||
$.create("normal paragraph 6")[0],
|
||||
]);
|
||||
override_rewire(ui_util, "get_collapsible_status_array", () => [false, false, false]);
|
||||
// For all non-collapsible elements, none should be collapsed.
|
||||
collapsed = ui_util.potentially_collapse_quotes($element);
|
||||
assert.equal(collapsed, false);
|
||||
expected_texts = ["never-been-set", "never-been-set", "never-been-set"];
|
||||
assert.deepEqual(
|
||||
[...$element.children()].map((element) => element.textContent),
|
||||
expected_texts,
|
||||
);
|
||||
|
||||
$element.set_children([
|
||||
$.create("blockquote 1")[0],
|
||||
$.create("blockquote 2")[0],
|
||||
$.create("blockquote 3")[0],
|
||||
]);
|
||||
override_rewire(ui_util, "get_collapsible_status_array", () => [true, true, true]);
|
||||
// For all collapsible elements, none should be collapsed.
|
||||
collapsed = ui_util.potentially_collapse_quotes($element);
|
||||
assert.equal(collapsed, false);
|
||||
expected_texts = ["never-been-set", "never-been-set", "never-been-set"];
|
||||
assert.deepEqual(
|
||||
[...$element.children()].map((element) => element.textContent),
|
||||
expected_texts,
|
||||
);
|
||||
});
|
||||
|
||||
run_test("topic search term parsing", ({override_rewire}) => {
|
||||
// get_left_sidebar_search_term() already trims, so each value
|
||||
// here stands in for an already-trimmed search input.
|
||||
function set_search_term(term) {
|
||||
override_rewire(ui_util, "get_left_sidebar_search_term", () => term);
|
||||
}
|
||||
|
||||
// Without the "topic:" prefix, there is no topic search.
|
||||
set_search_term("foo");
|
||||
assert.equal(ui_util.get_left_sidebar_topic_search_term(), undefined);
|
||||
assert.equal(ui_util.is_topic_search(), false);
|
||||
|
||||
// The "topic:" prefix yields the rest of the term as the query.
|
||||
set_search_term("topic:foo");
|
||||
assert.equal(ui_util.get_left_sidebar_topic_search_term(), "foo");
|
||||
assert.equal(ui_util.is_topic_search(), true);
|
||||
|
||||
// Whitespace after the prefix is trimmed off the query.
|
||||
set_search_term("topic: important");
|
||||
assert.equal(ui_util.get_left_sidebar_topic_search_term(), "important");
|
||||
|
||||
// The prefix match is case-insensitive; the query keeps its case.
|
||||
set_search_term("TOPIC:Foo");
|
||||
assert.equal(ui_util.get_left_sidebar_topic_search_term(), "Foo");
|
||||
assert.equal(ui_util.is_topic_search(), true);
|
||||
|
||||
// The prefix alone, with an empty query, still counts as a topic
|
||||
// search (so the sidebar switches to topic-filtering mode).
|
||||
set_search_term("topic:");
|
||||
assert.equal(ui_util.get_left_sidebar_topic_search_term(), "");
|
||||
assert.equal(ui_util.is_topic_search(), true);
|
||||
|
||||
// "topic:" only counts as a prefix, not when it appears mid-term.
|
||||
set_search_term("mytopic:foo");
|
||||
assert.equal(ui_util.get_left_sidebar_topic_search_term(), undefined);
|
||||
assert.equal(ui_util.is_topic_search(), false);
|
||||
});
|
||||
|
||||
run_test("replace_emoji_name_with_emoji_unicode", () => {
|
||||
const $emoji = $.create("span").attr("class", "emoji emoji-1f419");
|
||||
$emoji.set_matches("img", false);
|
||||
|
||||
const octopus_emoji = "🐙";
|
||||
assert.equal(octopus_emoji, ui_util.convert_emoji_element_to_unicode($emoji));
|
||||
|
||||
$emoji.attr("class", "emoji emoji-1f468-200d-1f373");
|
||||
const man_cook_emoji = "👨🍳";
|
||||
assert.equal(man_cook_emoji, ui_util.convert_emoji_element_to_unicode($emoji));
|
||||
});
|
||||
Reference in New Issue
Block a user