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:
151
web/tests/templates.test.cjs
Normal file
151
web/tests/templates.test.cjs
Normal file
@@ -0,0 +1,151 @@
|
||||
"use strict";
|
||||
|
||||
const assert = require("node:assert/strict");
|
||||
|
||||
const {set_global, with_overrides, zrequire} = require("./lib/namespace.cjs");
|
||||
const {run_test} = require("./lib/test.cjs");
|
||||
|
||||
const navigator = {};
|
||||
set_global("navigator", navigator);
|
||||
|
||||
const {initialize_user_settings} = zrequire("user_settings");
|
||||
|
||||
const user_settings = {};
|
||||
initialize_user_settings({user_settings});
|
||||
|
||||
/*
|
||||
Note that the test runner automatically registers
|
||||
all of our handlers.
|
||||
*/
|
||||
|
||||
run_test("and", () => {
|
||||
const args = {
|
||||
last: true,
|
||||
};
|
||||
|
||||
const html = require("./templates/and.hbs")(args);
|
||||
assert.equal(html, "<p>empty and</p>\n<p>last and</p>\n\n");
|
||||
});
|
||||
|
||||
run_test("or", () => {
|
||||
const args = {
|
||||
last: true,
|
||||
};
|
||||
|
||||
const html = require("./templates/or.hbs")(args);
|
||||
assert.equal(html, "\n<p>last or</p>\n<p>true or</p>\n");
|
||||
});
|
||||
|
||||
run_test("map_entries", () => {
|
||||
const html = require("./templates/map_entries.hbs")({
|
||||
m: new Map([
|
||||
["a", "b"],
|
||||
["c", "d"],
|
||||
]),
|
||||
});
|
||||
assert.equal(html, "a:b\nc:d\n");
|
||||
});
|
||||
|
||||
run_test("object_entries", () => {
|
||||
const html = require("./templates/object_entries.hbs")({
|
||||
o: {a: "b", c: "d"},
|
||||
});
|
||||
assert.equal(html, "a:b\nc:d\n");
|
||||
});
|
||||
|
||||
run_test("object_values", () => {
|
||||
const html = require("./templates/object_values.hbs")({
|
||||
o: {a: "b", c: "d"},
|
||||
});
|
||||
assert.equal(html, "b\nd\n");
|
||||
});
|
||||
|
||||
run_test("rendered_markdown", () => {
|
||||
const html = require("./templates/rendered_markdown.hbs")();
|
||||
const expected_html =
|
||||
'<a href="http://example.com" target="_blank" rel="noopener noreferrer" title="http://example.com/">good</a>\n';
|
||||
assert.equal(html, expected_html);
|
||||
});
|
||||
|
||||
run_test("numberFormat", () => {
|
||||
const args = {
|
||||
number: 1000000,
|
||||
};
|
||||
|
||||
const html = require("./templates/numberFormat.hbs")(args);
|
||||
assert.equal(html, "1,000,000\n");
|
||||
});
|
||||
|
||||
run_test("tooltip_hotkey_hints", () => {
|
||||
const args = {
|
||||
hotkey_one: "Ctrl",
|
||||
hotkey_two: "C",
|
||||
};
|
||||
|
||||
const html = require("./templates/tooltip_hotkey_hints.hbs")(args);
|
||||
const expected_html = `<span class="tooltip-hotkey-hints"><span class="tooltip-hotkey-hint">${args.hotkey_one}</span><span class="tooltip-hotkey-hint">${args.hotkey_two}</span></span>\n`;
|
||||
assert.equal(html, expected_html);
|
||||
});
|
||||
|
||||
run_test("popover_hotkey_hints", () => {
|
||||
const args = {
|
||||
hotkey_one: "Ctrl",
|
||||
hotkey_two: "[",
|
||||
};
|
||||
|
||||
const html = require("./templates/popover_hotkey_hints.hbs")(args);
|
||||
const expected_html = `<span class="popover-menu-hotkey-hints"><span class="popover-menu-hotkey-hint">${args.hotkey_one}</span><span class="popover-menu-hotkey-hint">${args.hotkey_two}</span></span>\n`;
|
||||
assert.equal(html, expected_html);
|
||||
});
|
||||
|
||||
run_test("popover_hotkey_hints mac command", () => {
|
||||
const args = {
|
||||
hotkey_one: "Ctrl",
|
||||
hotkey_two: "[",
|
||||
};
|
||||
|
||||
with_overrides(({override}) => {
|
||||
override(navigator, "platform", "MacIntel");
|
||||
const html = require("./templates/popover_hotkey_hints.hbs")(args);
|
||||
const expected_html =
|
||||
'<span class="popover-menu-hotkey-hints"><span class="popover-menu-hotkey-hint"><i class="zulip-icon zulip-icon-mac-command" aria-hidden="true"></i></span><span class="popover-menu-hotkey-hint">[</span></span>\n';
|
||||
assert.equal(html, expected_html);
|
||||
});
|
||||
});
|
||||
|
||||
run_test("popover_hotkey_hints_shift_hotkey", () => {
|
||||
const args = {
|
||||
hotkey_one: "Shift",
|
||||
hotkey_two: "V",
|
||||
};
|
||||
|
||||
const html = require("./templates/popover_hotkey_hints.hbs")(args);
|
||||
args.hotkey_one = "⇧"; // adjust_shift_hotkey
|
||||
const expected_html = `<span class="popover-menu-hotkey-hints popover-contains-shift-hotkey" data-hotkey-hints="${args.hotkey_one},${args.hotkey_two}"><span class="popover-menu-hotkey-hint">${args.hotkey_one}</span><span class="popover-menu-hotkey-hint">${args.hotkey_two}</span></span>\n`;
|
||||
assert.equal(html, expected_html);
|
||||
});
|
||||
|
||||
run_test("list_each", ({override}) => {
|
||||
assert.equal(
|
||||
require("./templates/list_each.hbs")({stuff: [{name: "x"}, {name: "y"}, {name: "z"}]}),
|
||||
`\
|
||||
<b>x</b>, <b>y</b>, and <b>z</b>
|
||||
<b>x</b> <b>y</b> <b>z</b>
|
||||
`,
|
||||
);
|
||||
assert.equal(
|
||||
require("./templates/list_each.hbs")({stuff: []}),
|
||||
`\
|
||||
empty
|
||||
|
||||
`,
|
||||
);
|
||||
override(user_settings, "default_language", "zh-Hans");
|
||||
assert.equal(
|
||||
require("./templates/list_each.hbs")({stuff: [{name: "水"}, {name: "粥"}, {name: "粥"}]}),
|
||||
`\
|
||||
<b>水</b>、<b>粥</b>和<b>粥</b>
|
||||
<b>水</b><b>粥</b><b>粥</b>
|
||||
`,
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user