mirror of https://github.com/zulip/zulip.git
tests: Use override more for realm.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
e84bb9ff2c
commit
ddf0fafab7
|
@ -337,19 +337,28 @@ test_ui("test_stream_wildcard_mention_allowed", ({override, override_rewire}) =>
|
||||||
// policy matters.
|
// policy matters.
|
||||||
override_rewire(peer_data, "get_subscriber_count", () => 16);
|
override_rewire(peer_data, "get_subscriber_count", () => 16);
|
||||||
|
|
||||||
realm.realm_wildcard_mention_policy =
|
override(
|
||||||
settings_config.wildcard_mention_policy_values.by_everyone.code;
|
realm,
|
||||||
|
"realm_wildcard_mention_policy",
|
||||||
|
settings_config.wildcard_mention_policy_values.by_everyone.code,
|
||||||
|
);
|
||||||
override(current_user, "is_guest", true);
|
override(current_user, "is_guest", true);
|
||||||
override(current_user, "is_admin", false);
|
override(current_user, "is_admin", false);
|
||||||
assert.ok(compose_validate.stream_wildcard_mention_allowed());
|
assert.ok(compose_validate.stream_wildcard_mention_allowed());
|
||||||
|
|
||||||
realm.realm_wildcard_mention_policy =
|
override(
|
||||||
settings_config.wildcard_mention_policy_values.nobody.code;
|
realm,
|
||||||
|
"realm_wildcard_mention_policy",
|
||||||
|
settings_config.wildcard_mention_policy_values.nobody.code,
|
||||||
|
);
|
||||||
override(current_user, "is_admin", true);
|
override(current_user, "is_admin", true);
|
||||||
assert.ok(!compose_validate.stream_wildcard_mention_allowed());
|
assert.ok(!compose_validate.stream_wildcard_mention_allowed());
|
||||||
|
|
||||||
realm.realm_wildcard_mention_policy =
|
override(
|
||||||
settings_config.wildcard_mention_policy_values.by_members.code;
|
realm,
|
||||||
|
"realm_wildcard_mention_policy",
|
||||||
|
settings_config.wildcard_mention_policy_values.by_members.code,
|
||||||
|
);
|
||||||
override(current_user, "is_guest", true);
|
override(current_user, "is_guest", true);
|
||||||
override(current_user, "is_admin", false);
|
override(current_user, "is_admin", false);
|
||||||
assert.ok(!compose_validate.stream_wildcard_mention_allowed());
|
assert.ok(!compose_validate.stream_wildcard_mention_allowed());
|
||||||
|
@ -357,16 +366,22 @@ test_ui("test_stream_wildcard_mention_allowed", ({override, override_rewire}) =>
|
||||||
override(current_user, "is_guest", false);
|
override(current_user, "is_guest", false);
|
||||||
assert.ok(compose_validate.stream_wildcard_mention_allowed());
|
assert.ok(compose_validate.stream_wildcard_mention_allowed());
|
||||||
|
|
||||||
realm.realm_wildcard_mention_policy =
|
override(
|
||||||
settings_config.wildcard_mention_policy_values.by_moderators_only.code;
|
realm,
|
||||||
|
"realm_wildcard_mention_policy",
|
||||||
|
settings_config.wildcard_mention_policy_values.by_moderators_only.code,
|
||||||
|
);
|
||||||
override(current_user, "is_moderator", false);
|
override(current_user, "is_moderator", false);
|
||||||
assert.ok(!compose_validate.stream_wildcard_mention_allowed());
|
assert.ok(!compose_validate.stream_wildcard_mention_allowed());
|
||||||
|
|
||||||
override(current_user, "is_moderator", true);
|
override(current_user, "is_moderator", true);
|
||||||
assert.ok(compose_validate.stream_wildcard_mention_allowed());
|
assert.ok(compose_validate.stream_wildcard_mention_allowed());
|
||||||
|
|
||||||
realm.realm_wildcard_mention_policy =
|
override(
|
||||||
settings_config.wildcard_mention_policy_values.by_admins_only.code;
|
realm,
|
||||||
|
"realm_wildcard_mention_policy",
|
||||||
|
settings_config.wildcard_mention_policy_values.by_admins_only.code,
|
||||||
|
);
|
||||||
override(current_user, "is_admin", false);
|
override(current_user, "is_admin", false);
|
||||||
assert.ok(!compose_validate.stream_wildcard_mention_allowed());
|
assert.ok(!compose_validate.stream_wildcard_mention_allowed());
|
||||||
|
|
||||||
|
@ -375,8 +390,11 @@ test_ui("test_stream_wildcard_mention_allowed", ({override, override_rewire}) =>
|
||||||
override(current_user, "is_admin", true);
|
override(current_user, "is_admin", true);
|
||||||
assert.ok(compose_validate.stream_wildcard_mention_allowed());
|
assert.ok(compose_validate.stream_wildcard_mention_allowed());
|
||||||
|
|
||||||
realm.realm_wildcard_mention_policy =
|
override(
|
||||||
settings_config.wildcard_mention_policy_values.by_full_members.code;
|
realm,
|
||||||
|
"realm_wildcard_mention_policy",
|
||||||
|
settings_config.wildcard_mention_policy_values.by_full_members.code,
|
||||||
|
);
|
||||||
const person = people.get_by_user_id(current_user.user_id);
|
const person = people.get_by_user_id(current_user.user_id);
|
||||||
person.date_joined = new Date(Date.now());
|
person.date_joined = new Date(Date.now());
|
||||||
override(realm, "realm_waiting_period_threshold", 10);
|
override(realm, "realm_waiting_period_threshold", 10);
|
||||||
|
@ -388,8 +406,11 @@ test_ui("test_stream_wildcard_mention_allowed", ({override, override_rewire}) =>
|
||||||
// Now, check for small streams (<=15 subscribers) where the wildcard mention
|
// Now, check for small streams (<=15 subscribers) where the wildcard mention
|
||||||
// policy doesn't matter; everyone is allowed to use wildcard mentions.
|
// policy doesn't matter; everyone is allowed to use wildcard mentions.
|
||||||
override_rewire(peer_data, "get_subscriber_count", () => 14);
|
override_rewire(peer_data, "get_subscriber_count", () => 14);
|
||||||
realm.realm_wildcard_mention_policy =
|
override(
|
||||||
settings_config.wildcard_mention_policy_values.by_admins_only.code;
|
realm,
|
||||||
|
"realm_wildcard_mention_policy",
|
||||||
|
settings_config.wildcard_mention_policy_values.by_admins_only.code,
|
||||||
|
);
|
||||||
override(current_user, "is_admin", false);
|
override(current_user, "is_admin", false);
|
||||||
override(current_user, "is_guest", true);
|
override(current_user, "is_guest", true);
|
||||||
assert.ok(compose_validate.stream_wildcard_mention_allowed());
|
assert.ok(compose_validate.stream_wildcard_mention_allowed());
|
||||||
|
|
|
@ -888,9 +888,9 @@ test("initialize", ({override, override_rewire, mock_template}) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
let expected_value;
|
let expected_value;
|
||||||
realm.custom_profile_field_types = {
|
override(realm, "custom_profile_field_types", {
|
||||||
PRONOUNS: {id: 8, name: "Pronouns"},
|
PRONOUNS: {id: 8, name: "Pronouns"},
|
||||||
};
|
});
|
||||||
|
|
||||||
mock_template("typeahead_list_item.hbs", true, (data, html) => {
|
mock_template("typeahead_list_item.hbs", true, (data, html) => {
|
||||||
assert.equal(typeof data.primary, "string");
|
assert.equal(typeof data.primary, "string");
|
||||||
|
|
|
@ -474,7 +474,7 @@ run_test("realm settings", ({override}) => {
|
||||||
|
|
||||||
// realm
|
// realm
|
||||||
function test_realm_boolean(event, parameter_name) {
|
function test_realm_boolean(event, parameter_name) {
|
||||||
realm[parameter_name] = true;
|
override(realm, parameter_name, true);
|
||||||
event = {...event};
|
event = {...event};
|
||||||
event.value = false;
|
event.value = false;
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
|
@ -486,7 +486,7 @@ run_test("realm settings", ({override}) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_realm_integer(event, parameter_name) {
|
function test_realm_integer(event, parameter_name) {
|
||||||
realm[parameter_name] = 1;
|
override(realm, parameter_name, 1);
|
||||||
event = {...event};
|
event = {...event};
|
||||||
event.value = 2;
|
event.value = 2;
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
|
|
|
@ -576,10 +576,10 @@ test_people("my_custom_profile_data", () => {
|
||||||
assert.equal(people.my_custom_profile_data(4), "My phone number");
|
assert.equal(people.my_custom_profile_data(4), "My phone number");
|
||||||
});
|
});
|
||||||
|
|
||||||
test_people("get_custom_fields_by_type", () => {
|
test_people("get_custom_fields_by_type", ({override}) => {
|
||||||
people.add_active_user(stewie);
|
people.add_active_user(stewie);
|
||||||
const person = people.get_by_user_id(stewie.user_id);
|
const person = people.get_by_user_id(stewie.user_id);
|
||||||
realm.custom_profile_field_types = {
|
override(realm, "custom_profile_field_types", {
|
||||||
SHORT_TEXT: {
|
SHORT_TEXT: {
|
||||||
id: 1,
|
id: 1,
|
||||||
name: "Short text",
|
name: "Short text",
|
||||||
|
@ -588,8 +588,8 @@ test_people("get_custom_fields_by_type", () => {
|
||||||
id: 8,
|
id: 8,
|
||||||
name: "Pronouns",
|
name: "Pronouns",
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
realm.custom_profile_fields = [
|
override(realm, "custom_profile_fields", [
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: "Phone number (mobile)",
|
name: "Phone number (mobile)",
|
||||||
|
@ -605,7 +605,7 @@ test_people("get_custom_fields_by_type", () => {
|
||||||
name: "Pronouns",
|
name: "Pronouns",
|
||||||
type: 8,
|
type: 8,
|
||||||
},
|
},
|
||||||
];
|
]);
|
||||||
const SHORT_TEXT_ID = 1;
|
const SHORT_TEXT_ID = 1;
|
||||||
assert.deepEqual(people.get_custom_fields_by_type(person.user_id, SHORT_TEXT_ID), [
|
assert.deepEqual(people.get_custom_fields_by_type(person.user_id, SHORT_TEXT_ID), [
|
||||||
"(888) 888-8888",
|
"(888) 888-8888",
|
||||||
|
|
|
@ -40,11 +40,11 @@ bot_data.initialize(bot_data_params);
|
||||||
function test(label, f) {
|
function test(label, f) {
|
||||||
run_test(label, ({override}) => {
|
run_test(label, ({override}) => {
|
||||||
override(realm, "realm_url", "https://chat.example.com");
|
override(realm, "realm_url", "https://chat.example.com");
|
||||||
realm.realm_embedded_bots = [
|
override(realm, "realm_embedded_bots", [
|
||||||
{name: "converter", config: {}},
|
{name: "converter", config: {}},
|
||||||
{name: "giphy", config: {key: "12345678"}},
|
{name: "giphy", config: {key: "12345678"}},
|
||||||
{name: "foobot", config: {bar: "baz", qux: "quux"}},
|
{name: "foobot", config: {bar: "baz", qux: "quux"}},
|
||||||
];
|
]);
|
||||||
|
|
||||||
f({override});
|
f({override});
|
||||||
});
|
});
|
||||||
|
|
|
@ -112,34 +112,34 @@ run_test("user_can_change_logo", ({override}) => {
|
||||||
function test_policy(label, policy, validation_func) {
|
function test_policy(label, policy, validation_func) {
|
||||||
run_test(label, ({override}) => {
|
run_test(label, ({override}) => {
|
||||||
override(current_user, "is_admin", true);
|
override(current_user, "is_admin", true);
|
||||||
realm[policy] = settings_config.common_policy_values.by_admins_only.code;
|
override(realm, policy, settings_config.common_policy_values.by_admins_only.code);
|
||||||
assert.equal(validation_func(), true);
|
assert.equal(validation_func(), true);
|
||||||
|
|
||||||
override(current_user, "is_admin", false);
|
override(current_user, "is_admin", false);
|
||||||
assert.equal(validation_func(), false);
|
assert.equal(validation_func(), false);
|
||||||
|
|
||||||
override(current_user, "is_moderator", true);
|
override(current_user, "is_moderator", true);
|
||||||
realm[policy] = settings_config.common_policy_values.by_moderators_only.code;
|
override(realm, policy, settings_config.common_policy_values.by_moderators_only.code);
|
||||||
assert.equal(validation_func(), true);
|
assert.equal(validation_func(), true);
|
||||||
|
|
||||||
override(current_user, "is_moderator", false);
|
override(current_user, "is_moderator", false);
|
||||||
assert.equal(validation_func(), false);
|
assert.equal(validation_func(), false);
|
||||||
|
|
||||||
override(current_user, "is_guest", true);
|
override(current_user, "is_guest", true);
|
||||||
realm[policy] = settings_config.common_policy_values.by_members.code;
|
override(realm, policy, settings_config.common_policy_values.by_members.code);
|
||||||
assert.equal(validation_func(), false);
|
assert.equal(validation_func(), false);
|
||||||
|
|
||||||
override(current_user, "is_guest", false);
|
override(current_user, "is_guest", false);
|
||||||
assert.equal(validation_func(), true);
|
assert.equal(validation_func(), true);
|
||||||
|
|
||||||
page_params.is_spectator = true;
|
page_params.is_spectator = true;
|
||||||
realm[policy] = settings_config.common_policy_values.by_members.code;
|
override(realm, policy, settings_config.common_policy_values.by_members.code);
|
||||||
assert.equal(validation_func(), false);
|
assert.equal(validation_func(), false);
|
||||||
|
|
||||||
page_params.is_spectator = false;
|
page_params.is_spectator = false;
|
||||||
assert.equal(validation_func(), true);
|
assert.equal(validation_func(), true);
|
||||||
|
|
||||||
realm[policy] = settings_config.common_policy_values.by_full_members.code;
|
override(realm, policy, settings_config.common_policy_values.by_full_members.code);
|
||||||
override(current_user, "user_id", 30);
|
override(current_user, "user_id", 30);
|
||||||
isaac.date_joined = new Date(Date.now());
|
isaac.date_joined = new Date(Date.now());
|
||||||
settings_data.initialize(isaac.date_joined);
|
settings_data.initialize(isaac.date_joined);
|
||||||
|
@ -176,30 +176,34 @@ test_policy(
|
||||||
function test_message_policy(label, policy, validation_func) {
|
function test_message_policy(label, policy, validation_func) {
|
||||||
run_test(label, ({override}) => {
|
run_test(label, ({override}) => {
|
||||||
override(current_user, "is_admin", true);
|
override(current_user, "is_admin", true);
|
||||||
realm[policy] = settings_config.common_message_policy_values.by_admins_only.code;
|
override(realm, policy, settings_config.common_message_policy_values.by_admins_only.code);
|
||||||
assert.equal(validation_func(), true);
|
assert.equal(validation_func(), true);
|
||||||
|
|
||||||
override(current_user, "is_admin", false);
|
override(current_user, "is_admin", false);
|
||||||
override(current_user, "is_moderator", true);
|
override(current_user, "is_moderator", true);
|
||||||
assert.equal(validation_func(), false);
|
assert.equal(validation_func(), false);
|
||||||
|
|
||||||
realm[policy] = settings_config.common_message_policy_values.by_moderators_only.code;
|
override(
|
||||||
|
realm,
|
||||||
|
policy,
|
||||||
|
settings_config.common_message_policy_values.by_moderators_only.code,
|
||||||
|
);
|
||||||
assert.equal(validation_func(), true);
|
assert.equal(validation_func(), true);
|
||||||
|
|
||||||
override(current_user, "is_moderator", false);
|
override(current_user, "is_moderator", false);
|
||||||
assert.equal(validation_func(), false);
|
assert.equal(validation_func(), false);
|
||||||
|
|
||||||
override(current_user, "is_guest", true);
|
override(current_user, "is_guest", true);
|
||||||
realm[policy] = settings_config.common_message_policy_values.by_everyone.code;
|
override(realm, policy, settings_config.common_message_policy_values.by_everyone.code);
|
||||||
assert.equal(validation_func(), true);
|
assert.equal(validation_func(), true);
|
||||||
|
|
||||||
realm[policy] = settings_config.common_message_policy_values.by_members.code;
|
override(realm, policy, settings_config.common_message_policy_values.by_members.code);
|
||||||
assert.equal(validation_func(), false);
|
assert.equal(validation_func(), false);
|
||||||
|
|
||||||
override(current_user, "is_guest", false);
|
override(current_user, "is_guest", false);
|
||||||
assert.equal(validation_func(), true);
|
assert.equal(validation_func(), true);
|
||||||
|
|
||||||
realm[policy] = settings_config.common_message_policy_values.by_full_members.code;
|
override(realm, policy, settings_config.common_message_policy_values.by_full_members.code);
|
||||||
override(current_user, "user_id", 30);
|
override(current_user, "user_id", 30);
|
||||||
isaac.date_joined = new Date(Date.now());
|
isaac.date_joined = new Date(Date.now());
|
||||||
override(realm, "realm_waiting_period_threshold", 10);
|
override(realm, "realm_waiting_period_threshold", 10);
|
||||||
|
@ -232,8 +236,11 @@ run_test("user_can_move_messages_to_another_topic_nobody_case", ({override}) =>
|
||||||
run_test("user_can_move_messages_between_streams_nobody_case", ({override}) => {
|
run_test("user_can_move_messages_between_streams_nobody_case", ({override}) => {
|
||||||
override(current_user, "is_admin", true);
|
override(current_user, "is_admin", true);
|
||||||
override(current_user, "is_guest", false);
|
override(current_user, "is_guest", false);
|
||||||
realm.realm_move_messages_between_streams_policy =
|
override(
|
||||||
settings_config.move_messages_between_streams_policy_values.nobody.code;
|
realm,
|
||||||
|
"realm_move_messages_between_streams_policy",
|
||||||
|
settings_config.move_messages_between_streams_policy_values.nobody.code,
|
||||||
|
);
|
||||||
assert.equal(settings_data.user_can_move_messages_between_streams(), false);
|
assert.equal(settings_data.user_can_move_messages_between_streams(), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -272,8 +279,11 @@ run_test("using_dark_theme", ({override}) => {
|
||||||
run_test("user_can_invite_others_to_realm_nobody_case", ({override}) => {
|
run_test("user_can_invite_others_to_realm_nobody_case", ({override}) => {
|
||||||
override(current_user, "is_admin", true);
|
override(current_user, "is_admin", true);
|
||||||
override(current_user, "is_guest", false);
|
override(current_user, "is_guest", false);
|
||||||
realm.realm_invite_to_realm_policy =
|
override(
|
||||||
settings_config.email_invite_to_realm_policy_values.nobody.code;
|
realm,
|
||||||
|
"realm_invite_to_realm_policy",
|
||||||
|
settings_config.email_invite_to_realm_policy_values.nobody.code,
|
||||||
|
);
|
||||||
assert.equal(settings_data.user_can_invite_users_by_email(), false);
|
assert.equal(settings_data.user_can_invite_users_by_email(), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -322,14 +332,14 @@ function test_realm_group_settings(setting_name, validation_func) {
|
||||||
|
|
||||||
page_params.is_spectator = false;
|
page_params.is_spectator = false;
|
||||||
override(current_user, "is_guest", false);
|
override(current_user, "is_guest", false);
|
||||||
realm[setting_name] = 1;
|
override(realm, setting_name, 1);
|
||||||
override(current_user, "user_id", admin_user_id);
|
override(current_user, "user_id", admin_user_id);
|
||||||
assert.equal(validation_func(), true);
|
assert.equal(validation_func(), true);
|
||||||
|
|
||||||
override(current_user, "user_id", moderator_user_id);
|
override(current_user, "user_id", moderator_user_id);
|
||||||
assert.equal(validation_func(), false);
|
assert.equal(validation_func(), false);
|
||||||
|
|
||||||
realm[setting_name] = 2;
|
override(realm, setting_name, 2);
|
||||||
override(current_user, "user_id", moderator_user_id);
|
override(current_user, "user_id", moderator_user_id);
|
||||||
assert.equal(validation_func(), true);
|
assert.equal(validation_func(), true);
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
const assert = require("node:assert/strict");
|
const assert = require("node:assert/strict");
|
||||||
|
|
||||||
const {$t} = require("./lib/i18n");
|
const {$t} = require("./lib/i18n");
|
||||||
const {mock_esm, zrequire, set_global} = require("./lib/namespace");
|
const {mock_esm, set_global, zrequire} = require("./lib/namespace");
|
||||||
const {run_test, noop} = require("./lib/test");
|
const {run_test, noop} = require("./lib/test");
|
||||||
const blueslip = require("./lib/zblueslip");
|
const blueslip = require("./lib/zblueslip");
|
||||||
const $ = require("./lib/zjquery");
|
const $ = require("./lib/zjquery");
|
||||||
|
@ -38,10 +38,10 @@ function test(label, f) {
|
||||||
run_test(label, (helpers) => {
|
run_test(label, (helpers) => {
|
||||||
$("#realm-icon-upload-widget .upload-spinner-background").css = noop;
|
$("#realm-icon-upload-widget .upload-spinner-background").css = noop;
|
||||||
helpers.override(current_user, "is_admin", false);
|
helpers.override(current_user, "is_admin", false);
|
||||||
realm.realm_domains = [
|
helpers.override(realm, "realm_domains", [
|
||||||
{domain: "example.com", allow_subdomains: true},
|
{domain: "example.com", allow_subdomains: true},
|
||||||
{domain: "example.org", allow_subdomains: false},
|
{domain: "example.org", allow_subdomains: false},
|
||||||
];
|
]);
|
||||||
helpers.override(realm, "realm_authentication_methods", {});
|
helpers.override(realm, "realm_authentication_methods", {});
|
||||||
settings_org.reset();
|
settings_org.reset();
|
||||||
f(helpers);
|
f(helpers);
|
||||||
|
@ -320,11 +320,15 @@ function test_sync_realm_settings({override}) {
|
||||||
in the following order - by_admins_only, by_moderators_only, by_full_members,
|
in the following order - by_admins_only, by_moderators_only, by_full_members,
|
||||||
by_members. */
|
by_members. */
|
||||||
|
|
||||||
realm[`realm_${property_name}`] = settings_config.common_policy_values.by_members.code;
|
override(
|
||||||
|
realm,
|
||||||
|
`realm_${property_name}`,
|
||||||
|
settings_config.common_policy_values.by_members.code,
|
||||||
|
);
|
||||||
$property_elem.val(settings_config.common_policy_values.by_members.code);
|
$property_elem.val(settings_config.common_policy_values.by_members.code);
|
||||||
|
|
||||||
for (const policy_value of Object.values(settings_config.common_policy_values)) {
|
for (const policy_value of Object.values(settings_config.common_policy_values)) {
|
||||||
realm[`realm_${property_name}`] = policy_value.code;
|
override(realm, `realm_${property_name}`, policy_value.code);
|
||||||
settings_org.sync_realm_settings(property_name);
|
settings_org.sync_realm_settings(property_name);
|
||||||
assert.equal($property_elem.val(), policy_value.code);
|
assert.equal($property_elem.val(), policy_value.code);
|
||||||
}
|
}
|
||||||
|
@ -409,12 +413,15 @@ function test_sync_realm_settings({override}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_parse_time_limit() {
|
function test_parse_time_limit({override}) {
|
||||||
const $elem = $("#id_realm_message_content_edit_limit_minutes");
|
const $elem = $("#id_realm_message_content_edit_limit_minutes");
|
||||||
const test_function = (value, expected_value = value) => {
|
const test_function = (value, expected_value = value) => {
|
||||||
$elem.val(value);
|
$elem.val(value);
|
||||||
realm.realm_message_content_edit_limit_seconds =
|
override(
|
||||||
settings_components.parse_time_limit($elem);
|
realm,
|
||||||
|
"realm_message_content_edit_limit_seconds",
|
||||||
|
settings_components.parse_time_limit($elem),
|
||||||
|
);
|
||||||
assert.equal(
|
assert.equal(
|
||||||
settings_components.get_realm_time_limits_in_minutes(
|
settings_components.get_realm_time_limits_in_minutes(
|
||||||
"realm_message_content_edit_limit_seconds",
|
"realm_message_content_edit_limit_seconds",
|
||||||
|
@ -516,7 +523,7 @@ function test_discard_changes_button({override}, discard_changes) {
|
||||||
|
|
||||||
test("set_up", ({override, override_rewire}) => {
|
test("set_up", ({override, override_rewire}) => {
|
||||||
override_rewire(settings_org, "check_disable_message_delete_limit_setting_dropdown", noop);
|
override_rewire(settings_org, "check_disable_message_delete_limit_setting_dropdown", noop);
|
||||||
realm.realm_available_video_chat_providers = {
|
override(realm, "realm_available_video_chat_providers", {
|
||||||
jitsi_meet: {
|
jitsi_meet: {
|
||||||
id: 1,
|
id: 1,
|
||||||
name: "Jitsi Meet",
|
name: "Jitsi Meet",
|
||||||
|
@ -529,7 +536,7 @@ test("set_up", ({override, override_rewire}) => {
|
||||||
id: 4,
|
id: 4,
|
||||||
name: "BigBlueButton",
|
name: "BigBlueButton",
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
|
|
||||||
let upload_realm_logo_or_icon;
|
let upload_realm_logo_or_icon;
|
||||||
realm_icon.build_realm_icon_widget = (f) => {
|
realm_icon.build_realm_icon_widget = (f) => {
|
||||||
|
@ -679,7 +686,7 @@ test("set_up", ({override, override_rewire}) => {
|
||||||
test_extract_property_name();
|
test_extract_property_name();
|
||||||
test_change_save_button_state();
|
test_change_save_button_state();
|
||||||
test_sync_realm_settings({override});
|
test_sync_realm_settings({override});
|
||||||
test_parse_time_limit();
|
test_parse_time_limit({override});
|
||||||
test_discard_changes_button(
|
test_discard_changes_button(
|
||||||
{override},
|
{override},
|
||||||
$(".admin-realm-form").get_on_handler(
|
$(".admin-realm-form").get_on_handler(
|
||||||
|
|
|
@ -826,11 +826,11 @@ test("highlight_with_escaping", () => {
|
||||||
assert.equal(result, expected);
|
assert.equal(result, expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("render_person when emails hidden", ({mock_template}) => {
|
test("render_person when emails hidden", ({mock_template, override}) => {
|
||||||
// Test render_person with regular person, under hidden email visibility case
|
// Test render_person with regular person, under hidden email visibility case
|
||||||
realm.custom_profile_field_types = {
|
override(realm, "custom_profile_field_types", {
|
||||||
PRONOUNS: {id: 8, name: "Pronouns"},
|
PRONOUNS: {id: 8, name: "Pronouns"},
|
||||||
};
|
});
|
||||||
let rendered = false;
|
let rendered = false;
|
||||||
mock_template("typeahead_list_item.hbs", false, (args) => {
|
mock_template("typeahead_list_item.hbs", false, (args) => {
|
||||||
assert.equal(args.primary, b_user_1.full_name);
|
assert.equal(args.primary, b_user_1.full_name);
|
||||||
|
@ -842,12 +842,12 @@ test("render_person when emails hidden", ({mock_template}) => {
|
||||||
assert.ok(rendered);
|
assert.ok(rendered);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("render_person", ({mock_template}) => {
|
test("render_person", ({mock_template, override}) => {
|
||||||
// Test render_person with regular person
|
// Test render_person with regular person
|
||||||
a_user.delivery_email = "a_user_delivery@zulip.org";
|
a_user.delivery_email = "a_user_delivery@zulip.org";
|
||||||
realm.custom_profile_field_types = {
|
override(realm, "custom_profile_field_types", {
|
||||||
PRONOUNS: {id: 8, name: "Pronouns"},
|
PRONOUNS: {id: 8, name: "Pronouns"},
|
||||||
};
|
});
|
||||||
let rendered = false;
|
let rendered = false;
|
||||||
mock_template("typeahead_list_item.hbs", false, (args) => {
|
mock_template("typeahead_list_item.hbs", false, (args) => {
|
||||||
assert.equal(args.primary, a_user.full_name);
|
assert.equal(args.primary, a_user.full_name);
|
||||||
|
|
|
@ -370,7 +370,7 @@ run_test("is_user_in_group", () => {
|
||||||
assert.equal(user_groups.is_user_in_group(admins.id, 6), false);
|
assert.equal(user_groups.is_user_in_group(admins.id, 6), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
run_test("get_realm_user_groups_for_dropdown_list_widget", () => {
|
run_test("get_realm_user_groups_for_dropdown_list_widget", ({override}) => {
|
||||||
const nobody = {
|
const nobody = {
|
||||||
name: "role:nobody",
|
name: "role:nobody",
|
||||||
description: "foo",
|
description: "foo",
|
||||||
|
@ -443,7 +443,7 @@ run_test("get_realm_user_groups_for_dropdown_list_widget", () => {
|
||||||
direct_subgroup_ids: new Set([4, 5]),
|
direct_subgroup_ids: new Set([4, 5]),
|
||||||
};
|
};
|
||||||
|
|
||||||
realm.server_supported_permission_settings = {
|
override(realm, "server_supported_permission_settings", {
|
||||||
stream: {
|
stream: {
|
||||||
can_remove_subscribers_group: {
|
can_remove_subscribers_group: {
|
||||||
require_system_group: true,
|
require_system_group: true,
|
||||||
|
@ -478,7 +478,7 @@ run_test("get_realm_user_groups_for_dropdown_list_widget", () => {
|
||||||
allowed_system_groups: ["role:everyone", "role:members"],
|
allowed_system_groups: ["role:everyone", "role:members"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
|
|
||||||
let expected_groups_list = [
|
let expected_groups_list = [
|
||||||
{name: "translated: Admins, moderators, members and guests", unique_id: 6},
|
{name: "translated: Admins, moderators, members and guests", unique_id: 6},
|
||||||
|
|
Loading…
Reference in New Issue