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:
148
web/tests/rtl.test.cjs
Normal file
148
web/tests/rtl.test.cjs
Normal file
@@ -0,0 +1,148 @@
|
||||
"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 rtl = zrequire("rtl");
|
||||
|
||||
run_test("get_direction", () => {
|
||||
// These characters are strong R or AL: ا ب پ ج ض و د ؛
|
||||
// These characters are not strong: ۱ ۲ ۳ ۴ ۵ ۶ ۷ ۸ ۹ ۰
|
||||
|
||||
assert.equal(rtl.get_direction("abcابپ"), "ltr");
|
||||
assert.equal(rtl.get_direction("ابپabc"), "rtl");
|
||||
assert.equal(rtl.get_direction("123abc"), "ltr");
|
||||
assert.equal(rtl.get_direction("۱۲۳abc"), "ltr");
|
||||
assert.equal(rtl.get_direction("123؛بپ"), "rtl");
|
||||
assert.equal(rtl.get_direction("۱۲۳ابپ"), "rtl");
|
||||
assert.equal(rtl.get_direction("۱۲جg"), "rtl");
|
||||
assert.equal(rtl.get_direction("12gج"), "ltr");
|
||||
assert.equal(rtl.get_direction("۱۲۳"), "ltr");
|
||||
assert.equal(rtl.get_direction("1234"), "ltr");
|
||||
|
||||
const supp_plane_ltr_char = "\u{103A0}";
|
||||
const supp_plane_rtl_char = "\u{10840}";
|
||||
|
||||
assert.equal(rtl.get_direction(supp_plane_ltr_char), "ltr");
|
||||
assert.equal(rtl.get_direction(supp_plane_rtl_char), "rtl");
|
||||
assert.equal(rtl.get_direction("123" + supp_plane_ltr_char), "ltr");
|
||||
assert.equal(rtl.get_direction("123" + supp_plane_rtl_char), "rtl");
|
||||
assert.equal(rtl.get_direction(supp_plane_ltr_char + supp_plane_rtl_char), "ltr");
|
||||
assert.equal(rtl.get_direction(supp_plane_rtl_char + supp_plane_ltr_char), "rtl");
|
||||
assert.equal(rtl.get_direction(supp_plane_ltr_char + " " + supp_plane_rtl_char), "ltr");
|
||||
assert.equal(rtl.get_direction(supp_plane_rtl_char + " " + supp_plane_ltr_char), "rtl");
|
||||
assert.equal(rtl.get_direction(supp_plane_ltr_char + "ج" + supp_plane_rtl_char), "ltr");
|
||||
assert.equal(rtl.get_direction(supp_plane_rtl_char + "ج" + supp_plane_ltr_char), "rtl");
|
||||
assert.equal(rtl.get_direction("پ" + supp_plane_ltr_char + "." + supp_plane_rtl_char), "rtl");
|
||||
assert.equal(rtl.get_direction("پ" + supp_plane_rtl_char + "." + supp_plane_ltr_char), "rtl");
|
||||
assert.equal(rtl.get_direction("b" + supp_plane_ltr_char + "." + supp_plane_rtl_char), "ltr");
|
||||
assert.equal(rtl.get_direction("b" + supp_plane_rtl_char + "." + supp_plane_ltr_char), "ltr");
|
||||
|
||||
const unmatched_surrogate_1 = "\u{D800}";
|
||||
const unmatched_surrogate_2 = "\u{DF00}";
|
||||
|
||||
assert.equal(rtl.get_direction(unmatched_surrogate_1 + " "), "ltr");
|
||||
assert.equal(rtl.get_direction(unmatched_surrogate_2 + " "), "ltr");
|
||||
assert.equal(rtl.get_direction(" " + unmatched_surrogate_1), "ltr");
|
||||
assert.equal(rtl.get_direction(" " + unmatched_surrogate_2), "ltr");
|
||||
assert.equal(rtl.get_direction(" " + unmatched_surrogate_1 + " "), "ltr");
|
||||
assert.equal(rtl.get_direction(" " + unmatched_surrogate_2 + " "), "ltr");
|
||||
assert.equal(rtl.get_direction(unmatched_surrogate_1 + supp_plane_ltr_char), "ltr");
|
||||
assert.equal(rtl.get_direction(unmatched_surrogate_1 + supp_plane_rtl_char), "ltr");
|
||||
assert.equal(rtl.get_direction(unmatched_surrogate_2 + supp_plane_ltr_char), "ltr");
|
||||
assert.equal(rtl.get_direction(unmatched_surrogate_2 + supp_plane_rtl_char), "ltr");
|
||||
assert.equal(rtl.get_direction(supp_plane_ltr_char + unmatched_surrogate_1), "ltr");
|
||||
assert.equal(rtl.get_direction(supp_plane_ltr_char + unmatched_surrogate_2), "ltr");
|
||||
assert.equal(rtl.get_direction(supp_plane_rtl_char + unmatched_surrogate_1), "rtl");
|
||||
assert.equal(rtl.get_direction(supp_plane_rtl_char + unmatched_surrogate_2), "rtl");
|
||||
|
||||
// Testing with some isolate initiators and PDIs.
|
||||
const i_chars = "\u{2066}\u{2067}\u{2068}";
|
||||
const pdi = "\u{2069}";
|
||||
|
||||
assert.equal(rtl.get_direction("aa" + i_chars.charAt(0) + "bb" + pdi + "cc"), "ltr");
|
||||
assert.equal(rtl.get_direction("دد" + i_chars.charAt(0) + "bb" + pdi + "cc"), "rtl");
|
||||
assert.equal(rtl.get_direction("12" + i_chars.charAt(0) + "bb" + pdi + "جج"), "rtl");
|
||||
assert.equal(rtl.get_direction("۱۲" + i_chars.charAt(0) + "جج" + pdi + "cc"), "ltr");
|
||||
assert.equal(rtl.get_direction("aa" + i_chars.charAt(0) + "ج؛ج"), "ltr");
|
||||
assert.equal(rtl.get_direction("12" + i_chars.charAt(0) + "ج؛ج"), "ltr");
|
||||
assert.equal(rtl.get_direction("۱۲" + i_chars.charAt(0) + "aaa"), "ltr");
|
||||
assert.equal(
|
||||
rtl.get_direction(
|
||||
",," + i_chars.charAt(0) + "bb" + i_chars.charAt(0) + "جج" + pdi + "ضض" + pdi + "..",
|
||||
),
|
||||
"ltr",
|
||||
);
|
||||
assert.equal(
|
||||
rtl.get_direction(
|
||||
",," + i_chars.charAt(0) + "bb" + i_chars.charAt(0) + "جج" + pdi + "ضض" + pdi + "وو",
|
||||
),
|
||||
"rtl",
|
||||
);
|
||||
assert.equal(
|
||||
rtl.get_direction(",," + i_chars.charAt(0) + "bb" + pdi + "33" + pdi + ".."),
|
||||
"ltr",
|
||||
);
|
||||
assert.equal(
|
||||
rtl.get_direction(",," + i_chars.charAt(0) + "bb" + pdi + "12" + pdi + "وو"),
|
||||
"rtl",
|
||||
);
|
||||
assert.equal(
|
||||
rtl.get_direction(",," + i_chars.charAt(0) + "ضج" + pdi + "12" + pdi + "ff"),
|
||||
"ltr",
|
||||
);
|
||||
|
||||
assert.equal(rtl.get_direction("aa" + i_chars.charAt(1) + "bb" + pdi + "cc"), "ltr");
|
||||
assert.equal(rtl.get_direction("دد" + i_chars.charAt(2) + "bb" + pdi + "cc"), "rtl");
|
||||
assert.equal(rtl.get_direction("12" + i_chars.charAt(1) + "bb" + pdi + "جج"), "rtl");
|
||||
assert.equal(rtl.get_direction("۱۲" + i_chars.charAt(2) + "جج" + pdi + "cc"), "ltr");
|
||||
assert.equal(rtl.get_direction("aa" + i_chars.charAt(1) + "ججج"), "ltr");
|
||||
assert.equal(rtl.get_direction("12" + i_chars.charAt(2) + "ججج"), "ltr");
|
||||
assert.equal(rtl.get_direction("۱۲" + i_chars.charAt(1) + "aaa"), "ltr");
|
||||
assert.equal(
|
||||
rtl.get_direction(
|
||||
",," + i_chars.charAt(1) + "bb" + i_chars.charAt(2) + "جج" + pdi + "ضض" + pdi + "..",
|
||||
),
|
||||
"ltr",
|
||||
);
|
||||
assert.equal(
|
||||
rtl.get_direction(
|
||||
",," + i_chars.charAt(2) + "bb" + i_chars.charAt(1) + "؛ج" + pdi + "ضض" + pdi + "وو",
|
||||
),
|
||||
"rtl",
|
||||
);
|
||||
assert.equal(
|
||||
rtl.get_direction(",," + i_chars.charAt(1) + "bb" + pdi + "33" + pdi + ".."),
|
||||
"ltr",
|
||||
);
|
||||
assert.equal(
|
||||
rtl.get_direction(",," + i_chars.charAt(2) + "bb" + pdi + "12" + pdi + "وو"),
|
||||
"rtl",
|
||||
);
|
||||
assert.equal(
|
||||
rtl.get_direction(",," + i_chars.charAt(1) + "ضج" + pdi + "12" + pdi + "ff"),
|
||||
"ltr",
|
||||
);
|
||||
});
|
||||
|
||||
run_test("set_rtl_class_for_textarea rtl", () => {
|
||||
const $textarea = $.create("some-textarea");
|
||||
assert.ok(!$textarea.hasClass("rtl"));
|
||||
const text = "```quote\nمرحبا";
|
||||
$textarea.val(text);
|
||||
rtl.set_rtl_class_for_textarea($textarea);
|
||||
assert.ok($textarea.hasClass("rtl"));
|
||||
});
|
||||
|
||||
run_test("set_rtl_class_for_textarea ltr", () => {
|
||||
const $textarea = $.create("some-textarea");
|
||||
$textarea.addClass("rtl");
|
||||
assert.ok($textarea.hasClass("rtl"));
|
||||
const text = "```quote\nEnglish text";
|
||||
$textarea.val(text);
|
||||
rtl.set_rtl_class_for_textarea($textarea);
|
||||
assert.ok(!$textarea.hasClass("rtl"));
|
||||
});
|
||||
Reference in New Issue
Block a user