tests: Unmock user_settings.

We previously auto-mocked this out of expediency, but that made it
impossible to test anything that uses the Zod schemata in the same
module.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2024-10-08 23:44:21 -07:00 committed by Tim Abbott
parent 4d74ecccf3
commit 8e49ca163b
47 changed files with 171 additions and 32 deletions

View File

@ -289,7 +289,6 @@ EXEMPT_FILES = make_set(
"web/src/user_groups.ts", "web/src/user_groups.ts",
"web/src/user_pill.ts", "web/src/user_pill.ts",
"web/src/user_profile.ts", "web/src/user_profile.ts",
"web/src/user_settings.ts",
"web/src/user_sort.ts", "web/src/user_sort.ts",
"web/src/user_status.ts", "web/src/user_status.ts",
"web/src/user_status_ui.ts", "web/src/user_status_ui.ts",

View File

@ -13,7 +13,7 @@ const {mock_esm, set_global, with_overrides, zrequire} = require("./lib/namespac
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");
const {current_user, page_params, realm, user_settings} = require("./lib/zpage_params"); const {current_user, page_params, realm} = require("./lib/zpage_params");
const $window_stub = $.create("window-stub"); const $window_stub = $.create("window-stub");
set_global("to_$", () => $window_stub); set_global("to_$", () => $window_stub);
@ -52,6 +52,10 @@ const peer_data = zrequire("peer_data");
const message_lists = zrequire("message_lists"); const message_lists = zrequire("message_lists");
const util = zrequire("util"); const util = zrequire("util");
const {Filter} = zrequire("../src/filter"); const {Filter} = zrequire("../src/filter");
const {initialize_user_settings} = zrequire("user_settings");
const user_settings = {};
initialize_user_settings({user_settings});
const me = { const me = {
email: "me@zulip.com", email: "me@zulip.com",

View File

@ -6,11 +6,14 @@ const {zrequire} = require("./lib/namespace");
const {make_stub} = require("./lib/stub"); const {make_stub} = require("./lib/stub");
const {run_test} = require("./lib/test"); const {run_test} = require("./lib/test");
const blueslip = require("./lib/zblueslip"); const blueslip = require("./lib/zblueslip");
const {user_settings} = require("./lib/zpage_params");
window.location.hash = "#bogus"; window.location.hash = "#bogus";
const browser_history = zrequire("browser_history"); const browser_history = zrequire("browser_history");
const {initialize_user_settings} = zrequire("user_settings");
const user_settings = {};
initialize_user_settings({user_settings});
function test(label, f) { function test(label, f) {
run_test(label, (helpers) => { run_test(label, (helpers) => {

View File

@ -6,7 +6,7 @@ const _ = require("lodash");
const {mock_esm, zrequire} = require("./lib/namespace"); const {mock_esm, zrequire} = require("./lib/namespace");
const {run_test} = require("./lib/test"); const {run_test} = require("./lib/test");
const {current_user, page_params, realm, user_settings} = require("./lib/zpage_params"); const {current_user, page_params, realm} = require("./lib/zpage_params");
mock_esm("../src/settings_data", { mock_esm("../src/settings_data", {
user_can_access_all_other_users: () => true, user_can_access_all_other_users: () => true,
@ -24,6 +24,10 @@ const user_status = zrequire("user_status");
const buddy_data = zrequire("buddy_data"); const buddy_data = zrequire("buddy_data");
const {Filter} = zrequire("filter"); const {Filter} = zrequire("filter");
const message_lists = zrequire("message_lists"); const message_lists = zrequire("message_lists");
const {initialize_user_settings} = zrequire("user_settings");
const user_settings = {};
initialize_user_settings({user_settings});
// The buddy_data module is mostly tested indirectly through // The buddy_data module is mostly tested indirectly through
// activity.test.js, but we should feel free to add direct tests // activity.test.js, but we should feel free to add direct tests

View File

@ -22,6 +22,9 @@ const message_viewport = mock_esm("../src/message_viewport");
const buddy_data = zrequire("buddy_data"); const buddy_data = zrequire("buddy_data");
const {BuddyList} = zrequire("buddy_list"); const {BuddyList} = zrequire("buddy_list");
const people = zrequire("people"); const people = zrequire("people");
const {initialize_user_settings} = zrequire("user_settings");
initialize_user_settings({user_settings: {}});
function init_simulated_scrolling() { function init_simulated_scrolling() {
const elem = { const elem = {

View File

@ -8,7 +8,7 @@ const {mock_banners} = require("./lib/compose_banner");
const {mock_esm, set_global, zrequire} = 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 $ = require("./lib/zjquery"); const $ = require("./lib/zjquery");
const {current_user, page_params, realm, user_settings} = require("./lib/zpage_params"); const {current_user, page_params, realm} = require("./lib/zpage_params");
const user_groups = zrequire("user_groups"); const user_groups = zrequire("user_groups");
@ -59,6 +59,10 @@ const drafts = zrequire("drafts");
const echo = zrequire("echo"); const echo = zrequire("echo");
const people = zrequire("people"); const people = zrequire("people");
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
const {initialize_user_settings} = zrequire("user_settings");
const user_settings = {};
initialize_user_settings({user_settings});
function reset_jquery() { function reset_jquery() {
// Avoid leaks. // Avoid leaks.

View File

@ -27,6 +27,9 @@ const channel = mock_esm("../src/channel");
const compose_reply = zrequire("compose_reply"); const compose_reply = zrequire("compose_reply");
const message_lists = zrequire("message_lists"); const message_lists = zrequire("message_lists");
const text_field_edit = mock_esm("text-field-edit"); const text_field_edit = mock_esm("text-field-edit");
const {initialize_user_settings} = zrequire("user_settings");
initialize_user_settings({user_settings: {}});
const alice = { const alice = {
email: "alice@zulip.com", email: "alice@zulip.com",

View File

@ -6,7 +6,7 @@ const {mock_banners} = require("./lib/compose_banner");
const {mock_esm, set_global, with_overrides, zrequire} = require("./lib/namespace"); const {mock_esm, set_global, with_overrides, zrequire} = require("./lib/namespace");
const {run_test, noop} = require("./lib/test"); const {run_test, noop} = require("./lib/test");
const $ = require("./lib/zjquery"); const $ = require("./lib/zjquery");
const {current_user, realm, user_settings} = require("./lib/zpage_params"); const {current_user, realm} = require("./lib/zpage_params");
let autosize_called; let autosize_called;
@ -57,6 +57,10 @@ const compose_pm_pill = zrequire("compose_pm_pill");
const compose_recipient = zrequire("compose_recipient"); const compose_recipient = zrequire("compose_recipient");
const composebox_typeahead = zrequire("composebox_typeahead"); const composebox_typeahead = zrequire("composebox_typeahead");
const settings_config = zrequire("settings_config"); const settings_config = zrequire("settings_config");
const {initialize_user_settings} = zrequire("user_settings");
const user_settings = {};
initialize_user_settings({user_settings});
const ct = composebox_typeahead; const ct = composebox_typeahead;

View File

@ -13,7 +13,6 @@ const {
page_params, page_params,
realm, realm,
realm_user_settings_defaults, realm_user_settings_defaults,
user_settings,
} = require("./lib/zpage_params"); } = require("./lib/zpage_params");
const event_fixtures = events.fixtures; const event_fixtures = events.fixtures;
@ -103,6 +102,10 @@ const user_group_edit = mock_esm("../src/user_group_edit");
const overlays = mock_esm("../src/overlays"); const overlays = mock_esm("../src/overlays");
mock_esm("../src/giphy"); mock_esm("../src/giphy");
const {Filter} = zrequire("filter"); const {Filter} = zrequire("filter");
const {initialize_user_settings} = zrequire("user_settings");
const user_settings = {};
initialize_user_settings({user_settings});
message_lists.update_recipient_bar_background_color = noop; message_lists.update_recipient_bar_background_color = noop;
message_lists.current = { message_lists.current = {

View File

@ -16,6 +16,9 @@ const compose_state = zrequire("compose_state");
const compose_recipient = zrequire("compose_recipient"); const compose_recipient = zrequire("compose_recipient");
const sub_store = zrequire("sub_store"); const sub_store = zrequire("sub_store");
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
const {initialize_user_settings} = zrequire("user_settings");
initialize_user_settings({user_settings: {}});
const aaron = { const aaron = {
email: "aaron@zulip.com", email: "aaron@zulip.com",

View File

@ -19,11 +19,14 @@ const people = zrequire("people");
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
const stream_topic_history = zrequire("stream_topic_history"); const stream_topic_history = zrequire("stream_topic_history");
const unread = zrequire("unread"); const unread = zrequire("unread");
const {initialize_user_settings} = zrequire("user_settings");
// It's typical to set up a little bit of data at the top of a // It's typical to set up a little bit of data at the top of a
// test module, but you can also do this within tests. Here we // test module, but you can also do this within tests. Here we
// will set up things at the top. // will set up things at the top.
initialize_user_settings({user_settings: {}});
const isaac = make_user({ const isaac = make_user({
email: "isaac@example.com", email: "isaac@example.com",
user_id: 30, user_id: 30,

View File

@ -46,6 +46,9 @@ message_lists.non_rendered_data = () => [];
const message_events = zrequire("message_events"); const message_events = zrequire("message_events");
const message_store = zrequire("message_store"); const message_store = zrequire("message_store");
const people = zrequire("people"); const people = zrequire("people");
const {initialize_user_settings} = zrequire("user_settings");
initialize_user_settings({user_settings: {}});
const isaac = make_user({ const isaac = make_user({
email: "isaac@example.com", email: "isaac@example.com",

View File

@ -17,6 +17,9 @@ const resolved_topic = zrequire("../shared/src/resolved_topic");
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
const people = zrequire("people"); const people = zrequire("people");
const {Filter} = zrequire("../src/filter"); const {Filter} = zrequire("../src/filter");
const {initialize_user_settings} = zrequire("user_settings");
initialize_user_settings({user_settings: {}});
const stream_message = "stream"; const stream_message = "stream";
const direct_message = "private"; const direct_message = "private";

View File

@ -6,7 +6,6 @@ const {mock_esm, set_global, zrequire} = require("./lib/namespace");
const {run_test} = require("./lib/test"); const {run_test} = require("./lib/test");
const blueslip = require("./lib/zblueslip"); const blueslip = require("./lib/zblueslip");
const $ = require("./lib/zjquery"); const $ = require("./lib/zjquery");
const {user_settings} = require("./lib/zpage_params");
let $window_stub; let $window_stub;
set_global("to_$", () => $window_stub); set_global("to_$", () => $window_stub);
@ -37,6 +36,10 @@ const hashchange = zrequire("hashchange");
const message_view = zrequire("../src/message_view"); const message_view = zrequire("../src/message_view");
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
const {Filter} = zrequire("../src/filter"); const {Filter} = zrequire("../src/filter");
const {initialize_user_settings} = zrequire("user_settings");
const user_settings = {};
initialize_user_settings({user_settings});
const devel_id = 100; const devel_id = 100;
const devel = { const devel = {

View File

@ -131,8 +131,6 @@ test.set_verbose(files.length === 1);
require("../../src/page_params"); require("../../src/page_params");
namespace.mock_esm("../../src/state_data", zpage_params); namespace.mock_esm("../../src/state_data", zpage_params);
require("../../src/state_data"); require("../../src/state_data");
namespace.mock_esm("../../src/user_settings", zpage_params);
require("../../src/user_settings");
namespace.mock_esm("../../src/realm_user_settings_defaults", zpage_params); namespace.mock_esm("../../src/realm_user_settings_defaults", zpage_params);
require("../../src/realm_user_settings_defaults"); require("../../src/realm_user_settings_defaults");

View File

@ -4,7 +4,6 @@ exports.current_user = {};
exports.page_params = {}; exports.page_params = {};
exports.realm = {}; exports.realm = {};
exports.realm_user_settings_defaults = {}; exports.realm_user_settings_defaults = {};
exports.user_settings = {};
exports.reset = () => { exports.reset = () => {
for (const field in exports.current_user) { for (const field in exports.current_user) {
@ -22,11 +21,6 @@ exports.reset = () => {
delete exports.realm[field]; delete exports.realm[field];
} }
} }
for (const field in exports.user_settings) {
if (Object.hasOwn(exports.user_settings, field)) {
delete exports.user_settings[field];
}
}
for (const field in exports.realm_user_settings_defaults) { for (const field in exports.realm_user_settings_defaults) {
if (Object.hasOwn(exports.realm_user_settings_defaults, field)) { if (Object.hasOwn(exports.realm_user_settings_defaults, field)) {
delete exports.realm_user_settings_defaults[field]; delete exports.realm_user_settings_defaults[field];

View File

@ -7,7 +7,7 @@ const markdown_test_cases = require("../../zerver/tests/fixtures/markdown_test_c
const markdown_assert = require("./lib/markdown_assert"); const markdown_assert = require("./lib/markdown_assert");
const {mock_esm, set_global, zrequire} = require("./lib/namespace"); const {mock_esm, set_global, zrequire} = require("./lib/namespace");
const {run_test} = require("./lib/test"); const {run_test} = require("./lib/test");
const {page_params, user_settings} = require("./lib/zpage_params"); const {page_params} = require("./lib/zpage_params");
const example_realm_linkifiers = [ const example_realm_linkifiers = [
{ {
@ -55,6 +55,10 @@ const people = zrequire("people");
const pygments_data = zrequire("pygments_data"); const pygments_data = zrequire("pygments_data");
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
const user_groups = zrequire("user_groups"); const user_groups = zrequire("user_groups");
const {initialize_user_settings} = zrequire("user_settings");
const user_settings = {};
initialize_user_settings({user_settings});
const emoji_params = { const emoji_params = {
realm_emoji: { realm_emoji: {

View File

@ -28,6 +28,9 @@ const message_helper = zrequire("message_helper");
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
const stream_topic_history = zrequire("stream_topic_history"); const stream_topic_history = zrequire("stream_topic_history");
const unread = zrequire("unread"); const unread = zrequire("unread");
const {initialize_user_settings} = zrequire("user_settings");
initialize_user_settings({user_settings: {}});
const alice = { const alice = {
email: "alice@example.com", email: "alice@example.com",

View File

@ -22,6 +22,9 @@ mock_esm("../src/left_sidebar_navigation_area", {
const message_flags = zrequire("message_flags"); const message_flags = zrequire("message_flags");
const starred_messages_ui = zrequire("starred_messages_ui"); const starred_messages_ui = zrequire("starred_messages_ui");
const {initialize_user_settings} = zrequire("user_settings");
initialize_user_settings({user_settings: {}});
run_test("starred", ({override}) => { run_test("starred", ({override}) => {
const message = { const message = {

View File

@ -30,6 +30,9 @@ const pm_conversations = zrequire("pm_conversations");
const message_helper = zrequire("message_helper"); const message_helper = zrequire("message_helper");
const message_store = zrequire("message_store"); const message_store = zrequire("message_store");
const message_user_ids = zrequire("message_user_ids"); const message_user_ids = zrequire("message_user_ids");
const {initialize_user_settings} = zrequire("user_settings");
initialize_user_settings({user_settings: {}});
const denmark = { const denmark = {
subscribed: false, subscribed: false,

View File

@ -20,6 +20,9 @@ const recent_view_util = zrequire("recent_view_util");
const inbox_util = zrequire("inbox_util"); const inbox_util = zrequire("inbox_util");
const message_lists = zrequire("message_lists"); const message_lists = zrequire("message_lists");
const user_groups = zrequire("user_groups"); const user_groups = zrequire("user_groups");
const {initialize_user_settings} = zrequire("user_settings");
initialize_user_settings({user_settings: {}});
mock_esm("../src/compose_banner", { mock_esm("../src/compose_banner", {
clear_errors() {}, clear_errors() {},

View File

@ -6,6 +6,9 @@ const {zrequire} = require("./lib/namespace");
const {run_test} = require("./lib/test"); const {run_test} = require("./lib/test");
const muted_users = zrequire("muted_users"); const muted_users = zrequire("muted_users");
const {initialize_user_settings} = zrequire("user_settings");
initialize_user_settings({user_settings: {}});
function test(label, f) { function test(label, f) {
run_test(label, ({override}) => { run_test(label, ({override}) => {

View File

@ -5,7 +5,7 @@ const assert = require("node:assert/strict");
const {mock_esm, zrequire} = require("./lib/namespace"); const {mock_esm, zrequire} = require("./lib/namespace");
const {run_test} = require("./lib/test"); const {run_test} = require("./lib/test");
const $ = require("./lib/zjquery"); const $ = require("./lib/zjquery");
const {current_user, page_params, user_settings} = require("./lib/zpage_params"); const {current_user, page_params} = require("./lib/zpage_params");
mock_esm("../src/electron_bridge"); mock_esm("../src/electron_bridge");
mock_esm("../src/spoilers", {hide_spoilers_in_notification() {}}); mock_esm("../src/spoilers", {hide_spoilers_in_notification() {}});
@ -15,6 +15,10 @@ const stream_data = zrequire("stream_data");
const desktop_notifications = zrequire("desktop_notifications"); const desktop_notifications = zrequire("desktop_notifications");
const message_notifications = zrequire("message_notifications"); const message_notifications = zrequire("message_notifications");
const {initialize_user_settings} = zrequire("user_settings");
const user_settings = {};
initialize_user_settings({user_settings});
// Not muted streams // Not muted streams
const general = { const general = {

View File

@ -10,7 +10,7 @@ const {$t} = require("./lib/i18n");
const {mock_esm, zrequire} = require("./lib/namespace"); const {mock_esm, zrequire} = require("./lib/namespace");
const {run_test} = require("./lib/test"); const {run_test} = require("./lib/test");
const blueslip = require("./lib/zblueslip"); const blueslip = require("./lib/zblueslip");
const {current_user, page_params, realm, user_settings} = require("./lib/zpage_params"); const {current_user, page_params, realm} = require("./lib/zpage_params");
const message_user_ids = mock_esm("../src/message_user_ids"); const message_user_ids = mock_esm("../src/message_user_ids");
const settings_data = mock_esm("../src/settings_data", { const settings_data = mock_esm("../src/settings_data", {
@ -20,6 +20,10 @@ const settings_data = mock_esm("../src/settings_data", {
const muted_users = zrequire("muted_users"); const muted_users = zrequire("muted_users");
const people = zrequire("people"); const people = zrequire("people");
const user_groups = zrequire("user_groups"); const user_groups = zrequire("user_groups");
const {initialize_user_settings} = zrequire("user_settings");
const user_settings = {};
initialize_user_settings({user_settings});
const welcome_bot = { const welcome_bot = {
email: "welcome-bot@example.com", email: "welcome-bot@example.com",

View File

@ -23,6 +23,9 @@ const people = zrequire("people");
const pm_conversations = zrequire("pm_conversations"); const pm_conversations = zrequire("pm_conversations");
const pm_list_data = zrequire("pm_list_data"); const pm_list_data = zrequire("pm_list_data");
const message_lists = zrequire("message_lists"); const message_lists = zrequire("message_lists");
const {initialize_user_settings} = zrequire("user_settings");
initialize_user_settings({user_settings: {}});
const alice = { const alice = {
email: "alice@zulip.com", email: "alice@zulip.com",

View File

@ -4,11 +4,14 @@ const assert = require("node:assert/strict");
const {mock_esm, zrequire} = require("./lib/namespace"); const {mock_esm, zrequire} = require("./lib/namespace");
const {run_test} = require("./lib/test"); const {run_test} = require("./lib/test");
const {user_settings} = require("./lib/zpage_params");
const thumbnail = mock_esm("../src/thumbnail"); const thumbnail = mock_esm("../src/thumbnail");
const {postprocess_content} = zrequire("postprocess_content"); const {postprocess_content} = zrequire("postprocess_content");
const {initialize_user_settings} = zrequire("user_settings");
const user_settings = {};
initialize_user_settings({user_settings});
run_test("postprocess_content", () => { run_test("postprocess_content", () => {
assert.equal( assert.equal(

View File

@ -4,7 +4,7 @@ const assert = require("node:assert/strict");
const {mock_esm, zrequire} = require("./lib/namespace"); const {mock_esm, zrequire} = require("./lib/namespace");
const {run_test} = require("./lib/test"); const {run_test} = require("./lib/test");
const {realm, user_settings} = require("./lib/zpage_params"); const {realm} = require("./lib/zpage_params");
mock_esm("../src/settings_data", { mock_esm("../src/settings_data", {
user_can_access_all_other_users: () => true, user_can_access_all_other_users: () => true,
@ -12,6 +12,10 @@ mock_esm("../src/settings_data", {
const people = zrequire("people"); const people = zrequire("people");
const presence = zrequire("presence"); const presence = zrequire("presence");
const {initialize_user_settings} = zrequire("user_settings");
const user_settings = {};
initialize_user_settings({user_settings});
const OFFLINE_THRESHOLD_SECS = 200; const OFFLINE_THRESHOLD_SECS = 200;

View File

@ -7,7 +7,7 @@ const {make_stub} = require("./lib/stub");
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");
const {current_user, page_params, user_settings} = require("./lib/zpage_params"); const {current_user, page_params} = require("./lib/zpage_params");
const alice_user_id = 5; const alice_user_id = 5;
@ -59,6 +59,10 @@ const emoji = zrequire("emoji");
const emoji_codes = zrequire("../../static/generated/emoji/emoji_codes.json"); const emoji_codes = zrequire("../../static/generated/emoji/emoji_codes.json");
const people = zrequire("people"); const people = zrequire("people");
const reactions = zrequire("reactions"); const reactions = zrequire("reactions");
const {initialize_user_settings} = zrequire("user_settings");
const user_settings = {};
initialize_user_settings({user_settings});
const emoji_params = { const emoji_params = {
realm_emoji: { realm_emoji: {

View File

@ -7,7 +7,7 @@ const {mock_cjs, mock_esm, 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");
const {realm, user_settings} = require("./lib/zpage_params"); const {realm} = require("./lib/zpage_params");
let clipboard_args; let clipboard_args;
class Clipboard { class Clipboard {
@ -33,6 +33,10 @@ const message_store = mock_esm("../src/message_store");
mock_esm("../src/settings_data", { mock_esm("../src/settings_data", {
user_can_access_all_other_users: () => false, user_can_access_all_other_users: () => false,
}); });
const {initialize_user_settings} = zrequire("user_settings");
const user_settings = {};
initialize_user_settings({user_settings});
const iago = { const iago = {
email: "iago@zulip.com", email: "iago@zulip.com",

View File

@ -7,6 +7,9 @@ const {run_test} = require("./lib/test");
const scheduled_messages = zrequire("scheduled_messages"); const scheduled_messages = zrequire("scheduled_messages");
const compose_send_menu_popover = zrequire("compose_send_menu_popover"); const compose_send_menu_popover = zrequire("compose_send_menu_popover");
const {initialize_user_settings} = zrequire("user_settings");
initialize_user_settings({user_settings: {}});
const per_day_stamps = { const per_day_stamps = {
"2023-04-30": { "2023-04-30": {

View File

@ -4,9 +4,12 @@ const assert = require("node:assert/strict");
const {zrequire} = require("./lib/namespace"); const {zrequire} = require("./lib/namespace");
const {run_test} = require("./lib/test"); const {run_test} = require("./lib/test");
const {user_settings} = require("./lib/zpage_params");
const settings_config = zrequire("settings_config"); const settings_config = zrequire("settings_config");
const {initialize_user_settings} = zrequire("user_settings");
const user_settings = {};
initialize_user_settings({user_settings});
run_test("all_notifications", ({override}) => { run_test("all_notifications", ({override}) => {
override(user_settings, "enable_stream_desktop_notifications", false); override(user_settings, "enable_stream_desktop_notifications", false);

View File

@ -4,11 +4,15 @@ const assert = require("node:assert/strict");
const {mock_esm, zrequire} = require("./lib/namespace"); const {mock_esm, zrequire} = require("./lib/namespace");
const {run_test} = require("./lib/test"); const {run_test} = require("./lib/test");
const {current_user, page_params, realm, user_settings} = require("./lib/zpage_params"); const {current_user, page_params, realm} = require("./lib/zpage_params");
const settings_data = zrequire("settings_data"); const settings_data = zrequire("settings_data");
const settings_config = zrequire("settings_config"); const settings_config = zrequire("settings_config");
const user_groups = zrequire("user_groups"); const user_groups = zrequire("user_groups");
const {initialize_user_settings} = zrequire("user_settings");
const user_settings = {};
initialize_user_settings({user_settings});
/* /*
Some methods in settings_data are fairly Some methods in settings_data are fairly

View File

@ -17,6 +17,9 @@ mock_esm("../src/settings_data", {
const settings_muted_users = zrequire("settings_muted_users"); const settings_muted_users = zrequire("settings_muted_users");
const muted_users = zrequire("muted_users"); const muted_users = zrequire("muted_users");
const people = zrequire("people"); const people = zrequire("people");
const {initialize_user_settings} = zrequire("user_settings");
initialize_user_settings({user_settings: {}});
run_test("settings", ({override}) => { run_test("settings", ({override}) => {
people.add_active_user({user_id: 5, email: "five@zulip.com", full_name: "Feivel Fiverson"}); people.add_active_user({user_id: 5, email: "five@zulip.com", full_name: "Feivel Fiverson"});

View File

@ -26,6 +26,9 @@ const settings_bots = zrequire("settings_bots");
const settings_account = zrequire("settings_account"); const settings_account = zrequire("settings_account");
const settings_components = zrequire("settings_components"); const settings_components = zrequire("settings_components");
const settings_org = zrequire("settings_org"); const settings_org = zrequire("settings_org");
const {initialize_user_settings} = zrequire("user_settings");
initialize_user_settings({user_settings: {}});
function test(label, f) { function test(label, f) {
run_test(label, (helpers) => { run_test(label, (helpers) => {

View File

@ -13,6 +13,9 @@ const list_widget = mock_esm("../src/list_widget", {
const settings_user_topics = zrequire("settings_user_topics"); const settings_user_topics = zrequire("settings_user_topics");
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
const user_topics = zrequire("user_topics"); const user_topics = zrequire("user_topics");
const {initialize_user_settings} = zrequire("user_settings");
initialize_user_settings({user_settings: {}});
const frontend = { const frontend = {
stream_id: 101, stream_id: 101,

View File

@ -5,7 +5,6 @@ const assert = require("node:assert/strict");
const {mock_esm, with_overrides, zrequire} = require("./lib/namespace"); const {mock_esm, with_overrides, zrequire} = require("./lib/namespace");
const {make_stub} = require("./lib/stub"); const {make_stub} = require("./lib/stub");
const {run_test} = require("./lib/test"); const {run_test} = require("./lib/test");
const {user_settings} = require("./lib/zpage_params");
const left_sidebar_navigation_area = mock_esm("../src/left_sidebar_navigation_area", { const left_sidebar_navigation_area = mock_esm("../src/left_sidebar_navigation_area", {
update_starred_count() {}, update_starred_count() {},
@ -13,6 +12,10 @@ const left_sidebar_navigation_area = mock_esm("../src/left_sidebar_navigation_ar
const message_store = zrequire("message_store"); const message_store = zrequire("message_store");
const starred_messages = zrequire("starred_messages"); const starred_messages = zrequire("starred_messages");
const starred_messages_ui = zrequire("starred_messages_ui"); const starred_messages_ui = zrequire("starred_messages_ui");
const {initialize_user_settings} = zrequire("user_settings");
const user_settings = {};
initialize_user_settings({user_settings});
run_test("add starred", () => { run_test("add starred", () => {
starred_messages.starred_ids.clear(); starred_messages.starred_ids.clear();

View File

@ -5,7 +5,7 @@ const assert = require("node:assert/strict");
const {mock_esm, zrequire} = require("./lib/namespace"); const {mock_esm, zrequire} = require("./lib/namespace");
const {run_test} = require("./lib/test"); const {run_test} = require("./lib/test");
const blueslip = require("./lib/zblueslip"); const blueslip = require("./lib/zblueslip");
const {current_user, page_params, realm, user_settings} = require("./lib/zpage_params"); const {current_user, page_params, realm} = require("./lib/zpage_params");
// TODO: Remove after we enable support for // TODO: Remove after we enable support for
// web_public_streams in production. // web_public_streams in production.
@ -20,6 +20,10 @@ const stream_data = zrequire("stream_data");
const hash_util = zrequire("hash_util"); const hash_util = zrequire("hash_util");
const stream_settings_data = zrequire("stream_settings_data"); const stream_settings_data = zrequire("stream_settings_data");
const user_groups = zrequire("user_groups"); const user_groups = zrequire("user_groups");
const {initialize_user_settings} = zrequire("user_settings");
const user_settings = {};
initialize_user_settings({user_settings});
mock_esm("../src/group_permission_settings", { mock_esm("../src/group_permission_settings", {
get_group_permission_setting_config() { get_group_permission_setting_config() {

View File

@ -5,7 +5,7 @@ const assert = require("node:assert/strict");
const {mock_esm, set_global, zrequire} = 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 $ = require("./lib/zjquery"); const $ = require("./lib/zjquery");
const {current_user, page_params, user_settings} = require("./lib/zpage_params"); const {current_user, page_params} = require("./lib/zpage_params");
set_global("document", "document-stub"); set_global("document", "document-stub");
@ -35,6 +35,10 @@ const {Filter} = zrequire("../src/filter");
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
const stream_list = zrequire("stream_list"); const stream_list = zrequire("stream_list");
const stream_list_sort = zrequire("stream_list_sort"); const stream_list_sort = zrequire("stream_list_sort");
const {initialize_user_settings} = zrequire("user_settings");
const user_settings = {};
initialize_user_settings({user_settings});
const devel = { const devel = {
name: "devel", name: "devel",

View File

@ -6,13 +6,16 @@ const _ = require("lodash");
const {zrequire} = require("./lib/namespace"); const {zrequire} = require("./lib/namespace");
const {run_test} = require("./lib/test"); const {run_test} = require("./lib/test");
const {user_settings} = require("./lib/zpage_params");
const people = zrequire("people"); const people = zrequire("people");
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
const stream_topic_history = zrequire("stream_topic_history"); const stream_topic_history = zrequire("stream_topic_history");
const stream_list_sort = zrequire("stream_list_sort"); const stream_list_sort = zrequire("stream_list_sort");
const settings_config = zrequire("settings_config"); const settings_config = zrequire("settings_config");
const {initialize_user_settings} = zrequire("user_settings");
const user_settings = {};
initialize_user_settings({user_settings});
function contains_sub(subs, sub) { function contains_sub(subs, sub) {
return subs.some((s) => s.name === sub.name); return subs.some((s) => s.name === sub.name);

View File

@ -28,6 +28,9 @@ set_global("page_params", {});
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
const stream_settings_ui = zrequire("stream_settings_ui"); const stream_settings_ui = zrequire("stream_settings_ui");
const user_groups = zrequire("user_groups"); const user_groups = zrequire("user_groups");
const {initialize_user_settings} = zrequire("user_settings");
initialize_user_settings({user_settings: {}});
run_test("redraw_left_panel", ({mock_template}) => { run_test("redraw_left_panel", ({mock_template}) => {
const admins_group = { const admins_group = {

View File

@ -9,7 +9,11 @@ const {$t} = require("./lib/i18n");
const {zrequire} = require("./lib/namespace"); const {zrequire} = require("./lib/namespace");
const {run_test} = require("./lib/test"); const {run_test} = require("./lib/test");
const $ = require("./lib/zjquery"); const $ = require("./lib/zjquery");
const {user_settings} = require("./lib/zpage_params");
const {initialize_user_settings} = zrequire("user_settings");
const user_settings = {};
initialize_user_settings({user_settings});
const timerender = zrequire("timerender"); const timerender = zrequire("timerender");

View File

@ -4,7 +4,7 @@ const assert = require("node:assert/strict");
const {mock_esm, zrequire} = require("./lib/namespace"); const {mock_esm, zrequire} = require("./lib/namespace");
const {run_test} = require("./lib/test"); const {run_test} = require("./lib/test");
const {current_user, realm, user_settings} = require("./lib/zpage_params"); const {current_user, realm} = require("./lib/zpage_params");
const stream_topic_history = mock_esm("../src/stream_topic_history"); const stream_topic_history = mock_esm("../src/stream_topic_history");
@ -23,6 +23,10 @@ const util = zrequire("util");
const ct = zrequire("composebox_typeahead"); const ct = zrequire("composebox_typeahead");
const th = zrequire("typeahead_helper"); const th = zrequire("typeahead_helper");
const user_groups = zrequire("user_groups"); const user_groups = zrequire("user_groups");
const {initialize_user_settings} = zrequire("user_settings");
const user_settings = {};
initialize_user_settings({user_settings});
let next_id = 0; let next_id = 0;

View File

@ -11,6 +11,9 @@ const stream_data = mock_esm("../src/stream_data");
const typing = zrequire("typing"); const typing = zrequire("typing");
const typing_status = zrequire("../shared/src/typing_status"); const typing_status = zrequire("../shared/src/typing_status");
const {initialize_user_settings} = zrequire("user_settings");
initialize_user_settings({user_settings: {}});
const TYPING_STARTED_WAIT_PERIOD = 10000; const TYPING_STARTED_WAIT_PERIOD = 10000;
const TYPING_STOPPED_WAIT_PERIOD = 5000; const TYPING_STOPPED_WAIT_PERIOD = 5000;

View File

@ -6,7 +6,7 @@ const _ = require("lodash");
const {set_global, with_overrides, zrequire} = require("./lib/namespace"); const {set_global, with_overrides, zrequire} = require("./lib/namespace");
const {run_test} = require("./lib/test"); const {run_test} = require("./lib/test");
const {realm, user_settings} = require("./lib/zpage_params"); const {realm} = require("./lib/zpage_params");
realm.realm_push_notifications_enabled = false; realm.realm_push_notifications_enabled = false;
@ -18,6 +18,10 @@ const people = zrequire("people");
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
const sub_store = zrequire("sub_store"); const sub_store = zrequire("sub_store");
const unread = zrequire("unread"); const unread = zrequire("unread");
const {initialize_user_settings} = zrequire("user_settings");
const user_settings = {};
initialize_user_settings({user_settings});
const me = { const me = {
email: "me@example.com", email: "me@example.com",

View File

@ -10,6 +10,9 @@ const channel = mock_esm("../src/channel");
const user_status = zrequire("user_status"); const user_status = zrequire("user_status");
const emoji_codes = zrequire("../../static/generated/emoji/emoji_codes.json"); const emoji_codes = zrequire("../../static/generated/emoji/emoji_codes.json");
const emoji = zrequire("emoji"); const emoji = zrequire("emoji");
const {initialize_user_settings} = zrequire("user_settings");
initialize_user_settings({user_settings: {}});
const emoji_params = { const emoji_params = {
realm_emoji: { realm_emoji: {

View File

@ -10,6 +10,9 @@ const blueslip = require("./lib/zblueslip");
const user_topics = zrequire("user_topics"); const user_topics = zrequire("user_topics");
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
const {initialize_user_settings} = zrequire("user_settings");
initialize_user_settings({user_settings: {}});
const design = { const design = {
stream_id: 100, stream_id: 100,

View File

@ -9,10 +9,13 @@ const {set_global, zrequire} = require("./lib/namespace");
const {run_test} = require("./lib/test"); const {run_test} = require("./lib/test");
const blueslip = zrequire("blueslip"); const blueslip = zrequire("blueslip");
const {initialize_user_settings} = zrequire("user_settings");
set_global("document", {}); set_global("document", {});
const util = zrequire("util"); const util = zrequire("util");
initialize_user_settings({user_settings: {}});
run_test("CachedValue", () => { run_test("CachedValue", () => {
let x = 5; let x = 5;