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:
91
web/tests/reload.test.cjs
Normal file
91
web/tests/reload.test.cjs
Normal file
@@ -0,0 +1,91 @@
|
||||
"use strict";
|
||||
|
||||
const assert = require("node:assert/strict");
|
||||
|
||||
const {mock_esm, set_global, zrequire} = require("./lib/namespace.cjs");
|
||||
const {run_test, noop} = require("./lib/test.cjs");
|
||||
const {$} = require("./lib/zjquery.cjs");
|
||||
|
||||
const channel = mock_esm("../src/channel");
|
||||
mock_esm("../src/popup_banners", {
|
||||
open_reloading_application_banner: noop,
|
||||
});
|
||||
|
||||
// override file-level function call in reload.ts
|
||||
window.addEventListener = noop;
|
||||
const reload = zrequire("reload");
|
||||
const reload_state = zrequire("reload_state");
|
||||
|
||||
set_global("window", {
|
||||
to_$: () => $("window-stub"),
|
||||
location: {
|
||||
href: "http://zulip.zulipdev.com/#",
|
||||
reload: noop,
|
||||
replace: noop,
|
||||
},
|
||||
});
|
||||
|
||||
run_test("old_metadata_string_is_stale", () => {
|
||||
assert.ok(reload.is_stale_refresh_token({reload_data: {hash: ""}}, Date.now()), true);
|
||||
});
|
||||
|
||||
run_test("recent_token_is_not_stale ", () => {
|
||||
assert.ok(
|
||||
!reload.is_stale_refresh_token(
|
||||
{
|
||||
hash: "",
|
||||
timestamp: Date.parse("21 Jan 2022 00:00:00 GMT"),
|
||||
},
|
||||
Date.parse("23 Jan 2022 00:00:00 GMT"),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
run_test("old_token_is_stale ", () => {
|
||||
assert.ok(
|
||||
reload.is_stale_refresh_token(
|
||||
{
|
||||
hash: "",
|
||||
timestamp: Date.parse("13 Jan 2022 00:00:00 GMT"),
|
||||
},
|
||||
Date.parse("23 Jan 2022 00:00:00 GMT"),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
run_test("reload", () => {
|
||||
channel.get = (opts) => {
|
||||
assert.equal(opts.url, "/compatibility");
|
||||
opts.success();
|
||||
};
|
||||
|
||||
// No reload has been initiated so "maybe_reload_*" shouldn't
|
||||
// do anything
|
||||
reload.maybe_reset_pending_reload_timeout("compose_start");
|
||||
assert.equal(reload.reset_reload_timeout, undefined);
|
||||
|
||||
reload.maybe_reset_pending_reload_timeout("compose_end");
|
||||
assert.equal(reload.reset_reload_timeout, undefined);
|
||||
|
||||
// Initiate reload should create a new timeout and creates
|
||||
// reset_reload_timeout
|
||||
reload.initiate({});
|
||||
assert.equal(typeof reload.reset_reload_timeout, "function");
|
||||
|
||||
reload.maybe_reset_pending_reload_timeout("compose_start");
|
||||
|
||||
reload.maybe_reset_pending_reload_timeout("compose_end");
|
||||
});
|
||||
|
||||
run_test("immediate_reload_skips_compatibility_check", () => {
|
||||
reload_state.clear_for_testing();
|
||||
|
||||
// do_reload_app should run synchronously without the /compatibility
|
||||
// check, so channel.get should not be called. Setting it to
|
||||
// undefined ensures a clear error if it is called unexpectedly.
|
||||
channel.get = undefined;
|
||||
|
||||
reload.initiate({immediate: true, save_compose: true});
|
||||
|
||||
assert.ok(reload_state.is_in_progress());
|
||||
});
|
||||
Reference in New Issue
Block a user