Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
stream_data: Rename add_sub to add_sub_for_tests.
Evy Kassirer10a815cae778
diff --git a/docs/testing/testing-with-node.md b/docs/testing/testing-with-node.mdindex cd5ce1ff8cd..b75130eb684 100644--- a/docs/testing/testing-with-node.md+++ b/docs/testing/testing-with-node.md@@ -30,7 +30,7 @@ in `web/tests`. Here is an example test fromcolor: 'red',stream_id: id};- stream_data.add_sub('Denmark', sub);+ stream_data.add_sub_for_tests('Denmark', sub);sub = stream_data.get_sub('Denmark');assert.equal(sub.color, 'red');sub = sub_store.get(id);diff --git a/web/src/stream_data.ts b/web/src/stream_data.tsindex 07f5df6aecf..3fb022f5c6f 100644--- a/web/src/stream_data.ts+++ b/web/src/stream_data.ts@@ -162,8 +162,8 @@ export function unsubscribe_myself(sub: StreamSubscription): void {stream_info.set_false(sub.stream_id, sub);}-export function add_sub(sub: StreamSubscription): void {- // This function is currently used only by tests.+export function add_sub_for_tests(sub: StreamSubscription): void {+ // This function is used only by tests.// We use create_sub_from_server_data at page load.// We use create_streams for new streams in live-update events.stream_info.set(sub.stream_id, sub);diff --git a/web/tests/activity.test.cjs b/web/tests/activity.test.cjsindex cffc90060f0..d0ba6172cd1 100644--- a/web/tests/activity.test.cjs+++ b/web/tests/activity.test.cjs@@ -114,7 +114,7 @@ const $fred_stub = $.create("fred stub");const rome_sub = {name: "Rome", subscribed: true, stream_id: 1001};function add_sub_and_set_as_current_narrow(sub) {- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);const filter_terms = [{operator: "stream", operand: sub.stream_id}];message_lists.set_current(make_message_list(filter_terms));}diff --git a/web/tests/buddy_data.test.cjs b/web/tests/buddy_data.test.cjsindex 9906368f9c2..6ed91c746dc 100644--- a/web/tests/buddy_data.test.cjs+++ b/web/tests/buddy_data.test.cjs@@ -402,7 +402,7 @@ test("show offline channel subscribers for small channels", ({override_rewire})const stream_id = 1001;const sub = {name: "Rome", subscribed: true, stream_id};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);peer_data.set_subscribers(stream_id, [selma.user_id,alice.user_id,@@ -433,7 +433,7 @@ test("get_conversation_participants", () => {people.add_active_user(selma);const rome_sub = {name: "Rome", subscribed: true, stream_id: 1001};- stream_data.add_sub(rome_sub);+ stream_data.add_sub_for_tests(rome_sub);peer_data.set_subscribers(rome_sub.stream_id, [selma.user_id, me.user_id]);const filter_terms = [@@ -486,7 +486,7 @@ test("compare_function", () => {const stream_id = 1001;const sub = {name: "Rome", subscribed: true, stream_id};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);people.add_active_user(alice);people.add_active_user(fred);diff --git a/web/tests/channel_folders.test.cjs b/web/tests/channel_folders.test.cjsindex be9c0fa7185..b350751a0fd 100644--- a/web/tests/channel_folders.test.cjs+++ b/web/tests/channel_folders.test.cjs@@ -102,13 +102,13 @@ run_test("basics", () => {name: "Stream 4",folder_id: frontend_folder.id,});- stream_data.add_sub(stream_1);+ stream_data.add_sub_for_tests(stream_1);assert.deepEqual(channel_folders.user_has_folders(), false);- stream_data.add_sub(stream_2);- stream_data.add_sub(stream_3);- stream_data.add_sub(stream_4);+ stream_data.add_sub_for_tests(stream_2);+ stream_data.add_sub_for_tests(stream_3);+ stream_data.add_sub_for_tests(stream_4);assert.deepEqual(channel_folders.get_stream_ids_in_folder(frontend_folder.id), [stream_2.stream_id,diff --git a/web/tests/clipboard_handler.test.cjs b/web/tests/clipboard_handler.test.cjsindex f1a88ff6dd0..6e4634e6a46 100644--- a/web/tests/clipboard_handler.test.cjs+++ b/web/tests/clipboard_handler.test.cjs@@ -33,7 +33,7 @@ run_test("copy_link_to_clipboard", async ({override}) => {subscribed: true,type: "stream",};- stream_data.add_sub(stream);+ stream_data.add_sub_for_tests(stream);const {window} = new JSDOM();global.document = window.document;diff --git a/web/tests/compose.test.cjs b/web/tests/compose.test.cjsindex fc6b35fe6b8..8e55f87bd17 100644--- a/web/tests/compose.test.cjs+++ b/web/tests/compose.test.cjs@@ -130,7 +130,7 @@ const social = {can_send_message_group: 2,topics_policy: "inherit",};-stream_data.add_sub(social);+stream_data.add_sub_for_tests(social);const nobody = make_user_group({name: "role:nobody",diff --git a/web/tests/compose_actions.test.cjs b/web/tests/compose_actions.test.cjsindex bda164c2198..0a614bb2319 100644--- a/web/tests/compose_actions.test.cjs+++ b/web/tests/compose_actions.test.cjs@@ -212,7 +212,7 @@ test("start", ({override, override_rewire, mock_template}) => {name: "Denmark",stream_id: 1,});- stream_data.add_sub(denmark);+ stream_data.add_sub_for_tests(denmark);compose_defaults = {trigger: "clear topic button",@@ -241,7 +241,7 @@ test("start", ({override, override_rewire, mock_template}) => {name: "social",stream_id: 2,});- stream_data.add_sub(social);+ stream_data.add_sub_for_tests(social);compose_state.set_stream_id("");// More than 1 subscription, do not autofill@@ -362,7 +362,7 @@ test("respond_to_message", ({override, override_rewire, mock_template}) => {name: "Denmark",stream_id: 1,});- stream_data.add_sub(denmark);+ stream_data.add_sub_for_tests(denmark);msg = {type: "stream",@@ -402,7 +402,7 @@ test("reply_with_mention", ({override, override_rewire, mock_template}) => {name: "Denmark",stream_id: 1,});- stream_data.add_sub(denmark);+ stream_data.add_sub_for_tests(denmark);const msg = {type: "stream",diff --git a/web/tests/compose_closed_ui.test.cjs b/web/tests/compose_closed_ui.test.cjsindex 81695313dc9..1a5e3739008 100644--- a/web/tests/compose_closed_ui.test.cjs+++ b/web/tests/compose_closed_ui.test.cjs@@ -85,13 +85,13 @@ run_test("reply_label", () => {name: "first_stream",stream_id: 1,};- stream_data.add_sub(stream_one);+ stream_data.add_sub_for_tests(stream_one);const stream_two = {subscribed: true,name: "second_stream",stream_id: 2,};- stream_data.add_sub(stream_two);+ stream_data.add_sub_for_tests(stream_two);list.add_messages([{@@ -208,7 +208,7 @@ run_test("test_non_message_list_input", () => {name: "stream test",stream_id: 10,};- stream_data.add_sub(stream);+ stream_data.add_sub_for_tests(stream);// Channel and topic row.compose_closed_ui.update_recipient_text_for_reply_button({diff --git a/web/tests/compose_fade.test.cjs b/web/tests/compose_fade.test.cjsindex fab43aed2b2..f50fb4cbbb8 100644--- a/web/tests/compose_fade.test.cjs+++ b/web/tests/compose_fade.test.cjs@@ -63,7 +63,7 @@ run_test("set_focused_recipient", () => {};stream_data.clear_subscriptions();- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);compose_state.set_stream_id(sub.stream_id);peer_data.set_subscribers(sub.stream_id, [me.user_id, alice.user_id]);compose_fade.set_focused_recipient("stream");@@ -107,7 +107,7 @@ run_test("want_normal_display", ({override}) => {// Focused recipient is a valid stream with no topic set// when topics are mandatoryoverride(realm, "realm_topics_policy", "disable_empty_topic");- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);assert.ok(compose_fade_helper.want_normal_display());// Focused recipient is a valid stream with no topic setdiff --git a/web/tests/compose_paste.test.cjs b/web/tests/compose_paste.test.cjsindex a95ea2aa41c..795efb1f874 100644--- a/web/tests/compose_paste.test.cjs+++ b/web/tests/compose_paste.test.cjs@@ -16,11 +16,11 @@ const compose_paste = zrequire("compose_paste");const stream_data = zrequire("stream_data");set_global("document", {});-stream_data.add_sub({+stream_data.add_sub_for_tests({stream_id: 4,name: "Rome",});-stream_data.add_sub({+stream_data.add_sub_for_tests({stream_id: 5,name: "Romeo`s lair",});diff --git a/web/tests/compose_state.test.cjs b/web/tests/compose_state.test.cjsindex e5178a7dd77..92ab3f36ebc 100644--- a/web/tests/compose_state.test.cjs+++ b/web/tests/compose_state.test.cjs@@ -47,7 +47,7 @@ run_test("has_full_recipient", ({override}) => {compose_state.topic("foo");assert.equal(compose_state.has_full_recipient(), false);- stream_data.add_sub({name: "bar", stream_id: 99});+ stream_data.add_sub_for_tests({name: "bar", stream_id: 99});compose_state.set_stream_id(99);assert.equal(compose_state.has_full_recipient(), true);diff --git a/web/tests/compose_ui.test.cjs b/web/tests/compose_ui.test.cjsindex a1db27b1584..87b1da63fca 100644--- a/web/tests/compose_ui.test.cjs+++ b/web/tests/compose_ui.test.cjs@@ -210,7 +210,7 @@ run_test("compute_placeholder_text", ({override}) => {name: "all",stream_id: 2,};- stream_data.add_sub(stream_all);+ stream_data.add_sub_for_tests(stream_all);opts.stream_id = stream_all.stream_id;assert.equal(compose_ui.compute_placeholder_text(opts), $t({defaultMessage: "Message #all"}));@@ -1298,7 +1298,7 @@ run_test("get_focus_area", ({override}) => {"#compose_select_recipient_widget_wrapper",);- stream_data.add_sub({+ stream_data.add_sub_for_tests({message_type: "stream",name: "fun",stream_id: 4,diff --git a/web/tests/compose_validate.test.cjs b/web/tests/compose_validate.test.cjsindex 422cf090f85..a6a94929c1c 100644--- a/web/tests/compose_validate.test.cjs+++ b/web/tests/compose_validate.test.cjs@@ -87,7 +87,7 @@ const social_sub = {name: "social",subscribed: true,};-stream_data.add_sub(social_sub);+stream_data.add_sub_for_tests(social_sub);people.add_active_user(me);people.initialize_current_user(me.user_id);@@ -200,11 +200,11 @@ test_ui("validate_stream_message_address_info", ({mock_template, override}) => {can_add_subscribers_group: nobody.id,can_subscribe_group: nobody.id,};- stream_data.add_sub(party_sub);+ stream_data.add_sub_for_tests(party_sub);assert.ok(compose_validate.validate_stream_message_address_info(party_sub));party_sub.subscribed = false;- stream_data.add_sub(party_sub);+ stream_data.add_sub_for_tests(party_sub);let user_not_subscribed_rendered = false;mock_template("compose_banner/compose_banner.hbs", true, (data, html) => {assert.equal(data.classname, compose_banner.CLASSNAMES.user_not_subscribed);@@ -216,7 +216,7 @@ test_ui("validate_stream_message_address_info", ({mock_template, override}) => {party_sub.name = "Frontend";party_sub.stream_id = 102;- stream_data.add_sub(party_sub);+ stream_data.add_sub_for_tests(party_sub);user_not_subscribed_rendered = false;assert.ok(!compose_validate.validate_stream_message_address_info(party_sub));@@ -326,7 +326,7 @@ test_ui("validate", ({mock_template, override}) => {stream_id: 100,name: "Denmark",};- stream_data.add_sub(denmark);+ stream_data.add_sub_for_tests(denmark);compose_state.set_stream_id(denmark.stream_id);override(realm, "realm_topics_policy", "disable_empty_topic");let missing_topic_error_rendered = false;@@ -398,7 +398,7 @@ test_ui("validate_stream_message", ({override, override_rewire, mock_template})can_send_message_group: everyone.id,topics_policy: "inherit",};- stream_data.add_sub(special_sub);+ stream_data.add_sub_for_tests(special_sub);compose_state.set_stream_id(special_sub.stream_id);$("#send_message_form").set_find_results(".message-textarea", $("textarea#compose-textarea"));@@ -445,7 +445,7 @@ test_ui("test_stream_posting_permission", ({mock_template, override}) => {can_send_message_group: admin.id,};- stream_data.add_sub(sub_stream_102);+ stream_data.add_sub_for_tests(sub_stream_102);compose_state.topic("topic102");compose_state.set_stream_id(sub_stream_102.stream_id);@@ -548,7 +548,7 @@ test_ui("needs_subscribe_warning", async () => {name: "stream",};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);peer_data.set_subscribers(sub.stream_id, [bob.user_id, me.user_id]);blueslip.expect("error", "Unknown user_id in maybe_get_user_by_id");@@ -580,14 +580,14 @@ test_ui("warn_if_private_stream_is_linked", async ({mock_template}) => {stream_id: 99,};- stream_data.add_sub(test_sub);+ stream_data.add_sub_for_tests(test_sub);peer_data.set_subscribers(test_sub.stream_id, [1, 2]);const denmark = {stream_id: 100,name: "Denmark",};- stream_data.add_sub(denmark);+ stream_data.add_sub_for_tests(denmark);peer_data.set_subscribers(denmark.stream_id, [1, 2, 3]);@@ -624,7 +624,7 @@ test_ui("warn_if_private_stream_is_linked", async ({mock_template}) => {name: "Denmark",stream_id: 22,};- stream_data.add_sub(secret_stream);+ stream_data.add_sub_for_tests(secret_stream);peer_data.set_subscribers(secret_stream.stream_id, []);banner_rendered = false;const $banner_container = $("#compose_banners");@@ -697,7 +697,7 @@ test_ui("warn_if_mentioning_unsubscribed_user", async ({override, mock_template}can_administer_channel_group: admin.id,can_subscribe_group: admin.id,};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);compose_state.set_stream_id(sub.stream_id);// Test with invalid stream in compose box. It should return noop.@@ -770,7 +770,7 @@ test_ui("test warn_if_topic_resolved", ({override, mock_template}) => {can_move_messages_out_of_channel_group: nobody.id,can_move_messages_within_channel_group: nobody.id,};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);compose_state.set_message_type("stream");compose_state.set_stream_id("");diff --git a/web/tests/composebox_typeahead.test.cjs b/web/tests/composebox_typeahead.test.cjsindex 9585a0b8568..4bd765f22d3 100644--- a/web/tests/composebox_typeahead.test.cjs+++ b/web/tests/composebox_typeahead.test.cjs@@ -617,12 +617,12 @@ const broken_link_stream = stream_item({can_add_subscribers_group: support.id,});-stream_data.add_sub(sweden_stream);-stream_data.add_sub(denmark_stream);-stream_data.add_sub(netherland_stream);-stream_data.add_sub(mobile_stream);-stream_data.add_sub(mobile_team_stream);-stream_data.add_sub(broken_link_stream);+stream_data.add_sub_for_tests(sweden_stream);+stream_data.add_sub_for_tests(denmark_stream);+stream_data.add_sub_for_tests(netherland_stream);+stream_data.add_sub_for_tests(mobile_stream);+stream_data.add_sub_for_tests(mobile_team_stream);+stream_data.add_sub_for_tests(broken_link_stream);const make_emoji = (emoji_dict) => ({emoji_name: emoji_dict.name,diff --git a/web/tests/dispatch_subs.test.cjs b/web/tests/dispatch_subs.test.cjsindex df41bbdd5ec..6b4af413aa6 100644--- a/web/tests/dispatch_subs.test.cjs+++ b/web/tests/dispatch_subs.test.cjs@@ -58,7 +58,7 @@ test("add", ({override}) => {const sub = event.subscriptions[0];const stream_id = sub.stream_id;- stream_data.add_sub({+ stream_data.add_sub_for_tests({stream_id,name: sub.name,});@@ -75,7 +75,7 @@ test("add", ({override}) => {test("peer add/remove", ({override}) => {let event = event_fixtures.subscription__peer_add;- stream_data.add_sub({+ stream_data.add_sub_for_tests({name: "devel",stream_id: event.stream_ids[0],});@@ -105,7 +105,7 @@ test("remove", ({override}) => {name: event_sub.name,};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);const stub = make_stub();override(stream_events, "mark_unsubscribed", stub.f);@@ -209,8 +209,8 @@ test("stream delete (normal)", ({override}) => {is_archived: false,};- stream_data.add_sub(test_sub);- stream_data.add_sub(devel_sub);+ stream_data.add_sub_for_tests(test_sub);+ stream_data.add_sub_for_tests(devel_sub);stream_data.subscribe_myself(devel_sub);@@ -252,8 +252,8 @@ test("stream delete (special streams)", ({override}) => {is_archived: false,};- stream_data.add_sub(devel_sub);- stream_data.add_sub(test_sub);+ stream_data.add_sub_for_tests(devel_sub);+ stream_data.add_sub_for_tests(test_sub);stream_data.subscribe_myself(devel_sub);@@ -303,8 +303,8 @@ test("stream delete (stream is selected in compose)", ({override}) => {is_archived: false,};- stream_data.add_sub(devel_sub);- stream_data.add_sub(test_sub);+ stream_data.add_sub_for_tests(devel_sub);+ stream_data.add_sub_for_tests(test_sub);stream_data.subscribe_myself(devel_sub);compose_state.set_stream_id(event.stream_ids[0]);diff --git a/web/tests/drafts.test.cjs b/web/tests/drafts.test.cjsindex 400c4cb51f1..9ce8c134133 100644--- a/web/tests/drafts.test.cjs+++ b/web/tests/drafts.test.cjs@@ -78,10 +78,10 @@ const stream_2 = make_stream({invite_only: false,is_web_public: false,});-stream_data.add_sub(stream_A);-stream_data.add_sub(stream_B);-stream_data.add_sub(stream_1);-stream_data.add_sub(stream_2);+stream_data.add_sub_for_tests(stream_A);+stream_data.add_sub_for_tests(stream_B);+stream_data.add_sub_for_tests(stream_1);+stream_data.add_sub_for_tests(stream_2);const setTimeout_delay = 3000;set_global("setTimeout", (f, delay) => {diff --git a/web/tests/echo.test.cjs b/web/tests/echo.test.cjsindex a6f6cbd1b14..e470f962076 100644--- a/web/tests/echo.test.cjs+++ b/web/tests/echo.test.cjs@@ -91,7 +91,7 @@ const general_sub = {name: "general",subscribed: true,};-stream_data.add_sub(general_sub);+stream_data.add_sub_for_tests(general_sub);run_test("process_from_server for un-echoed messages", () => {const waiting_for_ack = new Map();diff --git a/web/tests/example1.test.cjs b/web/tests/example1.test.cjsindex 5886932dd8f..987b8c4a347 100644--- a/web/tests/example1.test.cjs+++ b/web/tests/example1.test.cjs@@ -70,7 +70,7 @@ const denmark_stream = make_stream({run_test("verify stream_data persists stream color", () => {stream_data.clear_subscriptions();assert.equal(stream_data.get_sub_by_name("Denmark"), undefined);- stream_data.add_sub(denmark_stream);+ stream_data.add_sub_for_tests(denmark_stream);const sub = stream_data.get_sub_by_name("Denmark");assert.equal(sub.color, "a1a1a1");});diff --git a/web/tests/example2.test.cjs b/web/tests/example2.test.cjsindex beb853f220a..d5c26ec36f8 100644--- a/web/tests/example2.test.cjs+++ b/web/tests/example2.test.cjs@@ -65,7 +65,7 @@ people.add_active_user(isaac);run_test("message_store", () => {message_store.clear_for_testing();stream_data.clear_subscriptions();- stream_data.add_sub(denmark_stream);+ stream_data.add_sub_for_tests(denmark_stream);const in_message = {...messages.isaac_to_denmark_stream};@@ -89,7 +89,7 @@ run_test("message_store", () => {run_test("unread", () => {unread.declare_bankruptcy();stream_data.clear_subscriptions();- stream_data.add_sub(denmark_stream);+ stream_data.add_sub_for_tests(denmark_stream);const stream_id = denmark_stream.stream_id;const topic_name = "copenhagen";diff --git a/web/tests/example3.test.cjs b/web/tests/example3.test.cjsindex 16d21ac0d8f..1c0512e16be 100644--- a/web/tests/example3.test.cjs+++ b/web/tests/example3.test.cjs@@ -28,7 +28,7 @@ const denmark_stream = make_stream({run_test("filter", () => {stream_data.clear_subscriptions();- stream_data.add_sub(denmark_stream);+ stream_data.add_sub_for_tests(denmark_stream);const filter_terms = [{operator: "stream", operand: denmark_stream.stream_id.toString()},@@ -72,7 +72,7 @@ const message_lists = zrequire("message_lists");run_test("narrow_state", () => {stream_data.clear_subscriptions();- stream_data.add_sub(denmark_stream);+ stream_data.add_sub_for_tests(denmark_stream);message_lists.set_current(undefined);// As we often do, first make assertions about the startingdiff --git a/web/tests/example7.test.cjs b/web/tests/example7.test.cjsindex 939823d866f..875e37016e3 100644--- a/web/tests/example7.test.cjs+++ b/web/tests/example7.test.cjs@@ -80,7 +80,7 @@ run_test("unread_ops", ({override}) => {return "block";};stream_data.clear_subscriptions();- stream_data.add_sub(denmark_stream);+ stream_data.add_sub_for_tests(denmark_stream);message_store.clear_for_testing();unread.declare_bankruptcy();diff --git a/web/tests/filter.test.cjs b/web/tests/filter.test.cjsindex c9745e95a05..aca5999c3e3 100644--- a/web/tests/filter.test.cjs+++ b/web/tests/filter.test.cjs@@ -99,7 +99,7 @@ function make_sub(name, stream_id) {name,stream_id,};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);}let _stream_id = 0;@@ -118,7 +118,7 @@ const general_sub = {name: "general",stream_id: new_stream_id(),};-stream_data.add_sub(general_sub);+stream_data.add_sub_for_tests(general_sub);const invalid_sub_id = new_stream_id();@@ -1077,7 +1077,7 @@ test("predicate_basics", ({override}) => {// To keep these tests simple, we only pass objects with a few relevant attributes// rather than full-fledged message objects.- stream_data.add_sub(foo_sub);+ stream_data.add_sub_for_tests(foo_sub);let predicate = get_predicate([["channel", foo_stream_id.toString()],["topic", "Bar"],@@ -1115,9 +1115,9 @@ test("predicate_basics", ({override}) => {invite_only: false,is_web_public: true,};- stream_data.add_sub(old_sub);- stream_data.add_sub(private_sub);- stream_data.add_sub(web_public_sub);+ stream_data.add_sub_for_tests(old_sub);+ stream_data.add_sub_for_tests(private_sub);+ stream_data.add_sub_for_tests(web_public_sub);predicate = get_predicate([["channel", old_sub_id.toString()],["topic", "Bar"],@@ -1200,7 +1200,7 @@ test("predicate_basics", ({override}) => {name: "muted",is_muted: true,};- stream_data.add_sub(muted_stream);+ stream_data.add_sub_for_tests(muted_stream);assert.ok(!predicate({stream_id: muted_stream.stream_id, topic: "bar"}));// Muted stream but topic is unmuted or followed is part of in-home.@@ -2046,7 +2046,7 @@ test("is_valid_search_term", () => {stream_id: 100,name: "Denmark",};- stream_data.add_sub(denmark);+ stream_data.add_sub_for_tests(denmark);const test_data = [["has:image", true],@@ -2255,7 +2255,7 @@ function make_private_sub(name, stream_id) {stream_id,invite_only: true,};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);}function make_web_public_sub(name, stream_id) {@@ -2264,7 +2264,7 @@ function make_web_public_sub(name, stream_id) {stream_id,is_web_public: true,};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);}function make_archived_sub(name, stream_id) {@@ -2273,11 +2273,11 @@ function make_archived_sub(name, stream_id) {stream_id,is_archived: true,};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);}test("navbar_helpers", ({override}) => {- stream_data.add_sub(foo_sub);+ stream_data.add_sub_for_tests(foo_sub);// make sure title has names separated with correct delimitersfunction properly_separated_names(names) {diff --git a/web/tests/hash_util.test.cjs b/web/tests/hash_util.test.cjsindex 9744b168db5..ce86a5a7874 100644--- a/web/tests/hash_util.test.cjs+++ b/web/tests/hash_util.test.cjs@@ -27,7 +27,7 @@ const frontend = {name: "frontend",};-stream_data.add_sub(frontend);+stream_data.add_sub_for_tests(frontend);run_test("hash_util", () => {// Test encode_operand and decode_operanddiff --git a/web/tests/hashchange.test.cjs b/web/tests/hashchange.test.cjsindex bd076b560fb..d72a74504a5 100644--- a/web/tests/hashchange.test.cjs+++ b/web/tests/hashchange.test.cjs@@ -52,7 +52,7 @@ const devel = {color: "blue",subscribed: true,};-stream_data.add_sub(devel);+stream_data.add_sub_for_tests(devel);run_test("terms_round_trip", () => {let terms;@@ -91,7 +91,7 @@ run_test("terms_round_trip", () => {name: "Florida, USA",stream_id: florida_id,};- stream_data.add_sub(florida_stream);+ stream_data.add_sub_for_tests(florida_stream);terms = [{operator: "stream", operand: florida_id.toString()}];hash = hash_util.search_terms_to_hash(terms);assert.equal(hash, "#narrow/channel/987-Florida.2C-USA");@@ -134,7 +134,7 @@ run_test("stream_to_channel_rename", () => {name: "decode",stream_id: test_stream_id,};- stream_data.add_sub(test_channel);+ stream_data.add_sub_for_tests(test_channel);hash = "#narrow/channel/34-decode";narrow = hash_util.parse_narrow(hash.split("/"));assert.deepEqual(narrow, [@@ -298,7 +298,7 @@ run_test("hash_interactions", ({override, override_rewire}) => {assert.equal(window.location.hash, "#recent");const denmark_id = 1;- stream_data.add_sub({+ stream_data.add_sub_for_tests({subscribed: true,name: "Denmark",stream_id: denmark_id,diff --git a/web/tests/markdown.test.cjs b/web/tests/markdown.test.cjsindex c8bbe98ab71..2f5f4e2828a 100644--- a/web/tests/markdown.test.cjs+++ b/web/tests/markdown.test.cjs@@ -206,13 +206,13 @@ const amp_stream = {stream_id: 5,is_muted: false,};-stream_data.add_sub(denmark);-stream_data.add_sub(social);-stream_data.add_sub(edgecase_stream);-stream_data.add_sub(edgecase_stream_2);+stream_data.add_sub_for_tests(denmark);+stream_data.add_sub_for_tests(social);+stream_data.add_sub_for_tests(edgecase_stream);+stream_data.add_sub_for_tests(edgecase_stream_2);// Note: edgecase_stream cannot be mentioned because it is caught by// streamTopicHandler and it would be parsed as edgecase_stream_2.-stream_data.add_sub(amp_stream);+stream_data.add_sub_for_tests(amp_stream);markdown.initialize(markdown_config.get_helpers());linkifiers.initialize(example_realm_linkifiers);diff --git a/web/tests/message_delete.test.cjs b/web/tests/message_delete.test.cjsindex 99bf6ca7907..7ec251fd32a 100644--- a/web/tests/message_delete.test.cjs+++ b/web/tests/message_delete.test.cjs@@ -171,8 +171,8 @@ run_test("get_deletability", ({override}) => {can_delete_any_message_group: nobody_group.id,can_delete_own_message_group: moderators_group.id,};- stream_data.add_sub(social);- stream_data.add_sub(denmark);+ stream_data.add_sub_for_tests(social);+ stream_data.add_sub_for_tests(denmark);message = {locally_echoed: true,diff --git a/web/tests/message_events.test.cjs b/web/tests/message_events.test.cjsindex 5fb31b2bf9d..aab030aed66 100644--- a/web/tests/message_events.test.cjs+++ b/web/tests/message_events.test.cjs@@ -49,7 +49,7 @@ const denmark = {name: "Denmark",stream_id: 101,};-stream_data.add_sub(denmark);+stream_data.add_sub_for_tests(denmark);function test_helper(side_effects) {const events = [];diff --git a/web/tests/message_view.test.cjs b/web/tests/message_view.test.cjsindex adeaa23fb10..c0e9cb145da 100644--- a/web/tests/message_view.test.cjs+++ b/web/tests/message_view.test.cjs@@ -279,7 +279,7 @@ run_test("show_empty_narrow_message", ({mock_template, override}) => {// for non-subbed public streamconst rome_id = 99;- stream_data.add_sub({name: "ROME", stream_id: rome_id});+ stream_data.add_sub_for_tests({name: "ROME", stream_id: rome_id});current_filter = set_filter([["stream", rome_id.toString()]]);narrow_banner.show_empty_narrow_message(current_filter);assert.equal(@@ -317,7 +317,11 @@ run_test("show_empty_narrow_message", ({mock_template, override}) => {// for web-public stream for spectatorconst web_public_id = 1231;- stream_data.add_sub({name: "web-public-stream", stream_id: web_public_id, is_web_public: true});+ stream_data.add_sub_for_tests({+ name: "web-public-stream",+ stream_id: web_public_id,+ is_web_public: true,+ });current_filter = set_filter([["stream", web_public_id.toString()],["topic", "foo"],@@ -585,7 +589,7 @@ run_test("show_empty_narrow_message", ({mock_template, override}) => {name: "my stream",stream_id: my_stream_id,};- stream_data.add_sub(my_stream);+ stream_data.add_sub_for_tests(my_stream);stream_data.subscribe_myself(my_stream);current_filter = set_filter([["stream", my_stream_id.toString()]]);const list = new MessageList({@@ -680,7 +684,7 @@ run_test("show_search_stopwords", ({mock_template, override}) => {);const streamA_id = 88;- stream_data.add_sub({name: "streamA", stream_id: streamA_id});+ stream_data.add_sub_for_tests({name: "streamA", stream_id: streamA_id});current_filter = set_filter([["stream", streamA_id.toString()],["search", "what about grail"],@@ -708,8 +712,8 @@ run_test("show_invalid_narrow_message", ({mock_template}) => {const streamA_id = 88;const streamB_id = 77;- stream_data.add_sub({name: "streamA", stream_id: streamA_id});- stream_data.add_sub({name: "streamB", stream_id: streamB_id});+ stream_data.add_sub_for_tests({name: "streamA", stream_id: streamA_id});+ stream_data.add_sub_for_tests({name: "streamB", stream_id: streamB_id});let current_filter = set_filter([["stream", streamA_id.toString()],@@ -777,7 +781,7 @@ run_test("narrow_to_compose_target streams", ({override, override_rewire}) => {compose_state.set_message_type("stream");const rome_id = 99;- stream_data.add_sub({name: "ROME", stream_id: rome_id, topics_policy: "inherit"});+ stream_data.add_sub_for_tests({name: "ROME", stream_id: rome_id, topics_policy: "inherit"});compose_state.set_stream_id(99);// Test with existing topic@@ -923,7 +927,7 @@ run_test("narrow_compute_title", () => {name: "Foo",stream_id: foo_stream_id,};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);filter = new Filter([{operator: "stream", operand: foo_stream_id.toString()},diff --git a/web/tests/narrow_state.test.cjs b/web/tests/narrow_state.test.cjsindex 2470b8f7a7f..f768e15cdfb 100644--- a/web/tests/narrow_state.test.cjs+++ b/web/tests/narrow_state.test.cjs@@ -64,7 +64,7 @@ test("stream", () => {// Stream exists and user has access to the stream.const test_stream = {name: "Test", stream_id: test_stream_id};- stream_data.add_sub(test_stream);+ stream_data.add_sub_for_tests(test_stream);set_filter([["stream", test_stream_id.toString()],["topic", "Bar"],@@ -98,7 +98,7 @@ test("narrowed", () => {assert.ok(!narrow_state.narrowed_by_stream_reply());assert.equal(narrow_state.stream_sub(), undefined);- stream_data.add_sub(foo_stream);+ stream_data.add_sub_for_tests(foo_stream);set_filter([["stream", "Foo"]]);assert.ok(!narrow_state.narrowed_to_pms());@@ -218,7 +218,7 @@ test("set_compose_defaults", () => {assert.equal(stream_and_topic.stream_id, undefined);assert.equal(stream_and_topic.topic, "Bar");- stream_data.add_sub(foo_stream);+ stream_data.add_sub_for_tests(foo_stream);stream_and_topic = narrow_state.set_compose_defaults();assert.equal(stream_and_topic.stream_id, foo_stream_id);assert.equal(stream_and_topic.topic, "Bar");@@ -252,7 +252,7 @@ test("set_compose_defaults", () => {assert.deepEqual(narrow_state.set_compose_defaults(), {});const rome_id = 99;- stream_data.add_sub({name: "ROME", stream_id: rome_id});+ stream_data.add_sub_for_tests({name: "ROME", stream_id: rome_id});set_filter([["stream", rome_id.toString()]]);const stream_test = narrow_state.set_compose_defaults();@@ -318,7 +318,7 @@ test("stream_sub", () => {assert.equal(narrow_state.stream_sub(), undefined);const sub = {name: "Foo", stream_id: 55};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);assert.equal(narrow_state.stream_name(), "Foo");assert.deepEqual(narrow_state.stream_sub(), sub);diff --git a/web/tests/narrow_unread.test.cjs b/web/tests/narrow_unread.test.cjsindex dbeb866d9fb..d4649086e25 100644--- a/web/tests/narrow_unread.test.cjs+++ b/web/tests/narrow_unread.test.cjs@@ -100,7 +100,7 @@ run_test("get_unread_ids", () => {message_store.update_message_cache(private_msg);message_store.update_message_cache(other_topic_message);- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);terms = [{operator: "search", operand: "whatever"}];set_filter(terms);diff --git a/web/tests/notifications.test.cjs b/web/tests/notifications.test.cjsindex 1a925155c18..70920518c24 100644--- a/web/tests/notifications.test.cjs+++ b/web/tests/notifications.test.cjs@@ -41,8 +41,8 @@ const muted = {wildcard_mentions_notify: null,};-stream_data.add_sub(general);-stream_data.add_sub(muted);+stream_data.add_sub_for_tests(general);+stream_data.add_sub_for_tests(muted);user_topics.update_user_topics(general.stream_id,diff --git a/web/tests/peer_data.test.cjs b/web/tests/peer_data.test.cjsindex e50e17d8005..19dd2223017 100644--- a/web/tests/peer_data.test.cjs+++ b/web/tests/peer_data.test.cjs@@ -93,7 +93,7 @@ function test(label, f) {test("unsubscribe", () => {const devel = {name: "devel", subscribed: false, stream_id: 1};- stream_data.add_sub(devel);+ stream_data.add_sub_for_tests(devel);// verify clean slateassert.ok(!stream_data.is_subscribed(devel.stream_id));@@ -126,7 +126,7 @@ test("subscribers", async () => {can_administer_channel_group: nobody_group.id,can_subscribe_group: nobody_group.id,};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);people.add_active_user(fred);people.add_active_user(gail);@@ -213,7 +213,7 @@ test("subscribers", async () => {// Verify defensive code in set_subscribers, where the second parameter// can be undefined.- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);peer_data.add_subscriber(stream_id, brutus.user_id);sub.subscribed = true;assert.ok(stream_data.is_user_subscribed(stream_id, brutus.user_id));@@ -271,7 +271,7 @@ test("maybe_fetch_stream_subscribers", async () => {name: "India",subscribed: true,};- stream_data.add_sub(india);+ stream_data.add_sub_for_tests(india);let channel_get_calls = 0;channel.get = (opts) => {assert.equal(opts.url, `/json/streams/${india.stream_id}/members`);@@ -391,7 +391,7 @@ test("get_subscriber_count", async () => {blueslip.expect("warn", "We called get_subscriber_count for an untracked stream: 102");assert.equal(peer_data.get_subscriber_count(india.stream_id), 0);- stream_data.add_sub(india);+ stream_data.add_sub_for_tests(india);assert.equal(peer_data.get_subscriber_count(india.stream_id), 0);peer_data.add_subscriber(india.stream_id, fred.user_id);@@ -431,7 +431,7 @@ test("is_subscriber_subset", async () => {stream_id,name: `stream ${stream_id}`,};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);peer_data.set_subscribers(sub.stream_id, user_ids);return sub;}@@ -491,7 +491,7 @@ test("is_subscriber_subset", async () => {test("get_unique_subscriber_count_for_streams", async () => {const sub = {name: "Rome", subscribed: true, stream_id: 1001};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);people.add_active_user(fred);people.add_active_user(gail);diff --git a/web/tests/pill_typeahead.test.cjs b/web/tests/pill_typeahead.test.cjsindex 1576a847f4d..e90b567c77d 100644--- a/web/tests/pill_typeahead.test.cjs+++ b/web/tests/pill_typeahead.test.cjs@@ -147,7 +147,7 @@ const sweden_item = stream_item(sweden);const subs = [denmark, sweden];for (const sub of subs) {- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);}peer_data.set_subscribers(denmark.stream_id, [me.user_id, mark.user_id]);peer_data.set_subscribers(sweden.stream_id, [mark.user_id, jill.user_id]);diff --git a/web/tests/rendered_markdown.test.cjs b/web/tests/rendered_markdown.test.cjsindex 48d005e22f6..45196e5e8d3 100644--- a/web/tests/rendered_markdown.test.cjs+++ b/web/tests/rendered_markdown.test.cjs@@ -96,7 +96,7 @@ const stream = {is_muted: true,invite_only: false,};-stream_data.add_sub(stream);+stream_data.add_sub_for_tests(stream);const $array = (array) => {const each = (func) => {diff --git a/web/tests/search.test.cjs b/web/tests/search.test.cjsindex c271f24ae75..d6336eeb6fe 100644--- a/web/tests/search.test.cjs+++ b/web/tests/search.test.cjs@@ -40,7 +40,7 @@ const verona = {name: "Verona",stream_id: 1,};-stream_data.add_sub(verona);+stream_data.add_sub_for_tests(verona);run_test("initialize", ({override, override_rewire, mock_template}) => {const $search_query_box = $("#search_query");diff --git a/web/tests/search_suggestion.test.cjs b/web/tests/search_suggestion.test.cjsindex 4981978259e..972a0afa71c 100644--- a/web/tests/search_suggestion.test.cjs+++ b/web/tests/search_suggestion.test.cjs@@ -106,7 +106,7 @@ test("basic_get_suggestions_for_spectator", () => {page_params.is_spectator = true;const web_public_id = new_stream_id();const sub = {name: "Web public", stream_id: web_public_id, is_web_public: true};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);let query = "";let suggestions = get_suggestions(query);@@ -365,13 +365,13 @@ test("empty_query_suggestions", () => {const devel_id = new_stream_id();const office_id = new_stream_id();- stream_data.add_sub({+ stream_data.add_sub_for_tests({stream_id: devel_id,name: "devel",subscribed: true,is_web_public: true,});- stream_data.add_sub({stream_id: office_id, name: "office", subscribed: true});+ stream_data.add_sub_for_tests({stream_id: office_id, name: "office", subscribed: true});const suggestions = get_suggestions(query);@@ -420,8 +420,8 @@ test("has_suggestions", ({override, mock_template}) => {// Checks that category wise suggestions are displayed instead of a single// default suggestion when suggesting `has` operator.let query = "h";- stream_data.add_sub({stream_id: 44, name: "devel", subscribed: true});- stream_data.add_sub({stream_id: 77, name: "office", subscribed: true});+ stream_data.add_sub_for_tests({stream_id: 44, name: "devel", subscribed: true});+ stream_data.add_sub_for_tests({stream_id: 77, name: "office", subscribed: true});override(narrow_state, "stream_id", noop);let suggestions = get_suggestions(query);@@ -628,7 +628,7 @@ test("sent_by_me_suggestions", ({override, mock_template}) => {const denmark_id = new_stream_id();const sub = {name: "Denmark", stream_id: denmark_id};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);query = `channel:${denmark_id} topic:Denmark1 sent`;suggestions = get_suggestions(query);expected = [@@ -650,12 +650,12 @@ test("topic_suggestions", ({override, mock_template}) => {override(stream_topic_history_util, "get_server_history", noop);const office_id = new_stream_id();- stream_data.add_sub({stream_id: office_id, name: "office", subscribed: true});+ stream_data.add_sub_for_tests({stream_id: office_id, name: "office", subscribed: true});override(narrow_state, "stream_id", () => office_id);const devel_id = new_stream_id();- stream_data.add_sub({stream_id: devel_id, name: "devel", subscribed: true});- stream_data.add_sub({stream_id: office_id, name: "office", subscribed: true});+ stream_data.add_sub_for_tests({stream_id: devel_id, name: "devel", subscribed: true});+ stream_data.add_sub_for_tests({stream_id: office_id, name: "office", subscribed: true});suggestions = get_suggestions("te");expected = ["te", "dm:[email protected]", "sender:[email protected]", "dm-including:[email protected]"];@@ -776,7 +776,7 @@ test("whitespace_glitch", ({override, mock_template}) => {const query = "channel:office "; // note trailing spaceoverride(stream_topic_history_util, "get_server_history", noop);- stream_data.add_sub({stream_id: office_stream_id, name: "office", subscribed: true});+ stream_data.add_sub_for_tests({stream_id: office_stream_id, name: "office", subscribed: true});const suggestions = get_suggestions(query);@@ -787,7 +787,7 @@ test("whitespace_glitch", ({override, mock_template}) => {test("xss_channel_name", () => {const stream_id = new_stream_id();- stream_data.add_sub({stream_id, name: "<em> Italics </em>", subscribed: true});+ stream_data.add_sub_for_tests({stream_id, name: "<em> Italics </em>", subscribed: true});const query = "channel:ita";const suggestions = get_suggestions(query);@@ -799,9 +799,13 @@ test("xss_channel_name", () => {test("channel_completion", ({override}) => {const office_stream_id = new_stream_id();- stream_data.add_sub({stream_id: office_stream_id, name: "office", subscribed: true});+ stream_data.add_sub_for_tests({stream_id: office_stream_id, name: "office", subscribed: true});const dev_help_stream_id = new_stream_id();- stream_data.add_sub({stream_id: dev_help_stream_id, name: "dev help", subscribed: true});+ stream_data.add_sub_for_tests({+ stream_id: dev_help_stream_id,+ name: "dev help",+ subscribed: true,+ });override(narrow_state, "stream_id", noop);@@ -982,9 +986,9 @@ test("operator_suggestions", ({override, mock_template}) => {test("queries_with_spaces", () => {const office_id = new_stream_id();- stream_data.add_sub({stream_id: office_id, name: "office", subscribed: true});+ stream_data.add_sub_for_tests({stream_id: office_id, name: "office", subscribed: true});const dev_help_id = new_stream_id();- stream_data.add_sub({stream_id: dev_help_id, name: "dev help", subscribed: true});+ stream_data.add_sub_for_tests({stream_id: dev_help_id, name: "dev help", subscribed: true});// test allowing spaces with quotes surrounding operandlet query = 'channel:"dev he"';diff --git a/web/tests/settings_user_topics.test.cjs b/web/tests/settings_user_topics.test.cjsindex 38c8280d6eb..570715c37ed 100644--- a/web/tests/settings_user_topics.test.cjs+++ b/web/tests/settings_user_topics.test.cjs@@ -19,7 +19,7 @@ const frontend = {stream_id: 101,name: "frontend",};-stream_data.add_sub(frontend);+stream_data.add_sub_for_tests(frontend);run_test("settings", ({override, override_rewire}) => {user_topics.update_user_topics(diff --git a/web/tests/stream_data.test.cjs b/web/tests/stream_data.test.cjsindex d4e173b870c..995b3ef75e3 100644--- a/web/tests/stream_data.test.cjs+++ b/web/tests/stream_data.test.cjs@@ -182,11 +182,11 @@ test("basics", () => {can_administer_channel_group: admins_group.id,can_subscribe_group: admins_group.id,};- stream_data.add_sub(denmark);- stream_data.add_sub(social);- stream_data.add_sub(web_public_stream);+ stream_data.add_sub_for_tests(denmark);+ stream_data.add_sub_for_tests(social);+ stream_data.add_sub_for_tests(web_public_stream);assert.ok(stream_data.all_subscribed_streams_are_in_home_view());- stream_data.add_sub(test);+ stream_data.add_sub_for_tests(test);assert.ok(!stream_data.all_subscribed_streams_are_in_home_view());assert.equal(stream_data.get_sub("denmark"), denmark);@@ -273,7 +273,7 @@ test("basics", () => {history_public_to_subscribers: true,is_web_public: false,};- stream_data.add_sub(stream_starting_with_25);+ stream_data.add_sub_for_tests(stream_starting_with_25);assert.equal(stream_data.slug_to_stream_id("25-or-6-to-4"), 400);assert.equal(hash_util.decode_operand("channel", "25-or-6-to-4"), "400");@@ -290,7 +290,7 @@ test("basics", () => {can_administer_channel_group: admins_group.id,can_subscribe_group: admins_group.id,};- stream_data.add_sub(stream_99);+ stream_data.add_sub_for_tests(stream_99);assert.equal(stream_data.slug_to_stream_id("99"), 401);assert.equal(hash_util.decode_operand("channel", "99"), "401");// But if there's a stream with id 99, it gets priority over@@ -302,7 +302,7 @@ test("basics", () => {can_administer_channel_group: admins_group.id,can_subscribe_group: admins_group.id,};- stream_data.add_sub(stream_id_99);+ stream_data.add_sub_for_tests(stream_id_99);assert.equal(stream_data.slug_to_stream_id("99"), 99);assert.equal(hash_util.decode_operand("channel", "99"), "99");@@ -582,7 +582,7 @@ test("get_streams_for_user", ({override}) => {};const subs = [denmark, social, test, world, errors];for (const sub of subs) {- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);}override(current_user, "user_id", me.user_id);@@ -632,7 +632,7 @@ test("renames", () => {color: "red",stream_id: id,};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);sub = stream_data.get_sub("Denmark");assert.equal(sub.color, "red");sub = sub_store.get(id);@@ -671,7 +671,7 @@ test("admin_options", ({override}) => {date_created: 1691057093,creator_id: null,};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);return sub;}@@ -806,9 +806,9 @@ test("stream_settings", ({override}) => {creator_id: null,is_archived: true,};- stream_data.add_sub(cinnamon);- stream_data.add_sub(amber);- stream_data.add_sub(blue);+ stream_data.add_sub_for_tests(cinnamon);+ stream_data.add_sub_for_tests(amber);+ stream_data.add_sub_for_tests(blue);let sub_rows = stream_settings_data.get_streams_for_settings_page();assert.equal(sub_rows[0].color, "blue");@@ -896,10 +896,10 @@ test("default_stream_names", () => {};stream_data.set_realm_default_streams([announce.stream_id, general.stream_id]);- stream_data.add_sub(announce);- stream_data.add_sub(public_stream);- stream_data.add_sub(private_stream);- stream_data.add_sub(general);+ stream_data.add_sub_for_tests(announce);+ stream_data.add_sub_for_tests(public_stream);+ stream_data.add_sub_for_tests(private_stream);+ stream_data.add_sub_for_tests(general);const names = stream_data.get_non_default_stream_names();assert.deepEqual(names.sort(), [{name: "public", unique_id: 102}]);@@ -915,7 +915,7 @@ test("delete_sub", () => {subscribed: true,};- stream_data.add_sub(canada);+ stream_data.add_sub_for_tests(canada);assert.ok(stream_data.is_subscribed(canada.stream_id));assert.equal(stream_data.get_sub("Canada").stream_id, canada.stream_id);@@ -938,7 +938,7 @@ test("mark_archived", () => {subscribed: true,};- stream_data.add_sub(canada);+ stream_data.add_sub_for_tests(canada);const num_subscribed_subs = stream_data.num_subscribed_subs();const archived_subs = stream_data.get_archived_subs();@@ -967,7 +967,7 @@ test("mark_unarchived", () => {subscribed: true,};- stream_data.add_sub(canada);+ stream_data.add_sub_for_tests(canada);assert.ok(stream_data.is_stream_archived_by_id(canada.stream_id));assert.ok(stream_data.is_subscribed(canada.stream_id));@@ -996,7 +996,7 @@ test("notifications", ({override}) => {push_notifications: null,wildcard_mentions_notify: null,};- stream_data.add_sub(india);+ stream_data.add_sub_for_tests(india);assert.ok(!stream_data.receives_notifications(india.stream_id, "desktop_notifications"));assert.ok(!stream_data.receives_notifications(india.stream_id, "audible_notifications"));@@ -1066,7 +1066,7 @@ test("notifications", ({override}) => {push_notifications: null,wildcard_mentions_notify: null,};- stream_data.add_sub(canada);+ stream_data.add_sub_for_tests(canada);const antarctica = {stream_id: 104,@@ -1078,7 +1078,7 @@ test("notifications", ({override}) => {push_notifications: null,wildcard_mentions_notify: null,};- stream_data.add_sub(antarctica);+ stream_data.add_sub_for_tests(antarctica);override(user_settings, "enable_stream_desktop_notifications", true);override(user_settings, "enable_stream_audible_notifications", true);@@ -1154,8 +1154,8 @@ const jazy = {};test("is_new_stream_announcements_stream_muted", ({override}) => {- stream_data.add_sub(tony);- stream_data.add_sub(jazy);+ stream_data.add_sub_for_tests(tony);+ stream_data.add_sub_for_tests(jazy);override(realm, "realm_new_stream_announcements_stream_id", tony.stream_id);assert.ok(!stream_data.is_new_stream_announcements_stream_muted());@@ -1201,10 +1201,10 @@ test("muted_stream_ids", () => {history_public_to_subscribers: true,is_web_public: true,};- stream_data.add_sub(denmark);- stream_data.add_sub(social);- stream_data.add_sub(test);- stream_data.add_sub(web_public_stream);+ stream_data.add_sub_for_tests(denmark);+ stream_data.add_sub_for_tests(social);+ stream_data.add_sub_for_tests(test);+ stream_data.add_sub_for_tests(web_public_stream);assert.deepEqual(stream_data.muted_stream_ids(), [1, 3]);});@@ -1224,7 +1224,7 @@ test("remove_default_stream", () => {is_muted: true,};- stream_data.add_sub(remove_me);+ stream_data.add_sub_for_tests(remove_me);stream_data.set_realm_default_streams([remove_me.stream_id]);stream_data.remove_default_stream(remove_me.stream_id);assert.ok(!stream_data.is_default_stream_id(remove_me.stream_id));@@ -1358,7 +1358,7 @@ test("initialize", ({override}) => {stream_id: 89,};- stream_data.add_sub(foo);+ stream_data.add_sub_for_tests(foo);initialize();assert.equal(stream_data.get_new_stream_announcements_stream(), "foo");});@@ -1389,7 +1389,7 @@ test("get_invite_stream_data", ({override}) => {override(current_user, "user_id", me.user_id);override(current_user, "is_admin", true);- stream_data.add_sub(orie);+ stream_data.add_sub_for_tests(orie);stream_data.set_realm_default_streams([orie.stream_id]);override(realm, "realm_can_add_subscribers_group", everyone_group.id);@@ -1418,7 +1418,7 @@ test("get_invite_stream_data", ({override}) => {can_add_subscribers_group: nobody_group.id,can_subscribe_group: nobody_group.id,};- stream_data.add_sub(inviter);+ stream_data.add_sub_for_tests(inviter);expected_list.push({name: "Inviter",@@ -1444,7 +1444,7 @@ test("get_invite_stream_data", ({override}) => {can_subscribe_group: nobody_group.id,};- stream_data.add_sub(tokyo);+ stream_data.add_sub_for_tests(tokyo);assert.deepEqual(stream_data.get_invite_stream_data(), expected_list);const random = {@@ -1458,7 +1458,7 @@ test("get_invite_stream_data", ({override}) => {can_subscribe_group: nobody_group.id,};- stream_data.add_sub(random);+ stream_data.add_sub_for_tests(random);expected_list.push({name: "Random",@@ -1606,7 +1606,7 @@ test("can_resolve_topics", ({override}) => {stream_id: 1,can_resolve_topics_group: admins_group.id,};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);assert.equal(stream_data.can_resolve_topics(undefined), false);initialize_and_override_current_user(admin_user_id, override);@@ -1643,7 +1643,7 @@ test("can_unsubscribe_others", ({override}) => {can_add_subscribers_group: nobody_group.id,can_subscribe_group: nobody_group.id,};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);initialize_and_override_current_user(admin_user_id, override);assert.equal(stream_data.can_unsubscribe_others(sub), true);@@ -1706,7 +1706,7 @@ test("can_subscribe_others", ({override}) => {can_administer_channel_group: nobody_group.id,can_remove_subscribers_group: admins_group.id,};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);initialize_and_override_current_user(admin_user_id, override);assert.equal(stream_data.can_subscribe_others(sub), true);@@ -1775,7 +1775,7 @@ test("user_can_set_topics_policy", ({override}) => {can_administer_channel_group: nobody_group.id,can_remove_subscribers_group: admins_group.id,};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);override(realm, "realm_can_set_topics_policy_group", nobody_group.id);// Admins can always change per-channel topics policy.@@ -1810,7 +1810,7 @@ test("user_can_set_delete_message_policy", ({override}) => {can_administer_channel_group: nobody_group.id,can_remove_subscribers_group: admins_group.id,};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);override(realm, "realm_can_set_delete_message_policy_group", nobody_group.id);// Admins can always change per-channel delete_message policy.@@ -1872,10 +1872,10 @@ test("options for dropdown widget", () => {history_public_to_subscribers: true,is_web_public: true,};- stream_data.add_sub(denmark);- stream_data.add_sub(social);- stream_data.add_sub(web_public_stream);- stream_data.add_sub(test);+ stream_data.add_sub_for_tests(denmark);+ stream_data.add_sub_for_tests(social);+ stream_data.add_sub_for_tests(web_public_stream);+ stream_data.add_sub_for_tests(test);assert.deepEqual(stream_data.get_options_for_dropdown_widget(), [{@@ -2262,7 +2262,7 @@ run_test("is_empty_topic_only_channel", ({override}) => {stream_id: 2,topics_policy: "empty_topic_only",};- stream_data.add_sub(social);+ stream_data.add_sub_for_tests(social);const scotland = {subscribed: true,color: "red",@@ -2273,7 +2273,7 @@ run_test("is_empty_topic_only_channel", ({override}) => {override(realm, "realm_topics_policy", "allow_empty_topic");assert.equal(stream_data.is_empty_topic_only_channel(undefined), false);- stream_data.add_sub(scotland);+ stream_data.add_sub_for_tests(scotland);override(current_user, "user_id", me.user_id);override(current_user, "is_admin", true);diff --git a/web/tests/stream_events.test.cjs b/web/tests/stream_events.test.cjsindex ce4dfc7b43f..004b33878a4 100644--- a/web/tests/stream_events.test.cjs+++ b/web/tests/stream_events.test.cjs@@ -131,7 +131,7 @@ test("update_property", ({override}) => {);override(user_group_edit, "update_stream_setting_in_permissions_panel", noop);const sub = {...frontend};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);const stream_id = sub.stream_id;@@ -445,7 +445,7 @@ test("marked_(un)subscribed (early return)", () => {test("marked_subscribed (normal)", ({override}) => {const sub = {...frontend};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);override(stream_color_events, "update_stream_color", noop);override(buddy_list, "populate", noop);activity_ui.set_cursor_and_filter();@@ -496,7 +496,7 @@ test("marked_subscribed (color)", ({override}) => {is_muted: true,invite_only: false,};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);override(color_data, "pick_color", () => "green");override(user_profile, "update_user_profile_streams_list_for_users", noop);@@ -519,7 +519,7 @@ test("marked_subscribed (color)", ({override}) => {test("marked_subscribed (emails)", ({override}) => {const sub = {...frontend};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);override(stream_color_events, "update_stream_color", noop);// Test assigning subscriber emails@@ -548,7 +548,7 @@ test("marked_subscribed (emails)", ({override}) => {test("mark_unsubscribed (update_settings_for_unsubscribed)", ({override}) => {// Test unsubscribeconst sub = {...dev_help};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);stream_data.subscribe_myself(sub);const stub = make_stub();@@ -568,7 +568,7 @@ test("mark_unsubscribed (update_settings_for_unsubscribed)", ({override}) => {test("mark_unsubscribed (render_title_area)", ({override}) => {const sub = {...frontend, subscribed: true};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);// Test update bookend and remove done eventnarrow_to_frontend();@@ -597,7 +597,7 @@ test("mark_unsubscribed (render_title_area)", ({override}) => {});test("remove_deactivated_user_from_all_streams", () => {- stream_data.add_sub(dev_help);+ stream_data.add_sub_for_tests(dev_help);const subs_stub = make_stub();stream_settings_ui.update_subscribers_ui = subs_stub.f;@@ -627,15 +627,15 @@ test("process_subscriber_update", ({override, override_rewire}) => {const userIds = [104, 2, 3];// Sample stream IDsconst streamIds = [1, 2, 3];- stream_data.add_sub({+ stream_data.add_sub_for_tests({stream_id: 1,name: "Rome",});- stream_data.add_sub({+ stream_data.add_sub_for_tests({stream_id: 2,name: "Denmark",});- stream_data.add_sub({+ stream_data.add_sub_for_tests({stream_id: 3,name: "Paris",});@@ -657,7 +657,7 @@ test("process_subscriber_update", ({override, override_rewire}) => {test("marked_subscribed (new channel creation)", ({override}) => {stream_create.set_name(frontend.name);const sub = {...frontend};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);const go_to_location_stub = make_stub();override(browser_history, "go_to_location", go_to_location_stub.f);diff --git a/web/tests/stream_list.test.cjs b/web/tests/stream_list.test.cjsindex 4187fddb0f5..4fb6275189c 100644--- a/web/tests/stream_list.test.cjs+++ b/web/tests/stream_list.test.cjs@@ -180,8 +180,8 @@ test_ui("create_sidebar_row", ({override, override_rewire, mock_template}) => {normal_streams.push(stream);};- stream_data.add_sub(devel);- stream_data.add_sub(social);+ stream_data.add_sub_for_tests(devel);+ stream_data.add_sub_for_tests(social);create_devel_sidebar_row({mock_template});create_social_sidebar_row({mock_template});@@ -249,8 +249,8 @@ test_ui("pinned_streams_never_inactive", ({mock_template, override_rewire}) => {override_rewire(stream_list, "update_dom_with_unread_counts", noop);override_rewire(left_sidebar_navigation_area, "update_dom_with_unread_counts", noop);- stream_data.add_sub(devel);- stream_data.add_sub(social);+ stream_data.add_sub_for_tests(devel);+ stream_data.add_sub_for_tests(social);create_devel_sidebar_row({mock_template});create_social_sidebar_row({mock_template});@@ -285,7 +285,7 @@ test_ui("pinned_streams_never_inactive", ({mock_template, override_rewire}) => {});function add_row(sub) {- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);const row = {update_whether_active() {},get_li() {@@ -666,7 +666,7 @@ test_ui("refresh_pin", ({override_rewire, mock_template}) => {can_send_message_group: everyone_group.id,};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);// We need to populate current_sections; unclear if this is the best way.// stream_list.build_stream_list();diff --git a/web/tests/stream_list_sort.test.cjs b/web/tests/stream_list_sort.test.cjsindex 0123d2fd7ae..624b6d6c3da 100644--- a/web/tests/stream_list_sort.test.cjs+++ b/web/tests/stream_list_sort.test.cjs@@ -129,15 +129,15 @@ channel_folders.initialize({});function add_all_subs() {- stream_data.add_sub(scalene);- stream_data.add_sub(fast_tortoise);- stream_data.add_sub(pneumonia);- stream_data.add_sub(clarinet);- stream_data.add_sub(weaving);- stream_data.add_sub(stream_hyphen_underscore_slash_colon);- stream_data.add_sub(muted_active);- stream_data.add_sub(muted_pinned);- stream_data.add_sub(archived);+ stream_data.add_sub_for_tests(scalene);+ stream_data.add_sub_for_tests(fast_tortoise);+ stream_data.add_sub_for_tests(pneumonia);+ stream_data.add_sub_for_tests(clarinet);+ stream_data.add_sub_for_tests(weaving);+ stream_data.add_sub_for_tests(stream_hyphen_underscore_slash_colon);+ stream_data.add_sub_for_tests(muted_active);+ stream_data.add_sub_for_tests(muted_pinned);+ stream_data.add_sub_for_tests(archived);}function sort_groups(query) {@@ -426,7 +426,7 @@ test("filter inactives", ({override}) => {newly_subscribed: false,stream_id,};- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);});stream_list_sort.set_filter_out_inactives();diff --git a/web/tests/stream_pill.test.cjs b/web/tests/stream_pill.test.cjsindex ca0a81108b9..2a3e4e1bb82 100644--- a/web/tests/stream_pill.test.cjs+++ b/web/tests/stream_pill.test.cjs@@ -80,7 +80,7 @@ const sweden_pill = {const subs = [denmark, sweden, germany];for (const sub of subs) {- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);}peer_data.set_subscribers(denmark.stream_id, [1, 2, 77]);diff --git a/web/tests/stream_topic_history.test.cjs b/web/tests/stream_topic_history.test.cjsindex e01996e8a73..3ffda6fd306 100644--- a/web/tests/stream_topic_history.test.cjs+++ b/web/tests/stream_topic_history.test.cjs@@ -135,7 +135,7 @@ test("server_history", () => {stream_id: 66,};const stream_id = sub.stream_id;- stream_data.add_sub(sub);+ stream_data.add_sub_for_tests(sub);assert.equal(topic_list.is_full_topic_history_available(stream_id), false);diff --git a/web/tests/topic_link_util.test.cjs b/web/tests/topic_link_util.test.cjsindex 54924327937..1b6353092a8 100644--- a/web/tests/topic_link_util.test.cjs+++ b/web/tests/topic_link_util.test.cjs@@ -49,10 +49,10 @@ const markdown_stream = {type: "stream",};-stream_data.add_sub(sweden_stream);-stream_data.add_sub(denmark_stream);-stream_data.add_sub(dollar_stream);-stream_data.add_sub(markdown_stream);+stream_data.add_sub_for_tests(sweden_stream);+stream_data.add_sub_for_tests(denmark_stream);+stream_data.add_sub_for_tests(dollar_stream);+stream_data.add_sub_for_tests(markdown_stream);run_test("stream_link_syntax_test", () => {assert.equal(topic_link_util.get_stream_link_syntax("Sweden"), "#**Sweden**");diff --git a/web/tests/topic_list_data.test.cjs b/web/tests/topic_list_data.test.cjsindex 214eb5bed92..5965c31ec2c 100644--- a/web/tests/topic_list_data.test.cjs+++ b/web/tests/topic_list_data.test.cjs@@ -47,7 +47,7 @@ const general = {name: "general",};-stream_data.add_sub(general);+stream_data.add_sub_for_tests(general);function get_list_info(zoom, search) {const stream_id = general.stream_id;diff --git a/web/tests/transmit.test.cjs b/web/tests/transmit.test.cjsindex 756c97a907b..09af8a1d5ac 100644--- a/web/tests/transmit.test.cjs+++ b/web/tests/transmit.test.cjs@@ -133,7 +133,7 @@ run_test("topic wildcard mention not allowed", ({override}) => {run_test("reply_message_stream", ({override}) => {const social_stream_id = 555;- stream_data.add_sub({+ stream_data.add_sub_for_tests({name: "social",stream_id: social_stream_id,});diff --git a/web/tests/typeahead_helper.test.cjs b/web/tests/typeahead_helper.test.cjsindex 4d12c0f16ed..886f56eb505 100644--- a/web/tests/typeahead_helper.test.cjs+++ b/web/tests/typeahead_helper.test.cjs@@ -139,8 +139,8 @@ const linux_sub = {stream_id: 2,};stream_data.create_streams([dev_sub, linux_sub]);-stream_data.add_sub(dev_sub);-stream_data.add_sub(linux_sub);+stream_data.add_sub_for_tests(dev_sub);+stream_data.add_sub_for_tests(linux_sub);const bob_system_group = make_user_group({id: 1,diff --git a/web/tests/unread.test.cjs b/web/tests/unread.test.cjsindex c45ac075d2b..01d4b52d25d 100644--- a/web/tests/unread.test.cjs+++ b/web/tests/unread.test.cjs@@ -41,7 +41,7 @@ const social = {subscribed: true,is_muted: false,};-stream_data.add_sub(social);+stream_data.add_sub_for_tests(social);function assert_zero_counts(counts) {assert.equal(counts.direct_message_count, 0);diff --git a/web/tests/user_search.test.cjs b/web/tests/user_search.test.cjsindex a371627f99c..ffc905af4b3 100644--- a/web/tests/user_search.test.cjs+++ b/web/tests/user_search.test.cjs@@ -148,7 +148,7 @@ test("fetch on search", async ({override}) => {stub_buddy_list_empty_list_message_lengths();const office = {stream_id: 23, name: "office", subscribed: true};- stream_data.add_sub(office);+ stream_data.add_sub_for_tests(office);message_lists.set_current(make_message_list([{operator: "stream", operand: office.stream_id}]));let get_call_count = 0;channel.get = () => {@@ -170,9 +170,9 @@ test("fetch on search", async ({override}) => {get_call_count = 0;populate_call_count = 0;const kitchen = {stream_id: 25, name: "kitchen", subscribed: true};- stream_data.add_sub(kitchen);+ stream_data.add_sub_for_tests(kitchen);const living_room = {stream_id: 26, name: "living_room", subscribed: true};- stream_data.add_sub(living_room);+ stream_data.add_sub_for_tests(living_room);message_lists.set_current(make_message_list([{operator: "stream", operand: kitchen.stream_id}]),);diff --git a/web/tests/user_topics.test.cjs b/web/tests/user_topics.test.cjsindex fd9b5304bfd..4d5eb42ff7a 100644--- a/web/tests/user_topics.test.cjs+++ b/web/tests/user_topics.test.cjs@@ -39,10 +39,10 @@ const unknown = {name: "whatever",};-stream_data.add_sub(design);-stream_data.add_sub(devel);-stream_data.add_sub(office);-stream_data.add_sub(social);+stream_data.add_sub_for_tests(design);+stream_data.add_sub_for_tests(devel);+stream_data.add_sub_for_tests(office);+stream_data.add_sub_for_tests(social);function test(label, f) {run_test(label, ({override}) => {diff --git a/web/tests/user_topics_ui.test.cjs b/web/tests/user_topics_ui.test.cjsindex 395f502460c..50c3a1f5fb7 100644--- a/web/tests/user_topics_ui.test.cjs+++ b/web/tests/user_topics_ui.test.cjs@@ -17,7 +17,7 @@ const design = {is_muted: false,};-stream_data.add_sub(design);+stream_data.add_sub_for_tests(design);function test(label, f) {run_test(label, (helpers) => {