diff --git a/tools/test-js-with-node b/tools/test-js-with-node index 639e852353..ce2ea53709 100755 --- a/tools/test-js-with-node +++ b/tools/test-js-with-node @@ -289,7 +289,6 @@ EXEMPT_FILES = make_set( "web/src/user_groups.ts", "web/src/user_pill.ts", "web/src/user_profile.ts", - "web/src/user_settings.ts", "web/src/user_sort.ts", "web/src/user_status.ts", "web/src/user_status_ui.ts", diff --git a/web/tests/activity.test.js b/web/tests/activity.test.js index 050361cda3..8555b3208d 100644 --- a/web/tests/activity.test.js +++ b/web/tests/activity.test.js @@ -13,7 +13,7 @@ const {mock_esm, set_global, with_overrides, zrequire} = require("./lib/namespac const {run_test, noop} = require("./lib/test"); const blueslip = require("./lib/zblueslip"); 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"); set_global("to_$", () => $window_stub); @@ -52,6 +52,10 @@ const peer_data = zrequire("peer_data"); const message_lists = zrequire("message_lists"); const util = zrequire("util"); const {Filter} = zrequire("../src/filter"); +const {initialize_user_settings} = zrequire("user_settings"); + +const user_settings = {}; +initialize_user_settings({user_settings}); const me = { email: "me@zulip.com", diff --git a/web/tests/browser_history.test.js b/web/tests/browser_history.test.js index 09a9165a2a..56a9ec075d 100644 --- a/web/tests/browser_history.test.js +++ b/web/tests/browser_history.test.js @@ -6,11 +6,14 @@ const {zrequire} = require("./lib/namespace"); const {make_stub} = require("./lib/stub"); const {run_test} = require("./lib/test"); const blueslip = require("./lib/zblueslip"); -const {user_settings} = require("./lib/zpage_params"); window.location.hash = "#bogus"; 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) { run_test(label, (helpers) => { diff --git a/web/tests/buddy_data.test.js b/web/tests/buddy_data.test.js index 651d2edcb7..075ae51757 100644 --- a/web/tests/buddy_data.test.js +++ b/web/tests/buddy_data.test.js @@ -6,7 +6,7 @@ const _ = require("lodash"); const {mock_esm, zrequire} = require("./lib/namespace"); 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", { user_can_access_all_other_users: () => true, @@ -24,6 +24,10 @@ const user_status = zrequire("user_status"); const buddy_data = zrequire("buddy_data"); const {Filter} = zrequire("filter"); 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 // activity.test.js, but we should feel free to add direct tests diff --git a/web/tests/buddy_list.test.js b/web/tests/buddy_list.test.js index 453a0aceda..338e73a525 100644 --- a/web/tests/buddy_list.test.js +++ b/web/tests/buddy_list.test.js @@ -22,6 +22,9 @@ const message_viewport = mock_esm("../src/message_viewport"); const buddy_data = zrequire("buddy_data"); const {BuddyList} = zrequire("buddy_list"); const people = zrequire("people"); +const {initialize_user_settings} = zrequire("user_settings"); + +initialize_user_settings({user_settings: {}}); function init_simulated_scrolling() { const elem = { diff --git a/web/tests/compose.test.js b/web/tests/compose.test.js index 5c1c599e89..efe799319c 100644 --- a/web/tests/compose.test.js +++ b/web/tests/compose.test.js @@ -8,7 +8,7 @@ const {mock_banners} = require("./lib/compose_banner"); const {mock_esm, set_global, zrequire} = require("./lib/namespace"); const {run_test, noop} = require("./lib/test"); 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"); @@ -59,6 +59,10 @@ const drafts = zrequire("drafts"); const echo = zrequire("echo"); const people = zrequire("people"); const stream_data = zrequire("stream_data"); +const {initialize_user_settings} = zrequire("user_settings"); + +const user_settings = {}; +initialize_user_settings({user_settings}); function reset_jquery() { // Avoid leaks. diff --git a/web/tests/compose_ui.test.js b/web/tests/compose_ui.test.js index d354022746..f3682025fe 100644 --- a/web/tests/compose_ui.test.js +++ b/web/tests/compose_ui.test.js @@ -27,6 +27,9 @@ const channel = mock_esm("../src/channel"); const compose_reply = zrequire("compose_reply"); const message_lists = zrequire("message_lists"); const text_field_edit = mock_esm("text-field-edit"); +const {initialize_user_settings} = zrequire("user_settings"); + +initialize_user_settings({user_settings: {}}); const alice = { email: "alice@zulip.com", diff --git a/web/tests/composebox_typeahead.test.js b/web/tests/composebox_typeahead.test.js index 8a23bbcdf7..d2ffde4564 100644 --- a/web/tests/composebox_typeahead.test.js +++ b/web/tests/composebox_typeahead.test.js @@ -6,7 +6,7 @@ const {mock_banners} = require("./lib/compose_banner"); const {mock_esm, set_global, with_overrides, zrequire} = require("./lib/namespace"); const {run_test, noop} = require("./lib/test"); 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; @@ -57,6 +57,10 @@ const compose_pm_pill = zrequire("compose_pm_pill"); const compose_recipient = zrequire("compose_recipient"); const composebox_typeahead = zrequire("composebox_typeahead"); 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; diff --git a/web/tests/dispatch.test.js b/web/tests/dispatch.test.js index 5c6006d509..e0998e187b 100644 --- a/web/tests/dispatch.test.js +++ b/web/tests/dispatch.test.js @@ -13,7 +13,6 @@ const { page_params, realm, realm_user_settings_defaults, - user_settings, } = require("./lib/zpage_params"); 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"); mock_esm("../src/giphy"); 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.current = { diff --git a/web/tests/drafts.test.js b/web/tests/drafts.test.js index 48f8078f7d..66d6568bb7 100644 --- a/web/tests/drafts.test.js +++ b/web/tests/drafts.test.js @@ -16,6 +16,9 @@ const compose_state = zrequire("compose_state"); const compose_recipient = zrequire("compose_recipient"); const sub_store = zrequire("sub_store"); const stream_data = zrequire("stream_data"); +const {initialize_user_settings} = zrequire("user_settings"); + +initialize_user_settings({user_settings: {}}); const aaron = { email: "aaron@zulip.com", diff --git a/web/tests/example2.test.js b/web/tests/example2.test.js index 2b17287fe3..ad7c0ddd5c 100644 --- a/web/tests/example2.test.js +++ b/web/tests/example2.test.js @@ -19,11 +19,14 @@ const people = zrequire("people"); const stream_data = zrequire("stream_data"); const stream_topic_history = zrequire("stream_topic_history"); 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 // test module, but you can also do this within tests. Here we // will set up things at the top. +initialize_user_settings({user_settings: {}}); + const isaac = make_user({ email: "isaac@example.com", user_id: 30, diff --git a/web/tests/example5.test.js b/web/tests/example5.test.js index b2902a6223..5a2445a7c5 100644 --- a/web/tests/example5.test.js +++ b/web/tests/example5.test.js @@ -46,6 +46,9 @@ message_lists.non_rendered_data = () => []; const message_events = zrequire("message_events"); const message_store = zrequire("message_store"); const people = zrequire("people"); +const {initialize_user_settings} = zrequire("user_settings"); + +initialize_user_settings({user_settings: {}}); const isaac = make_user({ email: "isaac@example.com", diff --git a/web/tests/filter.test.js b/web/tests/filter.test.js index 396f1632cd..7ee8d6433f 100644 --- a/web/tests/filter.test.js +++ b/web/tests/filter.test.js @@ -17,6 +17,9 @@ const resolved_topic = zrequire("../shared/src/resolved_topic"); const stream_data = zrequire("stream_data"); const people = zrequire("people"); const {Filter} = zrequire("../src/filter"); +const {initialize_user_settings} = zrequire("user_settings"); + +initialize_user_settings({user_settings: {}}); const stream_message = "stream"; const direct_message = "private"; diff --git a/web/tests/hashchange.test.js b/web/tests/hashchange.test.js index dbd80c4e48..f823768cdf 100644 --- a/web/tests/hashchange.test.js +++ b/web/tests/hashchange.test.js @@ -6,7 +6,6 @@ const {mock_esm, set_global, zrequire} = require("./lib/namespace"); const {run_test} = require("./lib/test"); const blueslip = require("./lib/zblueslip"); const $ = require("./lib/zjquery"); -const {user_settings} = require("./lib/zpage_params"); let $window_stub; set_global("to_$", () => $window_stub); @@ -37,6 +36,10 @@ const hashchange = zrequire("hashchange"); const message_view = zrequire("../src/message_view"); const stream_data = zrequire("stream_data"); 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 = { diff --git a/web/tests/lib/index.js b/web/tests/lib/index.js index 6e96c379d9..102a320226 100644 --- a/web/tests/lib/index.js +++ b/web/tests/lib/index.js @@ -131,8 +131,6 @@ test.set_verbose(files.length === 1); require("../../src/page_params"); namespace.mock_esm("../../src/state_data", zpage_params); 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); require("../../src/realm_user_settings_defaults"); diff --git a/web/tests/lib/zpage_params.js b/web/tests/lib/zpage_params.js index e77e9dd499..359ff5c976 100644 --- a/web/tests/lib/zpage_params.js +++ b/web/tests/lib/zpage_params.js @@ -4,7 +4,6 @@ exports.current_user = {}; exports.page_params = {}; exports.realm = {}; exports.realm_user_settings_defaults = {}; -exports.user_settings = {}; exports.reset = () => { for (const field in exports.current_user) { @@ -22,11 +21,6 @@ exports.reset = () => { 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) { if (Object.hasOwn(exports.realm_user_settings_defaults, field)) { delete exports.realm_user_settings_defaults[field]; diff --git a/web/tests/markdown.test.js b/web/tests/markdown.test.js index 553c388ba7..3a0ee0bd0d 100644 --- a/web/tests/markdown.test.js +++ b/web/tests/markdown.test.js @@ -7,7 +7,7 @@ const markdown_test_cases = require("../../zerver/tests/fixtures/markdown_test_c const markdown_assert = require("./lib/markdown_assert"); const {mock_esm, set_global, zrequire} = require("./lib/namespace"); 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 = [ { @@ -55,6 +55,10 @@ const people = zrequire("people"); const pygments_data = zrequire("pygments_data"); const stream_data = zrequire("stream_data"); const user_groups = zrequire("user_groups"); +const {initialize_user_settings} = zrequire("user_settings"); + +const user_settings = {}; +initialize_user_settings({user_settings}); const emoji_params = { realm_emoji: { diff --git a/web/tests/message_events.test.js b/web/tests/message_events.test.js index ee4b2c5314..c942c1a39b 100644 --- a/web/tests/message_events.test.js +++ b/web/tests/message_events.test.js @@ -28,6 +28,9 @@ const message_helper = zrequire("message_helper"); const stream_data = zrequire("stream_data"); const stream_topic_history = zrequire("stream_topic_history"); const unread = zrequire("unread"); +const {initialize_user_settings} = zrequire("user_settings"); + +initialize_user_settings({user_settings: {}}); const alice = { email: "alice@example.com", diff --git a/web/tests/message_flags.test.js b/web/tests/message_flags.test.js index 627ec5701a..f49dd1e12c 100644 --- a/web/tests/message_flags.test.js +++ b/web/tests/message_flags.test.js @@ -22,6 +22,9 @@ mock_esm("../src/left_sidebar_navigation_area", { const message_flags = zrequire("message_flags"); const starred_messages_ui = zrequire("starred_messages_ui"); +const {initialize_user_settings} = zrequire("user_settings"); + +initialize_user_settings({user_settings: {}}); run_test("starred", ({override}) => { const message = { diff --git a/web/tests/message_store.test.js b/web/tests/message_store.test.js index ef9e7bb87f..8fe5564f54 100644 --- a/web/tests/message_store.test.js +++ b/web/tests/message_store.test.js @@ -30,6 +30,9 @@ const pm_conversations = zrequire("pm_conversations"); const message_helper = zrequire("message_helper"); const message_store = zrequire("message_store"); const message_user_ids = zrequire("message_user_ids"); +const {initialize_user_settings} = zrequire("user_settings"); + +initialize_user_settings({user_settings: {}}); const denmark = { subscribed: false, diff --git a/web/tests/message_view.test.js b/web/tests/message_view.test.js index aa313b01dd..70c87cafc0 100644 --- a/web/tests/message_view.test.js +++ b/web/tests/message_view.test.js @@ -20,6 +20,9 @@ const recent_view_util = zrequire("recent_view_util"); const inbox_util = zrequire("inbox_util"); const message_lists = zrequire("message_lists"); const user_groups = zrequire("user_groups"); +const {initialize_user_settings} = zrequire("user_settings"); + +initialize_user_settings({user_settings: {}}); mock_esm("../src/compose_banner", { clear_errors() {}, diff --git a/web/tests/muted_users.test.js b/web/tests/muted_users.test.js index ab90452ee9..6c31abb4c3 100644 --- a/web/tests/muted_users.test.js +++ b/web/tests/muted_users.test.js @@ -6,6 +6,9 @@ const {zrequire} = require("./lib/namespace"); const {run_test} = require("./lib/test"); const muted_users = zrequire("muted_users"); +const {initialize_user_settings} = zrequire("user_settings"); + +initialize_user_settings({user_settings: {}}); function test(label, f) { run_test(label, ({override}) => { diff --git a/web/tests/notifications.test.js b/web/tests/notifications.test.js index 9aa45dc206..dc806b1473 100644 --- a/web/tests/notifications.test.js +++ b/web/tests/notifications.test.js @@ -5,7 +5,7 @@ const assert = require("node:assert/strict"); const {mock_esm, zrequire} = require("./lib/namespace"); const {run_test} = require("./lib/test"); 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/spoilers", {hide_spoilers_in_notification() {}}); @@ -15,6 +15,10 @@ const stream_data = zrequire("stream_data"); const desktop_notifications = zrequire("desktop_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 const general = { diff --git a/web/tests/people.test.js b/web/tests/people.test.js index 28d3a84bac..838fd8c265 100644 --- a/web/tests/people.test.js +++ b/web/tests/people.test.js @@ -10,7 +10,7 @@ const {$t} = require("./lib/i18n"); const {mock_esm, zrequire} = require("./lib/namespace"); const {run_test} = require("./lib/test"); 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 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 people = zrequire("people"); const user_groups = zrequire("user_groups"); +const {initialize_user_settings} = zrequire("user_settings"); + +const user_settings = {}; +initialize_user_settings({user_settings}); const welcome_bot = { email: "welcome-bot@example.com", diff --git a/web/tests/pm_list_data.test.js b/web/tests/pm_list_data.test.js index 451538b48c..db7a6512e5 100644 --- a/web/tests/pm_list_data.test.js +++ b/web/tests/pm_list_data.test.js @@ -23,6 +23,9 @@ const people = zrequire("people"); const pm_conversations = zrequire("pm_conversations"); const pm_list_data = zrequire("pm_list_data"); const message_lists = zrequire("message_lists"); +const {initialize_user_settings} = zrequire("user_settings"); + +initialize_user_settings({user_settings: {}}); const alice = { email: "alice@zulip.com", diff --git a/web/tests/postprocess_content.test.js b/web/tests/postprocess_content.test.js index d6162fa81a..63380eea83 100644 --- a/web/tests/postprocess_content.test.js +++ b/web/tests/postprocess_content.test.js @@ -4,11 +4,14 @@ const assert = require("node:assert/strict"); const {mock_esm, zrequire} = require("./lib/namespace"); const {run_test} = require("./lib/test"); -const {user_settings} = require("./lib/zpage_params"); const thumbnail = mock_esm("../src/thumbnail"); 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", () => { assert.equal( diff --git a/web/tests/presence.test.js b/web/tests/presence.test.js index 9da869c8d5..f6d6eb2ffb 100644 --- a/web/tests/presence.test.js +++ b/web/tests/presence.test.js @@ -4,7 +4,7 @@ const assert = require("node:assert/strict"); const {mock_esm, zrequire} = require("./lib/namespace"); 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", { user_can_access_all_other_users: () => true, @@ -12,6 +12,10 @@ mock_esm("../src/settings_data", { const people = zrequire("people"); const presence = zrequire("presence"); +const {initialize_user_settings} = zrequire("user_settings"); + +const user_settings = {}; +initialize_user_settings({user_settings}); const OFFLINE_THRESHOLD_SECS = 200; diff --git a/web/tests/reactions.test.js b/web/tests/reactions.test.js index 67b141ad6a..6c78f2aabc 100644 --- a/web/tests/reactions.test.js +++ b/web/tests/reactions.test.js @@ -7,7 +7,7 @@ const {make_stub} = require("./lib/stub"); const {run_test, noop} = require("./lib/test"); const blueslip = require("./lib/zblueslip"); 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; @@ -59,6 +59,10 @@ const emoji = zrequire("emoji"); const emoji_codes = zrequire("../../static/generated/emoji/emoji_codes.json"); const people = zrequire("people"); const reactions = zrequire("reactions"); +const {initialize_user_settings} = zrequire("user_settings"); + +const user_settings = {}; +initialize_user_settings({user_settings}); const emoji_params = { realm_emoji: { diff --git a/web/tests/rendered_markdown.test.js b/web/tests/rendered_markdown.test.js index 57af781593..061ed366a1 100644 --- a/web/tests/rendered_markdown.test.js +++ b/web/tests/rendered_markdown.test.js @@ -7,7 +7,7 @@ const {mock_cjs, mock_esm, zrequire} = require("./lib/namespace"); const {run_test, noop} = require("./lib/test"); const blueslip = require("./lib/zblueslip"); const $ = require("./lib/zjquery"); -const {realm, user_settings} = require("./lib/zpage_params"); +const {realm} = require("./lib/zpage_params"); let clipboard_args; class Clipboard { @@ -33,6 +33,10 @@ const message_store = mock_esm("../src/message_store"); mock_esm("../src/settings_data", { user_can_access_all_other_users: () => false, }); +const {initialize_user_settings} = zrequire("user_settings"); + +const user_settings = {}; +initialize_user_settings({user_settings}); const iago = { email: "iago@zulip.com", diff --git a/web/tests/scheduled_messages.test.js b/web/tests/scheduled_messages.test.js index 48e3596443..66418f8198 100644 --- a/web/tests/scheduled_messages.test.js +++ b/web/tests/scheduled_messages.test.js @@ -7,6 +7,9 @@ const {run_test} = require("./lib/test"); const scheduled_messages = zrequire("scheduled_messages"); 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 = { "2023-04-30": { diff --git a/web/tests/settings_config.test.js b/web/tests/settings_config.test.js index d5ea785b5c..5b523a129e 100644 --- a/web/tests/settings_config.test.js +++ b/web/tests/settings_config.test.js @@ -4,9 +4,12 @@ const assert = require("node:assert/strict"); const {zrequire} = require("./lib/namespace"); const {run_test} = require("./lib/test"); -const {user_settings} = require("./lib/zpage_params"); 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}) => { override(user_settings, "enable_stream_desktop_notifications", false); diff --git a/web/tests/settings_data.test.js b/web/tests/settings_data.test.js index 89bc67c085..c8dd09be92 100644 --- a/web/tests/settings_data.test.js +++ b/web/tests/settings_data.test.js @@ -4,11 +4,15 @@ const assert = require("node:assert/strict"); const {mock_esm, zrequire} = require("./lib/namespace"); 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_config = zrequire("settings_config"); 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 diff --git a/web/tests/settings_muted_users.test.js b/web/tests/settings_muted_users.test.js index 4b3a34ed59..01f61dc2b5 100644 --- a/web/tests/settings_muted_users.test.js +++ b/web/tests/settings_muted_users.test.js @@ -17,6 +17,9 @@ mock_esm("../src/settings_data", { const settings_muted_users = zrequire("settings_muted_users"); const muted_users = zrequire("muted_users"); const people = zrequire("people"); +const {initialize_user_settings} = zrequire("user_settings"); + +initialize_user_settings({user_settings: {}}); run_test("settings", ({override}) => { people.add_active_user({user_id: 5, email: "five@zulip.com", full_name: "Feivel Fiverson"}); diff --git a/web/tests/settings_org.test.js b/web/tests/settings_org.test.js index 843c8036d6..ea5c48052b 100644 --- a/web/tests/settings_org.test.js +++ b/web/tests/settings_org.test.js @@ -26,6 +26,9 @@ const settings_bots = zrequire("settings_bots"); const settings_account = zrequire("settings_account"); const settings_components = zrequire("settings_components"); const settings_org = zrequire("settings_org"); +const {initialize_user_settings} = zrequire("user_settings"); + +initialize_user_settings({user_settings: {}}); function test(label, f) { run_test(label, (helpers) => { diff --git a/web/tests/settings_user_topics.test.js b/web/tests/settings_user_topics.test.js index 6996d65b5d..c4d8f2b857 100644 --- a/web/tests/settings_user_topics.test.js +++ b/web/tests/settings_user_topics.test.js @@ -13,6 +13,9 @@ const list_widget = mock_esm("../src/list_widget", { const settings_user_topics = zrequire("settings_user_topics"); const stream_data = zrequire("stream_data"); const user_topics = zrequire("user_topics"); +const {initialize_user_settings} = zrequire("user_settings"); + +initialize_user_settings({user_settings: {}}); const frontend = { stream_id: 101, diff --git a/web/tests/starred_messages.test.js b/web/tests/starred_messages.test.js index 9b372b7305..1310451dab 100644 --- a/web/tests/starred_messages.test.js +++ b/web/tests/starred_messages.test.js @@ -5,7 +5,6 @@ const assert = require("node:assert/strict"); const {mock_esm, with_overrides, zrequire} = require("./lib/namespace"); const {make_stub} = require("./lib/stub"); 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", { 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 starred_messages = zrequire("starred_messages"); 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", () => { starred_messages.starred_ids.clear(); diff --git a/web/tests/stream_data.test.js b/web/tests/stream_data.test.js index 5b464fa8fb..119c593cb4 100644 --- a/web/tests/stream_data.test.js +++ b/web/tests/stream_data.test.js @@ -5,7 +5,7 @@ const assert = require("node:assert/strict"); const {mock_esm, zrequire} = require("./lib/namespace"); const {run_test} = require("./lib/test"); 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 // web_public_streams in production. @@ -20,6 +20,10 @@ const stream_data = zrequire("stream_data"); const hash_util = zrequire("hash_util"); const stream_settings_data = zrequire("stream_settings_data"); 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", { get_group_permission_setting_config() { diff --git a/web/tests/stream_list.test.js b/web/tests/stream_list.test.js index 801549dd7b..8f428f0ccc 100644 --- a/web/tests/stream_list.test.js +++ b/web/tests/stream_list.test.js @@ -5,7 +5,7 @@ const assert = require("node:assert/strict"); const {mock_esm, set_global, zrequire} = require("./lib/namespace"); const {run_test, noop} = require("./lib/test"); 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"); @@ -35,6 +35,10 @@ const {Filter} = zrequire("../src/filter"); const stream_data = zrequire("stream_data"); const stream_list = zrequire("stream_list"); 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 = { name: "devel", diff --git a/web/tests/stream_list_sort.test.js b/web/tests/stream_list_sort.test.js index 5ad4c400f2..5da734e76b 100644 --- a/web/tests/stream_list_sort.test.js +++ b/web/tests/stream_list_sort.test.js @@ -6,13 +6,16 @@ const _ = require("lodash"); const {zrequire} = require("./lib/namespace"); const {run_test} = require("./lib/test"); -const {user_settings} = require("./lib/zpage_params"); const people = zrequire("people"); const stream_data = zrequire("stream_data"); const stream_topic_history = zrequire("stream_topic_history"); const stream_list_sort = zrequire("stream_list_sort"); 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) { return subs.some((s) => s.name === sub.name); diff --git a/web/tests/stream_settings_ui.test.js b/web/tests/stream_settings_ui.test.js index a0817bac5f..48539ff2e4 100644 --- a/web/tests/stream_settings_ui.test.js +++ b/web/tests/stream_settings_ui.test.js @@ -28,6 +28,9 @@ set_global("page_params", {}); const stream_data = zrequire("stream_data"); const stream_settings_ui = zrequire("stream_settings_ui"); 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}) => { const admins_group = { diff --git a/web/tests/timerender.test.js b/web/tests/timerender.test.js index 7a6c55ee72..0b1386c1a1 100644 --- a/web/tests/timerender.test.js +++ b/web/tests/timerender.test.js @@ -9,7 +9,11 @@ const {$t} = require("./lib/i18n"); const {zrequire} = require("./lib/namespace"); const {run_test} = require("./lib/test"); 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"); diff --git a/web/tests/typeahead_helper.test.js b/web/tests/typeahead_helper.test.js index 7c982f1a0e..0e458341c1 100644 --- a/web/tests/typeahead_helper.test.js +++ b/web/tests/typeahead_helper.test.js @@ -4,7 +4,7 @@ const assert = require("node:assert/strict"); const {mock_esm, zrequire} = require("./lib/namespace"); 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"); @@ -23,6 +23,10 @@ const util = zrequire("util"); const ct = zrequire("composebox_typeahead"); const th = zrequire("typeahead_helper"); 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; diff --git a/web/tests/typing_status.test.js b/web/tests/typing_status.test.js index 1d7ae68d25..378cb5f185 100644 --- a/web/tests/typing_status.test.js +++ b/web/tests/typing_status.test.js @@ -11,6 +11,9 @@ const stream_data = mock_esm("../src/stream_data"); const typing = zrequire("typing"); 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_STOPPED_WAIT_PERIOD = 5000; diff --git a/web/tests/unread.test.js b/web/tests/unread.test.js index c415bc7eba..aaa89d2340 100644 --- a/web/tests/unread.test.js +++ b/web/tests/unread.test.js @@ -6,7 +6,7 @@ const _ = require("lodash"); const {set_global, with_overrides, zrequire} = require("./lib/namespace"); 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; @@ -18,6 +18,10 @@ const people = zrequire("people"); const stream_data = zrequire("stream_data"); const sub_store = zrequire("sub_store"); const unread = zrequire("unread"); +const {initialize_user_settings} = zrequire("user_settings"); + +const user_settings = {}; +initialize_user_settings({user_settings}); const me = { email: "me@example.com", diff --git a/web/tests/user_status.test.js b/web/tests/user_status.test.js index 5efd49f91f..77a8cdf5c5 100644 --- a/web/tests/user_status.test.js +++ b/web/tests/user_status.test.js @@ -10,6 +10,9 @@ const channel = mock_esm("../src/channel"); const user_status = zrequire("user_status"); const emoji_codes = zrequire("../../static/generated/emoji/emoji_codes.json"); const emoji = zrequire("emoji"); +const {initialize_user_settings} = zrequire("user_settings"); + +initialize_user_settings({user_settings: {}}); const emoji_params = { realm_emoji: { diff --git a/web/tests/user_topics.test.js b/web/tests/user_topics.test.js index af1fc1d29b..82820b08f4 100644 --- a/web/tests/user_topics.test.js +++ b/web/tests/user_topics.test.js @@ -10,6 +10,9 @@ const blueslip = require("./lib/zblueslip"); const user_topics = zrequire("user_topics"); const stream_data = zrequire("stream_data"); +const {initialize_user_settings} = zrequire("user_settings"); + +initialize_user_settings({user_settings: {}}); const design = { stream_id: 100, diff --git a/web/tests/util.test.js b/web/tests/util.test.js index 83bd65ee04..48c8ee91b5 100644 --- a/web/tests/util.test.js +++ b/web/tests/util.test.js @@ -9,10 +9,13 @@ const {set_global, zrequire} = require("./lib/namespace"); const {run_test} = require("./lib/test"); const blueslip = zrequire("blueslip"); +const {initialize_user_settings} = zrequire("user_settings"); set_global("document", {}); const util = zrequire("util"); +initialize_user_settings({user_settings: {}}); + run_test("CachedValue", () => { let x = 5;