Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

node tests: Add activity.clear_for_testing().

Steve Howelleb46ac408d1d
diff --git a/frontend_tests/node_tests/activity.js b/frontend_tests/node_tests/activity.js
index 511916e3e10..d805fbc8de7 100644
--- a/frontend_tests/node_tests/activity.js
+++ b/frontend_tests/node_tests/activity.js
@@ -122,11 +122,16 @@ function test(label, f) {
clear_buddy_list();
muting.set_muted_users([]);
+
+ activity.clear_for_testing();
+ activity.set_cursor_and_filter();
+
f(override);
});
}
-test("reload_defaults", () => {
+run_test("reload_defaults", () => {
+ activity.clear_for_testing();
blueslip.expect("warn", "get_filter_text() is called before initialization");
assert.equal(activity.get_filter_text(), "");
});
@@ -201,8 +206,6 @@ test("huddle_data.process_loaded_messages", () => {
});
test("presence_list_full_update", (override) => {
- activity.set_cursor_and_filter();
-
override(padded_widget, "update_padding", () => {});
$(".user-list-filter").trigger("focus");
@@ -467,8 +470,6 @@ test("insert_unfiltered_user_with_filter", () => {
// This test only tests that we do not explode when
// try to insert Fred into a list where he does not
// match the search filter.
- activity.set_cursor_and_filter();
-
const user_filter = $(".user-list-filter");
user_filter.val("do-not-match-filter");
activity.redraw_user(fred.user_id);
@@ -557,7 +558,10 @@ test("initialize", (override) => {
$(window).off("focus");
activity.initialize();
- payload.success({});
+ payload.success({
+ zephyr_mirror_active: true,
+ presences: {},
+ });
$(window).trigger("focus");
clear();
diff --git a/static/js/activity.js b/static/js/activity.js
index c83159089bf..be21948b970 100644
--- a/static/js/activity.js
+++ b/static/js/activity.js
@@ -76,6 +76,12 @@ export function update_dom_with_unread_counts(counts) {
}
}
+export function clear_for_testing() {
+ user_cursor = undefined;
+ user_filter = undefined;
+ client_is_active = false;
+}
+
export function mark_client_idle() {
// When we become idle, we don't immediately send anything to the
// server; instead, we wait for our next periodic update, since