mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 21:13:36 +00:00
typeahead: Fetch stream topic history from server.
Long ago, we changed Zulip to inspect server-provided topic history in our compose and search typeahead modules, but did not trigger a query to the server to fetch data. This could result in confusing experiences where someone thought that a topic doesn't exist that just isn't present in recent history. Once we merge this, we may want to adjust the messaging in typeahead to advertise that the first option will create a new topic, since this change may make it feel more like creating topics is a heavyweight operation. Fixes #9857.
This commit is contained in:
@@ -18,6 +18,7 @@ const message_user_ids = mock_esm("../../static/js/message_user_ids", {
|
||||
user_ids: () => [],
|
||||
});
|
||||
const stream_topic_history = mock_esm("../../static/js/stream_topic_history");
|
||||
const stream_topic_history_util = mock_esm("../../static/js/stream_topic_history_util");
|
||||
|
||||
let autosize_called;
|
||||
|
||||
@@ -316,6 +317,10 @@ test("topics_seen_for", (override) => {
|
||||
return ["With Twisted Metal", "acceptance", "civil fears"];
|
||||
});
|
||||
|
||||
override(stream_topic_history_util, "get_server_history", (stream_id) => {
|
||||
assert.equal(stream_id, denmark_stream.stream_id);
|
||||
});
|
||||
|
||||
assert.deepEqual(ct.topics_seen_for("Denmark"), [
|
||||
"With Twisted Metal",
|
||||
"acceptance",
|
||||
@@ -558,6 +563,8 @@ function sorted_names_from(subs) {
|
||||
test("initialize", (override) => {
|
||||
let expected_value;
|
||||
|
||||
override(stream_topic_history_util, "get_server_history", () => {});
|
||||
|
||||
let stream_typeahead_called = false;
|
||||
$("#stream_message_recipient_stream").typeahead = (options) => {
|
||||
// options.source()
|
||||
@@ -1109,6 +1116,8 @@ test("initialize", (override) => {
|
||||
});
|
||||
|
||||
test("begins_typeahead", (override) => {
|
||||
override(stream_topic_history_util, "get_server_history", () => {});
|
||||
|
||||
const begin_typehead_this = {
|
||||
options: {
|
||||
completions: {
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
const {strict: assert} = require("assert");
|
||||
|
||||
const {with_field, zrequire} = require("../zjsunit/namespace");
|
||||
const {mock_esm, with_field, zrequire} = require("../zjsunit/namespace");
|
||||
const {run_test} = require("../zjsunit/test");
|
||||
const {page_params} = require("../zjsunit/zpage_params");
|
||||
|
||||
const stream_topic_history_util = mock_esm("../../static/js/stream_topic_history_util");
|
||||
|
||||
const settings_config = zrequire("settings_config");
|
||||
|
||||
const huddle_data = zrequire("huddle_data");
|
||||
@@ -629,8 +631,8 @@ test("topic_suggestions", (override) => {
|
||||
let suggestions;
|
||||
let expected;
|
||||
|
||||
override(stream_topic_history_util, "get_server_history", () => {});
|
||||
override(stream_data, "subscribed_streams", () => ["office"]);
|
||||
|
||||
override(narrow_state, "stream", () => "office");
|
||||
|
||||
const devel_id = 44;
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
const {strict: assert} = require("assert");
|
||||
|
||||
const {zrequire} = require("../zjsunit/namespace");
|
||||
const {mock_esm, zrequire} = require("../zjsunit/namespace");
|
||||
const {run_test} = require("../zjsunit/test");
|
||||
const {page_params} = require("../zjsunit/zpage_params");
|
||||
|
||||
const stream_topic_history_util = mock_esm("../../static/js/stream_topic_history_util");
|
||||
|
||||
const settings_config = zrequire("settings_config");
|
||||
|
||||
const huddle_data = zrequire("huddle_data");
|
||||
@@ -596,8 +598,8 @@ test("topic_suggestions", (override) => {
|
||||
let suggestions;
|
||||
let expected;
|
||||
|
||||
override(stream_topic_history_util, "get_server_history", () => {});
|
||||
override(stream_data, "subscribed_streams", () => ["office"]);
|
||||
|
||||
override(narrow_state, "stream", () => "office");
|
||||
|
||||
const devel_id = 44;
|
||||
|
||||
Reference in New Issue
Block a user