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:
77
web/tests/browser_history.test.cjs
Normal file
77
web/tests/browser_history.test.cjs
Normal file
@@ -0,0 +1,77 @@
|
||||
"use strict";
|
||||
|
||||
const assert = require("node:assert/strict");
|
||||
|
||||
const {zrequire} = require("./lib/namespace.cjs");
|
||||
const {run_test} = require("./lib/test.cjs");
|
||||
const blueslip = require("./lib/zblueslip.cjs");
|
||||
|
||||
window.location.hash = "#bogus";
|
||||
|
||||
const browser_history = zrequire("browser_history");
|
||||
const {initialize_user_settings} = zrequire("user_settings");
|
||||
|
||||
const user_settings = {};
|
||||
initialize_user_settings({user_settings});
|
||||
|
||||
function test(label, f) {
|
||||
run_test(label, (helpers) => {
|
||||
helpers.override(user_settings, "web_home_view", "recent");
|
||||
window.location.hash = "#bogus";
|
||||
browser_history.clear_for_testing();
|
||||
f(helpers);
|
||||
});
|
||||
}
|
||||
|
||||
test("basics", () => {
|
||||
const hash1 = "#settings/profile";
|
||||
const hash2 = "#narrow/is/dm";
|
||||
browser_history.go_to_location(hash1);
|
||||
assert.equal(window.location.hash, hash1);
|
||||
|
||||
browser_history.update(hash2);
|
||||
assert.equal(window.location.hash, hash2);
|
||||
assert.equal(browser_history.old_hash(), hash1);
|
||||
|
||||
const was_internal_change = browser_history.save_old_hash();
|
||||
assert.ok(was_internal_change);
|
||||
assert.equal(browser_history.old_hash(), hash2);
|
||||
});
|
||||
|
||||
test("update with same hash", () => {
|
||||
const hash = "#keyboard-shortcuts";
|
||||
|
||||
browser_history.update(hash);
|
||||
assert.equal(window.location.hash, hash);
|
||||
browser_history.update(hash);
|
||||
assert.equal(window.location.hash, hash);
|
||||
});
|
||||
|
||||
test("error for bad hashes", () => {
|
||||
const hash = "bogus";
|
||||
blueslip.expect("error", "programming error: prefix hashes with #");
|
||||
browser_history.update(hash);
|
||||
});
|
||||
|
||||
test("update internal hash if required", () => {
|
||||
const hash = "#test/hash";
|
||||
browser_history.update_hash_internally_if_required(hash);
|
||||
assert.equal(window.location.hash, hash);
|
||||
|
||||
// Calling again with the same hash should be a no-op.
|
||||
// If update() were called, it would log a blueslip.info
|
||||
// for the redundant hash, so verify no new info appeared.
|
||||
const info_count = blueslip.get_test_logs("info").length;
|
||||
browser_history.update_hash_internally_if_required(hash);
|
||||
assert.equal(blueslip.get_test_logs("info").length, info_count);
|
||||
});
|
||||
|
||||
test("web-public view hash restore", () => {
|
||||
browser_history.update("#");
|
||||
assert.equal(window.location.hash, "");
|
||||
const new_hash = "#narrow/is/dm";
|
||||
browser_history.update(new_hash);
|
||||
assert.equal(window.location.hash, new_hash);
|
||||
browser_history.return_to_web_public_hash();
|
||||
assert.equal(window.location.hash, "#recent");
|
||||
});
|
||||
Reference in New Issue
Block a user