snapshot of https://github.com/zulip/zulip.git @ 48c69911c7dd4e03b20552eb3bd77ad8151c1357 (2026-09-15)
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
This commit is contained in:
82
web/tests/compose_call_session.test.cjs
Normal file
82
web/tests/compose_call_session.test.cjs
Normal file
@@ -0,0 +1,82 @@
|
||||
"use strict";
|
||||
|
||||
const assert = require("node:assert/strict");
|
||||
|
||||
const {zrequire} = require("./lib/namespace.cjs");
|
||||
const {run_test} = require("./lib/test.cjs");
|
||||
|
||||
const compose_call_session = zrequire("compose_call_session");
|
||||
|
||||
run_test("ComposeCallSession", () => {
|
||||
const session_manager = compose_call_session.compose_call_session_manager;
|
||||
const session = session_manager.get_compose_call_session("key");
|
||||
const session_returned = session_manager.get_compose_call_session("key");
|
||||
assert.equal(session, session_returned);
|
||||
|
||||
const xhr1 = {};
|
||||
const xhr2 = {};
|
||||
|
||||
session.append_pending_xhr(xhr1);
|
||||
session.append_pending_xhr(xhr2);
|
||||
|
||||
let callback_ran = false;
|
||||
const callback = () => {
|
||||
callback_ran = true;
|
||||
};
|
||||
|
||||
session.maybe_run_xhr_callback(xhr1, callback);
|
||||
assert.ok(callback_ran);
|
||||
|
||||
/* istanbul ignore next */
|
||||
session.maybe_run_xhr_callback(xhr1, () => {
|
||||
throw new Error("XHR callback should only run once");
|
||||
});
|
||||
|
||||
session.abort_pending_xhr(xhr2);
|
||||
/* istanbul ignore next */
|
||||
session.maybe_run_xhr_callback(xhr2, () => {
|
||||
throw new Error("Callbacks shouldn't run for aborted XHRs.");
|
||||
});
|
||||
|
||||
// Token callbacks for a provider.
|
||||
let callback_ran_for_zoom_token1 = false;
|
||||
let callback_ran_for_zoom_token2 = false;
|
||||
|
||||
const session1 = session_manager.get_compose_call_session("key1");
|
||||
const session2 = session_manager.get_compose_call_session("key2");
|
||||
const zoom_token_callback1 = () => {
|
||||
callback_ran_for_zoom_token1 = true;
|
||||
};
|
||||
const zoom_token_callback2 = () => {
|
||||
callback_ran_for_zoom_token2 = true;
|
||||
};
|
||||
session1.add_oauth_token_callback("zoom", zoom_token_callback1);
|
||||
session2.add_oauth_token_callback("zoom", zoom_token_callback2);
|
||||
|
||||
session_manager.run_and_clear_callbacks_for_provider("zoom");
|
||||
assert.ok(callback_ran_for_zoom_token1);
|
||||
assert.ok(callback_ran_for_zoom_token2);
|
||||
|
||||
// All callbacks associated with a session be abandoned on calling
|
||||
// ComposeCallSession.abandon_everything.
|
||||
const session3 = session_manager.get_compose_call_session("key3");
|
||||
const xhr_obj = {};
|
||||
/* istanbul ignore next */
|
||||
session3.add_oauth_token_callback("zoom", () => {
|
||||
throw new Error("Token callbacks shouldn't run after abandon_everything");
|
||||
});
|
||||
|
||||
/* istanbul ignore next */
|
||||
session3.append_pending_xhr(xhr_obj, () => {
|
||||
throw new Error("XHR callbacks shouldn't run after abandon_everything");
|
||||
});
|
||||
session_manager.abandon_session("key3");
|
||||
|
||||
session3.maybe_run_xhr_callback(xhr_obj);
|
||||
session3.run_and_delete_callback_for_provider("zoom");
|
||||
|
||||
/* istanbul ignore next */
|
||||
session3.maybe_run_xhr_callback(undefined, () => {
|
||||
throw new Error("callbacks shouldn't run for undefined XHR objects");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user