mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 21:43:21 +00:00
page_params: Split out state data for realm.
For spectators, the chunk of page_params that originates from do_events_register isn’t assigned until ui_init.js. That means the TypeScript type of page_params is mostly a lie during module load time: reading a parameter too early silently results in undefined rather than the declared type, with unpredictable results later on. We want to make such an early read into an immediate runtime error, for both users and spectators consistently, and pave the way for runtime validation of the page_params type. As a second step, split out the subset of fields that pertain to the entire realm. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
e96ede0ef6
commit
b9e62c7af8
@@ -8,7 +8,7 @@ const {mock_esm, with_overrides, zrequire} = require("./lib/namespace");
|
||||
const {run_test} = require("./lib/test");
|
||||
const blueslip = require("./lib/zblueslip");
|
||||
const $ = require("./lib/zjquery");
|
||||
const {page_params} = require("./lib/zpage_params");
|
||||
const {page_params, realm} = require("./lib/zpage_params");
|
||||
|
||||
const message_store = mock_esm("../src/message_store");
|
||||
|
||||
@@ -979,7 +979,7 @@ function test_mit_exceptions() {
|
||||
}
|
||||
|
||||
test("mit_exceptions", ({override}) => {
|
||||
override(page_params, "realm_is_zephyr_mirror_realm", true);
|
||||
override(realm, "realm_is_zephyr_mirror_realm", true);
|
||||
test_mit_exceptions();
|
||||
});
|
||||
|
||||
@@ -1757,7 +1757,7 @@ test("navbar_helpers", () => {
|
||||
},
|
||||
];
|
||||
|
||||
page_params.realm_enable_guest_user_indicator = true;
|
||||
realm.realm_enable_guest_user_indicator = true;
|
||||
|
||||
for (const test_case of test_cases) {
|
||||
test_helpers(test_case);
|
||||
@@ -1812,7 +1812,7 @@ test("navbar_helpers", () => {
|
||||
|
||||
test_get_title(stream_topic_search_term_test_case);
|
||||
|
||||
page_params.realm_enable_guest_user_indicator = false;
|
||||
realm.realm_enable_guest_user_indicator = false;
|
||||
const guest_user_test_cases_without_indicator = [
|
||||
{
|
||||
terms: guest_sender,
|
||||
|
||||
Reference in New Issue
Block a user