2020-08-01 03:43:15 +02:00
|
|
|
"use strict";
|
|
|
|
|
2020-11-30 23:46:45 +01:00
|
|
|
const {strict: assert} = require("assert");
|
|
|
|
|
2021-06-16 15:58:34 +02:00
|
|
|
const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace");
|
2020-12-01 00:39:47 +01:00
|
|
|
const {run_test} = require("../zjsunit/test");
|
2021-03-16 23:38:59 +01:00
|
|
|
const blueslip = require("../zjsunit/zblueslip");
|
2021-02-21 15:38:51 +01:00
|
|
|
const $ = require("../zjsunit/zjquery");
|
2021-07-28 16:00:58 +02:00
|
|
|
const {user_settings} = require("../zjsunit/zpage_params");
|
2020-12-01 00:02:16 +01:00
|
|
|
|
2021-03-14 11:01:58 +01:00
|
|
|
let window_stub;
|
2020-07-15 01:29:15 +02:00
|
|
|
set_global("to_$", () => window_stub);
|
|
|
|
|
2021-03-10 06:10:32 +01:00
|
|
|
mock_esm("../../static/js/search", {
|
2020-07-03 10:38:24 +02:00
|
|
|
update_button_visibility: () => {},
|
|
|
|
});
|
2020-07-15 01:29:15 +02:00
|
|
|
set_global("document", "document-stub");
|
2021-02-10 04:53:22 +01:00
|
|
|
const history = set_global("history", {});
|
2020-07-15 01:29:15 +02:00
|
|
|
|
2021-03-10 06:10:32 +01:00
|
|
|
const admin = mock_esm("../../static/js/admin");
|
|
|
|
const drafts = mock_esm("../../static/js/drafts");
|
|
|
|
const floating_recipient_bar = mock_esm("../../static/js/floating_recipient_bar");
|
|
|
|
const info_overlay = mock_esm("../../static/js/info_overlay");
|
|
|
|
const message_viewport = mock_esm("../../static/js/message_viewport");
|
2021-05-19 05:34:35 +02:00
|
|
|
const narrow = zrequire("../../static/js/narrow");
|
2021-03-10 06:10:32 +01:00
|
|
|
const overlays = mock_esm("../../static/js/overlays");
|
|
|
|
const settings = mock_esm("../../static/js/settings");
|
2021-07-09 15:51:31 +02:00
|
|
|
const stream_settings_ui = mock_esm("../../static/js/stream_settings_ui");
|
2021-03-10 06:10:32 +01:00
|
|
|
const ui_util = mock_esm("../../static/js/ui_util");
|
2022-02-25 19:27:25 +01:00
|
|
|
const ui_report = mock_esm("../../static/js/ui_report");
|
2021-03-10 06:10:32 +01:00
|
|
|
mock_esm("../../static/js/top_left_corner", {
|
2020-09-20 10:14:24 +02:00
|
|
|
handle_narrow_deactivated: () => {},
|
|
|
|
});
|
2021-03-06 17:37:51 +01:00
|
|
|
set_global("favicon", {});
|
2020-07-15 01:29:15 +02:00
|
|
|
|
2021-03-22 16:09:12 +01:00
|
|
|
const browser_history = zrequire("browser_history");
|
2020-12-01 23:21:38 +01:00
|
|
|
const people = zrequire("people");
|
|
|
|
const hash_util = zrequire("hash_util");
|
|
|
|
const hashchange = zrequire("hashchange");
|
|
|
|
const stream_data = zrequire("stream_data");
|
|
|
|
|
2021-06-10 14:18:46 +02:00
|
|
|
const recent_topics_util = zrequire("recent_topics_util");
|
|
|
|
const recent_topics_ui = zrequire("recent_topics_ui");
|
2020-12-01 23:21:38 +01:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
run_test("operators_round_trip", () => {
|
2019-11-02 00:06:25 +01:00
|
|
|
let operators;
|
|
|
|
let hash;
|
|
|
|
let narrow;
|
2014-02-19 22:19:16 +01:00
|
|
|
|
|
|
|
operators = [
|
2020-07-15 01:29:15 +02:00
|
|
|
{operator: "stream", operand: "devel"},
|
|
|
|
{operator: "topic", operand: "algol"},
|
2014-02-19 22:19:16 +01:00
|
|
|
];
|
2018-08-04 16:33:28 +02:00
|
|
|
hash = hash_util.operators_to_hash(operators);
|
2020-07-15 01:29:15 +02:00
|
|
|
assert.equal(hash, "#narrow/stream/devel/topic/algol");
|
2014-02-19 22:19:16 +01:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
narrow = hash_util.parse_narrow(hash.split("/"));
|
2017-01-05 22:04:33 +01:00
|
|
|
assert.deepEqual(narrow, [
|
2020-07-15 01:29:15 +02:00
|
|
|
{operator: "stream", operand: "devel", negated: false},
|
|
|
|
{operator: "topic", operand: "algol", negated: false},
|
2017-01-05 22:04:33 +01:00
|
|
|
]);
|
|
|
|
|
2014-02-19 22:19:16 +01:00
|
|
|
operators = [
|
2020-07-15 01:29:15 +02:00
|
|
|
{operator: "stream", operand: "devel"},
|
|
|
|
{operator: "topic", operand: "visual c++", negated: true},
|
2014-02-19 22:19:16 +01:00
|
|
|
];
|
2018-08-04 16:33:28 +02:00
|
|
|
hash = hash_util.operators_to_hash(operators);
|
2020-07-15 01:29:15 +02:00
|
|
|
assert.equal(hash, "#narrow/stream/devel/-topic/visual.20c.2B.2B");
|
2017-01-05 22:04:33 +01:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
narrow = hash_util.parse_narrow(hash.split("/"));
|
2017-01-05 22:04:33 +01:00
|
|
|
assert.deepEqual(narrow, [
|
2020-07-15 01:29:15 +02:00
|
|
|
{operator: "stream", operand: "devel", negated: false},
|
|
|
|
{operator: "topic", operand: "visual c++", negated: true},
|
2017-01-05 22:04:33 +01:00
|
|
|
]);
|
|
|
|
|
2018-02-15 21:02:47 +01:00
|
|
|
// test new encodings, where we have a stream id
|
2019-11-02 00:06:25 +01:00
|
|
|
const florida_stream = {
|
2020-07-15 01:29:15 +02:00
|
|
|
name: "Florida, USA",
|
2018-02-15 21:02:47 +01:00
|
|
|
stream_id: 987,
|
|
|
|
};
|
2020-02-09 22:02:55 +01:00
|
|
|
stream_data.add_sub(florida_stream);
|
2020-07-15 00:34:28 +02:00
|
|
|
operators = [{operator: "stream", operand: "Florida, USA"}];
|
2018-08-04 16:33:28 +02:00
|
|
|
hash = hash_util.operators_to_hash(operators);
|
2020-07-15 01:29:15 +02:00
|
|
|
assert.equal(hash, "#narrow/stream/987-Florida.2C-USA");
|
|
|
|
narrow = hash_util.parse_narrow(hash.split("/"));
|
2020-07-15 00:34:28 +02:00
|
|
|
assert.deepEqual(narrow, [{operator: "stream", operand: "Florida, USA", negated: false}]);
|
2018-05-15 15:59:50 +02:00
|
|
|
});
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
run_test("operators_trailing_slash", () => {
|
|
|
|
const hash = "#narrow/stream/devel/topic/algol/";
|
|
|
|
const narrow = hash_util.parse_narrow(hash.split("/"));
|
2018-05-15 15:59:50 +02:00
|
|
|
assert.deepEqual(narrow, [
|
2020-07-15 01:29:15 +02:00
|
|
|
{operator: "stream", operand: "devel", negated: false},
|
|
|
|
{operator: "topic", operand: "algol", negated: false},
|
2018-02-15 21:02:47 +01:00
|
|
|
]);
|
2018-05-15 12:40:07 +02:00
|
|
|
});
|
2017-01-19 03:53:50 +01:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
run_test("people_slugs", () => {
|
2019-11-02 00:06:25 +01:00
|
|
|
let operators;
|
|
|
|
let hash;
|
2017-01-19 03:53:50 +01:00
|
|
|
|
2019-11-02 00:06:25 +01:00
|
|
|
const alice = {
|
2020-07-15 01:29:15 +02:00
|
|
|
email: "alice@example.com",
|
2017-01-19 03:53:50 +01:00
|
|
|
user_id: 42,
|
2020-07-15 01:29:15 +02:00
|
|
|
full_name: "Alice Smith",
|
2017-01-19 03:53:50 +01:00
|
|
|
};
|
|
|
|
|
2020-05-26 22:34:15 +02:00
|
|
|
people.add_active_user(alice);
|
2020-07-15 00:34:28 +02:00
|
|
|
operators = [{operator: "sender", operand: "alice@example.com"}];
|
2018-08-04 16:33:28 +02:00
|
|
|
hash = hash_util.operators_to_hash(operators);
|
2020-07-15 01:29:15 +02:00
|
|
|
assert.equal(hash, "#narrow/sender/42-alice");
|
|
|
|
const narrow = hash_util.parse_narrow(hash.split("/"));
|
2020-07-15 00:34:28 +02:00
|
|
|
assert.deepEqual(narrow, [{operator: "sender", operand: "alice@example.com", negated: false}]);
|
2017-01-19 03:53:50 +01:00
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
operators = [{operator: "pm-with", operand: "alice@example.com"}];
|
2018-08-04 16:33:28 +02:00
|
|
|
hash = hash_util.operators_to_hash(operators);
|
2020-07-15 01:29:15 +02:00
|
|
|
assert.equal(hash, "#narrow/pm-with/42-alice");
|
2018-05-15 12:40:07 +02:00
|
|
|
});
|
2018-04-11 13:14:39 +02:00
|
|
|
|
2022-01-08 10:27:06 +01:00
|
|
|
function test_helper({override, override_rewire, change_tab}) {
|
2019-11-02 00:06:25 +01:00
|
|
|
let events = [];
|
|
|
|
let narrow_terms;
|
2018-04-11 13:14:39 +02:00
|
|
|
|
2021-02-11 01:42:59 +01:00
|
|
|
function stub(module, func_name) {
|
|
|
|
module[func_name] = () => {
|
|
|
|
events.push([module, func_name]);
|
2018-04-11 13:14:39 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-02-11 01:42:59 +01:00
|
|
|
stub(admin, "launch");
|
|
|
|
stub(drafts, "launch");
|
|
|
|
stub(floating_recipient_bar, "update");
|
|
|
|
stub(message_viewport, "stop_auto_scrolling");
|
|
|
|
stub(narrow, "deactivate");
|
|
|
|
stub(overlays, "close_for_hash_change");
|
|
|
|
stub(settings, "launch");
|
2021-07-09 15:51:31 +02:00
|
|
|
stub(stream_settings_ui, "launch");
|
2021-02-11 01:42:59 +01:00
|
|
|
stub(ui_util, "blur_active_element");
|
2022-02-25 19:27:25 +01:00
|
|
|
stub(ui_report, "error");
|
2018-04-11 13:14:39 +02:00
|
|
|
|
2021-03-14 11:01:58 +01:00
|
|
|
if (change_tab) {
|
|
|
|
override(ui_util, "change_tab_to", (hash) => {
|
|
|
|
events.push("change_tab_to " + hash);
|
|
|
|
});
|
2018-04-11 13:14:39 +02:00
|
|
|
|
2022-01-08 10:27:06 +01:00
|
|
|
override_rewire(narrow, "activate", (terms) => {
|
2021-03-14 11:01:58 +01:00
|
|
|
narrow_terms = terms;
|
|
|
|
events.push("narrow.activate");
|
|
|
|
});
|
2018-04-11 13:14:39 +02:00
|
|
|
|
2021-03-14 11:01:58 +01:00
|
|
|
override(info_overlay, "show", (name) => {
|
|
|
|
events.push("info: " + name);
|
|
|
|
});
|
|
|
|
}
|
2018-04-11 13:14:39 +02:00
|
|
|
|
|
|
|
return {
|
|
|
|
clear_events: () => {
|
|
|
|
events = [];
|
|
|
|
},
|
|
|
|
assert_events: (expected_events) => {
|
2021-03-14 11:01:58 +01:00
|
|
|
assert.deepEqual(events, expected_events);
|
2018-04-11 13:14:39 +02:00
|
|
|
},
|
2020-07-02 01:41:40 +02:00
|
|
|
get_narrow_terms: () => narrow_terms,
|
2018-04-11 13:14:39 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-01-08 10:27:06 +01:00
|
|
|
run_test("hash_interactions", ({override, override_rewire}) => {
|
2021-03-14 11:01:58 +01:00
|
|
|
window_stub = $.create("window-stub");
|
2021-07-28 16:00:58 +02:00
|
|
|
user_settings.default_view = "recent_topics";
|
2021-03-14 11:01:58 +01:00
|
|
|
|
2022-01-08 10:27:06 +01:00
|
|
|
override_rewire(recent_topics_util, "is_visible", () => false);
|
|
|
|
const helper = test_helper({override, override_rewire, change_tab: true});
|
2018-04-11 13:14:39 +02:00
|
|
|
|
2021-06-19 06:58:15 +02:00
|
|
|
let recent_topics_ui_shown = false;
|
2022-01-08 10:27:06 +01:00
|
|
|
override_rewire(recent_topics_ui, "show", () => {
|
2021-06-19 06:58:15 +02:00
|
|
|
recent_topics_ui_shown = true;
|
|
|
|
});
|
|
|
|
window.location.hash = "#unknown_hash";
|
2018-04-11 13:14:39 +02:00
|
|
|
|
2021-03-22 16:09:12 +01:00
|
|
|
browser_history.clear_for_testing();
|
2018-04-11 13:14:39 +02:00
|
|
|
hashchange.initialize();
|
2021-06-19 06:58:15 +02:00
|
|
|
// If it's an unknown hash it should show the default view.
|
|
|
|
assert.equal(recent_topics_ui_shown, true);
|
|
|
|
helper.assert_events([
|
|
|
|
[overlays, "close_for_hash_change"],
|
|
|
|
[message_viewport, "stop_auto_scrolling"],
|
|
|
|
]);
|
|
|
|
|
|
|
|
window.location.hash = "#all_messages";
|
|
|
|
|
|
|
|
helper.clear_events();
|
|
|
|
window_stub.trigger("hashchange");
|
2018-04-11 13:14:39 +02:00
|
|
|
helper.assert_events([
|
2021-02-11 01:42:59 +01:00
|
|
|
[overlays, "close_for_hash_change"],
|
|
|
|
[message_viewport, "stop_auto_scrolling"],
|
2020-07-04 16:25:41 +02:00
|
|
|
"change_tab_to #message_feed_container",
|
2021-02-11 01:42:59 +01:00
|
|
|
[narrow, "deactivate"],
|
|
|
|
[floating_recipient_bar, "update"],
|
2018-04-11 13:14:39 +02:00
|
|
|
]);
|
|
|
|
|
|
|
|
helper.clear_events();
|
2021-03-14 11:01:58 +01:00
|
|
|
window_stub.trigger("hashchange");
|
2018-04-11 13:14:39 +02:00
|
|
|
helper.assert_events([
|
2021-02-11 01:42:59 +01:00
|
|
|
[overlays, "close_for_hash_change"],
|
|
|
|
[message_viewport, "stop_auto_scrolling"],
|
2020-07-04 16:25:41 +02:00
|
|
|
"change_tab_to #message_feed_container",
|
2021-02-11 01:42:59 +01:00
|
|
|
[narrow, "deactivate"],
|
|
|
|
[floating_recipient_bar, "update"],
|
2018-04-11 13:14:39 +02:00
|
|
|
]);
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
window.location.hash = "#narrow/stream/Denmark";
|
2018-04-11 13:14:39 +02:00
|
|
|
|
|
|
|
helper.clear_events();
|
2021-03-14 11:01:58 +01:00
|
|
|
window_stub.trigger("hashchange");
|
2018-04-11 13:14:39 +02:00
|
|
|
helper.assert_events([
|
2021-02-11 01:42:59 +01:00
|
|
|
[overlays, "close_for_hash_change"],
|
|
|
|
[message_viewport, "stop_auto_scrolling"],
|
2020-07-04 16:25:41 +02:00
|
|
|
"change_tab_to #message_feed_container",
|
2020-07-15 01:29:15 +02:00
|
|
|
"narrow.activate",
|
2021-02-11 01:42:59 +01:00
|
|
|
[floating_recipient_bar, "update"],
|
2018-04-11 13:14:39 +02:00
|
|
|
]);
|
2019-11-02 00:06:25 +01:00
|
|
|
let terms = helper.get_narrow_terms();
|
2020-07-15 01:29:15 +02:00
|
|
|
assert.equal(terms[0].operand, "Denmark");
|
2018-04-11 13:14:39 +02:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
window.location.hash = "#narrow";
|
2018-04-11 13:14:39 +02:00
|
|
|
|
|
|
|
helper.clear_events();
|
2021-03-14 11:01:58 +01:00
|
|
|
window_stub.trigger("hashchange");
|
2018-04-11 13:14:39 +02:00
|
|
|
helper.assert_events([
|
2021-02-11 01:42:59 +01:00
|
|
|
[overlays, "close_for_hash_change"],
|
|
|
|
[message_viewport, "stop_auto_scrolling"],
|
2020-07-04 16:25:41 +02:00
|
|
|
"change_tab_to #message_feed_container",
|
2020-07-15 01:29:15 +02:00
|
|
|
"narrow.activate",
|
2021-02-11 01:42:59 +01:00
|
|
|
[floating_recipient_bar, "update"],
|
2018-04-11 13:14:39 +02:00
|
|
|
]);
|
|
|
|
terms = helper.get_narrow_terms();
|
|
|
|
assert.equal(terms.length, 0);
|
|
|
|
|
2022-02-25 19:27:25 +01:00
|
|
|
// Test an invalid narrow hash
|
|
|
|
window.location.hash = "#narrow/foo.foo";
|
|
|
|
|
|
|
|
helper.clear_events();
|
|
|
|
window_stub.trigger("hashchange");
|
|
|
|
helper.assert_events([
|
|
|
|
[overlays, "close_for_hash_change"],
|
|
|
|
[message_viewport, "stop_auto_scrolling"],
|
|
|
|
"change_tab_to #message_feed_container",
|
|
|
|
[ui_report, "error"],
|
|
|
|
]);
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
window.location.hash = "#streams/whatever";
|
2018-04-11 13:14:39 +02:00
|
|
|
|
|
|
|
helper.clear_events();
|
2021-03-14 11:01:58 +01:00
|
|
|
window_stub.trigger("hashchange");
|
2021-02-11 01:42:59 +01:00
|
|
|
helper.assert_events([
|
|
|
|
[overlays, "close_for_hash_change"],
|
2021-07-09 15:51:31 +02:00
|
|
|
[stream_settings_ui, "launch"],
|
2021-02-11 01:42:59 +01:00
|
|
|
]);
|
2018-04-11 13:14:39 +02:00
|
|
|
|
2021-06-28 05:08:55 +02:00
|
|
|
recent_topics_ui_shown = false;
|
|
|
|
window.location.hash = "#reload:send_after_reload=0...";
|
|
|
|
|
|
|
|
helper.clear_events();
|
|
|
|
window_stub.trigger("hashchange");
|
|
|
|
helper.assert_events([]);
|
|
|
|
// If it's reload hash it shouldn't show the default view.
|
|
|
|
assert.equal(recent_topics_ui_shown, false);
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
window.location.hash = "#keyboard-shortcuts/whatever";
|
2018-04-11 13:14:39 +02:00
|
|
|
|
|
|
|
helper.clear_events();
|
2021-03-14 11:01:58 +01:00
|
|
|
window_stub.trigger("hashchange");
|
2021-02-11 01:42:59 +01:00
|
|
|
helper.assert_events([[overlays, "close_for_hash_change"], "info: keyboard-shortcuts"]);
|
2018-04-11 13:14:39 +02:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
window.location.hash = "#message-formatting/whatever";
|
2018-04-11 13:14:39 +02:00
|
|
|
|
|
|
|
helper.clear_events();
|
2021-03-14 11:01:58 +01:00
|
|
|
window_stub.trigger("hashchange");
|
2021-02-11 01:42:59 +01:00
|
|
|
helper.assert_events([[overlays, "close_for_hash_change"], "info: message-formatting"]);
|
2018-04-11 13:14:39 +02:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
window.location.hash = "#search-operators/whatever";
|
2018-04-11 13:14:39 +02:00
|
|
|
|
|
|
|
helper.clear_events();
|
2021-03-14 11:01:58 +01:00
|
|
|
window_stub.trigger("hashchange");
|
2021-02-11 01:42:59 +01:00
|
|
|
helper.assert_events([[overlays, "close_for_hash_change"], "info: search-operators"]);
|
2018-04-11 13:14:39 +02:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
window.location.hash = "#drafts";
|
2018-04-11 13:14:39 +02:00
|
|
|
|
|
|
|
helper.clear_events();
|
2021-03-14 11:01:58 +01:00
|
|
|
window_stub.trigger("hashchange");
|
2021-02-11 01:42:59 +01:00
|
|
|
helper.assert_events([
|
|
|
|
[overlays, "close_for_hash_change"],
|
|
|
|
[drafts, "launch"],
|
|
|
|
]);
|
2018-04-11 13:14:39 +02:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
window.location.hash = "#settings/alert-words";
|
2018-04-11 13:14:39 +02:00
|
|
|
|
|
|
|
helper.clear_events();
|
2021-03-14 11:01:58 +01:00
|
|
|
window_stub.trigger("hashchange");
|
2021-02-11 01:42:59 +01:00
|
|
|
helper.assert_events([
|
|
|
|
[overlays, "close_for_hash_change"],
|
|
|
|
[settings, "launch"],
|
|
|
|
]);
|
2018-04-11 13:14:39 +02:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
window.location.hash = "#organization/user-list-admin";
|
2018-04-11 13:14:39 +02:00
|
|
|
|
|
|
|
helper.clear_events();
|
2021-03-14 11:01:58 +01:00
|
|
|
window_stub.trigger("hashchange");
|
2021-02-11 01:42:59 +01:00
|
|
|
helper.assert_events([
|
|
|
|
[overlays, "close_for_hash_change"],
|
|
|
|
[admin, "launch"],
|
|
|
|
]);
|
2018-04-11 13:14:39 +02:00
|
|
|
|
|
|
|
helper.clear_events();
|
2021-03-22 16:09:12 +01:00
|
|
|
browser_history.exit_overlay();
|
2018-04-11 13:14:39 +02:00
|
|
|
|
2021-02-11 01:42:59 +01:00
|
|
|
helper.assert_events([[ui_util, "blur_active_element"]]);
|
2018-05-15 12:40:07 +02:00
|
|
|
});
|
2018-04-11 13:14:39 +02:00
|
|
|
|
2022-01-08 10:27:06 +01:00
|
|
|
run_test("save_narrow", ({override, override_rewire}) => {
|
|
|
|
override_rewire(recent_topics_util, "is_visible", () => false);
|
2021-06-10 14:18:46 +02:00
|
|
|
|
2022-01-08 10:27:06 +01:00
|
|
|
const helper = test_helper({override, override_rewire});
|
2018-04-11 13:14:39 +02:00
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
let operators = [{operator: "is", operand: "private"}];
|
2018-04-11 13:14:39 +02:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
blueslip.expect("warn", "browser does not support pushState");
|
2018-04-11 13:14:39 +02:00
|
|
|
hashchange.save_narrow(operators);
|
2018-12-06 22:59:05 +01:00
|
|
|
|
2021-02-11 01:42:59 +01:00
|
|
|
helper.assert_events([[message_viewport, "stop_auto_scrolling"]]);
|
2020-07-15 01:29:15 +02:00
|
|
|
assert.equal(window.location.hash, "#narrow/is/private");
|
2018-04-11 13:14:39 +02:00
|
|
|
|
2019-11-02 00:06:25 +01:00
|
|
|
let url_pushed;
|
2021-03-14 11:01:58 +01:00
|
|
|
override(history, "pushState", (state, title, url) => {
|
2018-04-11 13:14:39 +02:00
|
|
|
url_pushed = url;
|
2021-03-14 11:01:58 +01:00
|
|
|
});
|
2018-04-11 13:14:39 +02:00
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
operators = [{operator: "is", operand: "starred"}];
|
2018-04-11 13:14:39 +02:00
|
|
|
|
|
|
|
helper.clear_events();
|
|
|
|
hashchange.save_narrow(operators);
|
2021-02-11 01:42:59 +01:00
|
|
|
helper.assert_events([[message_viewport, "stop_auto_scrolling"]]);
|
2021-10-14 00:23:21 +02:00
|
|
|
assert.equal(url_pushed, "http://zulip.zulipdev.com/#narrow/is/starred");
|
2018-05-15 12:40:07 +02:00
|
|
|
});
|