Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
node tests: Clear pending channel requests.
Steve Howellab34f63ad572
diff --git a/frontend_tests/node_tests/channel.js b/frontend_tests/node_tests/channel.jsindex b935a705766..9b6e641cb1f 100644--- a/frontend_tests/node_tests/channel.js+++ b/frontend_tests/node_tests/channel.js@@ -280,6 +280,7 @@ run_test("retry", () => {});run_test("too_many_pending", () => {+ channel.clear_for_tests();$.ajax = () => {const xhr = "stub";return xhr;@@ -290,9 +291,10 @@ run_test("too_many_pending", () => {"The length of pending_requests is over 50. " +"Most likely they are not being correctly removed.",);- _.times(50, () => {+ _.times(51, () => {channel.post({});});+ channel.clear_for_tests();});run_test("xhr_error_message", () => {diff --git a/static/js/channel.js b/static/js/channel.jsindex 52964e7c767..52d62deb2ed 100644--- a/static/js/channel.js+++ b/static/js/channel.js@@ -3,6 +3,10 @@ import * as reload_state from "./reload_state";const pending_requests = [];+export function clear_for_tests() {+ pending_requests.length = 0;+}+function add_pending_request(jqXHR) {pending_requests.push(jqXHR);if (pending_requests.length > 50) {