Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
tests: Remove rewires in stream_events.test.cjs.
Tim Abbott32ed90865a47
diff --git a/web/src/narrow_state.ts b/web/src/narrow_state.tsindex c171461b1fe..164666549cd 100644--- a/web/src/narrow_state.ts+++ b/web/src/narrow_state.ts@@ -127,14 +127,14 @@ export function set_compose_defaults(): {return opts;}-export let stream_id = (+export function stream_id(current_filter: Filter | undefined = filter(),// If true, we'll return undefined if the filter contains a// stream_id, but that stream ID is not present in stream_data// (whether because it's an invalid channel ID, or because the// channel is not accessible to this user).only_valid_id = false,-): number | undefined => {+): number | undefined {if (current_filter === undefined) {return undefined;}@@ -149,10 +149,6 @@ export let stream_id = (}}return undefined;-};--export function rewire_stream_id(value: typeof stream_id): void {- stream_id = value;}export function stream_name(current_filter: Filter | undefined = filter()): string | undefined {diff --git a/web/tests/stream_events.test.cjs b/web/tests/stream_events.test.cjsindex 505cd3d5a2c..3a044dd3cae 100644--- a/web/tests/stream_events.test.cjs+++ b/web/tests/stream_events.test.cjs@@ -58,10 +58,12 @@ const user_group_edit = mock_esm("../src/user_group_edit");const user_profile = mock_esm("../src/user_profile");const {Filter} = zrequire("../src/filter");-const activity_ui = zrequire("activity_ui");-const {buddy_list} = zrequire("buddy_list");+const activity_ui = mock_esm("../src/activity_ui", {+ build_user_sidebar: noop,+ set_cursor_and_filter: noop,+});const compose_state = zrequire("compose_state");-const narrow_state = zrequire("narrow_state");+zrequire("narrow_state");const peer_data = zrequire("peer_data");const people = zrequire("people");const {set_current_user, set_realm} = zrequire("state_data");@@ -470,7 +472,6 @@ test("marked_subscribed (normal)", ({override}) => {const sub = {...frontend};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();narrow_to_frontend();@@ -631,7 +632,6 @@ test("mark_unsubscribed (render_title_area)", ({override}) => {override(unread_ui, "update_unread_counts", noop);override(unread_ui, "hide_unread_banner", noop);override(user_profile, "update_user_profile_streams_list_for_users", noop);- override(buddy_list, "populate", noop);$("#channels_overlay_container .stream-row:not(.notdisplayed)").length = 0;@@ -642,12 +642,12 @@ test("mark_unsubscribed (render_title_area)", ({override}) => {message_lists.current = undefined;});-test("process_subscriber_update", ({override, override_rewire}) => {+test("process_subscriber_update", ({override}) => {const subsStub = make_stub();stream_settings_ui.update_subscribers_ui = subsStub.f;let build_user_sidebar_called = false;- override_rewire(activity_ui, "build_user_sidebar", () => {+ override(activity_ui, "build_user_sidebar", () => {build_user_sidebar_called = true;});override(user_profile, "update_user_profile_streams_list_for_users", noop);@@ -677,9 +677,11 @@ test("process_subscriber_update", ({override, override_rewire}) => {// For a stream the user is currently viewing, we rebuild the user sidebar// when someone subscribes to that stream.- override_rewire(narrow_state, "stream_id", () => 1);+ const filter = new Filter([{operator: "channel", operand: "1"}]);+ message_lists.current = {data: {filter}};stream_events.process_subscriber_update(userIds, streamIds);assert.ok(build_user_sidebar_called);+ message_lists.current = undefined;});test("marked_subscribed (new channel creation)", ({override}) => {