mirror of https://github.com/zulip/zulip.git
search: Remove unused base_query variable.
This commit is contained in:
parent
7116526492
commit
6346110b56
|
@ -45,8 +45,7 @@ export function initialize({on_narrow_search}) {
|
||||||
|
|
||||||
$search_query_box.typeahead({
|
$search_query_box.typeahead({
|
||||||
source(query) {
|
source(query) {
|
||||||
const base_query = "";
|
const suggestions = search_suggestion.get_suggestions(query);
|
||||||
const suggestions = search_suggestion.get_suggestions(base_query, query);
|
|
||||||
// Update our global search_map hash
|
// Update our global search_map hash
|
||||||
search_map = suggestions.lookup_table;
|
search_map = suggestions.lookup_table;
|
||||||
return suggestions.strings;
|
return suggestions.strings;
|
||||||
|
|
|
@ -705,7 +705,7 @@ class Attacher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function get_search_result(_base_query, query) {
|
export function get_search_result(query) {
|
||||||
let suggestion;
|
let suggestion;
|
||||||
|
|
||||||
// search_operators correspond to the operators for the query in the input.
|
// search_operators correspond to the operators for the query in the input.
|
||||||
|
@ -808,8 +808,8 @@ export function get_search_result(_base_query, query) {
|
||||||
return attacher.result.slice(0, max_items);
|
return attacher.result.slice(0, max_items);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function get_suggestions(base_query, query) {
|
export function get_suggestions(query) {
|
||||||
const result = get_search_result(base_query, query);
|
const result = get_search_result(query);
|
||||||
return finalize_search_result(result);
|
return finalize_search_result(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,8 +68,8 @@ function init() {
|
||||||
stream_data.clear_subscriptions();
|
stream_data.clear_subscriptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_suggestions(base_query, query) {
|
function get_suggestions(query) {
|
||||||
return search.get_suggestions(base_query, query);
|
return search.get_suggestions(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
function test(label, f) {
|
function test(label, f) {
|
||||||
|
@ -84,7 +84,7 @@ test("basic_get_suggestions", ({override}) => {
|
||||||
|
|
||||||
override(narrow_state, "stream", () => "office");
|
override(narrow_state, "stream", () => "office");
|
||||||
|
|
||||||
const suggestions = get_suggestions("", query);
|
const suggestions = get_suggestions(query);
|
||||||
|
|
||||||
const expected = ["fred"];
|
const expected = ["fred"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
@ -94,7 +94,7 @@ test("basic_get_suggestions_for_spectator", () => {
|
||||||
page_params.is_spectator = true;
|
page_params.is_spectator = true;
|
||||||
|
|
||||||
const query = "";
|
const query = "";
|
||||||
const suggestions = get_suggestions("", query);
|
const suggestions = get_suggestions(query);
|
||||||
assert.deepEqual(suggestions.strings, ["", "has:link", "has:image", "has:attachment"]);
|
assert.deepEqual(suggestions.strings, ["", "has:link", "has:image", "has:attachment"]);
|
||||||
page_params.is_spectator = false;
|
page_params.is_spectator = false;
|
||||||
});
|
});
|
||||||
|
@ -102,7 +102,7 @@ test("basic_get_suggestions_for_spectator", () => {
|
||||||
test("subset_suggestions", () => {
|
test("subset_suggestions", () => {
|
||||||
const query = "stream:Denmark topic:Hamlet shakespeare";
|
const query = "stream:Denmark topic:Hamlet shakespeare";
|
||||||
|
|
||||||
const suggestions = get_suggestions("", query);
|
const suggestions = get_suggestions(query);
|
||||||
|
|
||||||
const expected = [
|
const expected = [
|
||||||
"stream:Denmark topic:Hamlet shakespeare",
|
"stream:Denmark topic:Hamlet shakespeare",
|
||||||
|
@ -115,7 +115,7 @@ test("subset_suggestions", () => {
|
||||||
|
|
||||||
test("dm_suggestions", ({override}) => {
|
test("dm_suggestions", ({override}) => {
|
||||||
let query = "is:dm";
|
let query = "is:dm";
|
||||||
let suggestions = get_suggestions("", query);
|
let suggestions = get_suggestions(query);
|
||||||
let expected = [
|
let expected = [
|
||||||
"is:dm",
|
"is:dm",
|
||||||
"dm:alice@zulip.com",
|
"dm:alice@zulip.com",
|
||||||
|
@ -127,7 +127,7 @@ test("dm_suggestions", ({override}) => {
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "is:dm al";
|
query = "is:dm al";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = [
|
expected = [
|
||||||
"is:dm al",
|
"is:dm al",
|
||||||
"is:dm is:alerted",
|
"is:dm is:alerted",
|
||||||
|
@ -142,75 +142,75 @@ test("dm_suggestions", ({override}) => {
|
||||||
// we suggest "is:dm" to anyone with "is:private"
|
// we suggest "is:dm" to anyone with "is:private"
|
||||||
// in their muscle memory.
|
// in their muscle memory.
|
||||||
query = "is:pr";
|
query = "is:pr";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["is:dm"];
|
expected = ["is:dm"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "is:private";
|
query = "is:private";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["is:dm"];
|
expected = ["is:dm"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "dm:t";
|
query = "dm:t";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["dm:t", "dm:ted@zulip.com"];
|
expected = ["dm:t", "dm:ted@zulip.com"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "-dm:t";
|
query = "-dm:t";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["-dm:t", "is:dm -dm:ted@zulip.com"];
|
expected = ["-dm:t", "is:dm -dm:ted@zulip.com"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "dm:ted@zulip.com";
|
query = "dm:ted@zulip.com";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["dm:ted@zulip.com"];
|
expected = ["dm:ted@zulip.com"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "sender:ted";
|
query = "sender:ted";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["sender:ted", "sender:ted@zulip.com"];
|
expected = ["sender:ted", "sender:ted@zulip.com"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "sender:te";
|
query = "sender:te";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["sender:te", "sender:ted@zulip.com"];
|
expected = ["sender:te", "sender:ted@zulip.com"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "-sender:te";
|
query = "-sender:te";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["-sender:te", "-sender:ted@zulip.com"];
|
expected = ["-sender:te", "-sender:ted@zulip.com"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "sender:ted@zulip.com";
|
query = "sender:ted@zulip.com";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["sender:ted@zulip.com"];
|
expected = ["sender:ted@zulip.com"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "is:unread from:ted";
|
query = "is:unread from:ted";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["is:unread from:ted", "is:unread from:ted@zulip.com", "is:unread"];
|
expected = ["is:unread from:ted", "is:unread from:ted@zulip.com", "is:unread"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
// Users can enter bizarre queries, and if they do, we want to
|
// Users can enter bizarre queries, and if they do, we want to
|
||||||
// be conservative with suggestions.
|
// be conservative with suggestions.
|
||||||
query = "is:dm near:3";
|
query = "is:dm near:3";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["is:dm near:3", "is:dm"];
|
expected = ["is:dm near:3", "is:dm"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "dm:ted@zulip.com near:3";
|
query = "dm:ted@zulip.com near:3";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["dm:ted@zulip.com near:3", "dm:ted@zulip.com"];
|
expected = ["dm:ted@zulip.com near:3", "dm:ted@zulip.com"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
// Make sure suggestions still work if preceding tokens
|
// Make sure suggestions still work if preceding tokens
|
||||||
query = "is:alerted sender:ted@zulip.com";
|
query = "is:alerted sender:ted@zulip.com";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["is:alerted sender:ted@zulip.com", "is:alerted"];
|
expected = ["is:alerted sender:ted@zulip.com", "is:alerted"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "is:starred has:link is:dm al";
|
query = "is:starred has:link is:dm al";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = [
|
expected = [
|
||||||
"is:starred has:link is:dm al",
|
"is:starred has:link is:dm al",
|
||||||
"is:starred has:link is:dm is:alerted",
|
"is:starred has:link is:dm is:alerted",
|
||||||
|
@ -225,12 +225,12 @@ test("dm_suggestions", ({override}) => {
|
||||||
|
|
||||||
// Make sure it handles past context correctly
|
// Make sure it handles past context correctly
|
||||||
query = "stream:Denmark dm:";
|
query = "stream:Denmark dm:";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["stream:Denmark dm:", "stream:Denmark"];
|
expected = ["stream:Denmark dm:", "stream:Denmark"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "sender:ted@zulip.com sender:";
|
query = "sender:ted@zulip.com sender:";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["sender:ted@zulip.com sender:", "sender:ted@zulip.com"];
|
expected = ["sender:ted@zulip.com sender:", "sender:ted@zulip.com"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
|
@ -238,12 +238,12 @@ test("dm_suggestions", ({override}) => {
|
||||||
// and "dm" operator as a suggestions
|
// and "dm" operator as a suggestions
|
||||||
override(narrow_state, "stream", () => undefined);
|
override(narrow_state, "stream", () => undefined);
|
||||||
query = "pm-with";
|
query = "pm-with";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["pm-with", "dm:"];
|
expected = ["pm-with", "dm:"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "pm-with:t";
|
query = "pm-with:t";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["pm-with:t", "dm:ted@zulip.com"];
|
expected = ["pm-with:t", "dm:ted@zulip.com"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
});
|
});
|
||||||
|
@ -252,7 +252,7 @@ test("group_suggestions", () => {
|
||||||
// Entering a comma in a "dm:" query should immediately
|
// Entering a comma in a "dm:" query should immediately
|
||||||
// generate suggestions for the next person.
|
// generate suggestions for the next person.
|
||||||
let query = "dm:bob@zulip.com,";
|
let query = "dm:bob@zulip.com,";
|
||||||
let suggestions = get_suggestions("", query);
|
let suggestions = get_suggestions(query);
|
||||||
let expected = [
|
let expected = [
|
||||||
"dm:bob@zulip.com,",
|
"dm:bob@zulip.com,",
|
||||||
"dm:bob@zulip.com,alice@zulip.com",
|
"dm:bob@zulip.com,alice@zulip.com",
|
||||||
|
@ -264,25 +264,25 @@ test("group_suggestions", () => {
|
||||||
// Only the last part of a comma-separated "dm" query
|
// Only the last part of a comma-separated "dm" query
|
||||||
// should be used to generate suggestions.
|
// should be used to generate suggestions.
|
||||||
query = "dm:bob@zulip.com,t";
|
query = "dm:bob@zulip.com,t";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["dm:bob@zulip.com,t", "dm:bob@zulip.com,ted@zulip.com"];
|
expected = ["dm:bob@zulip.com,t", "dm:bob@zulip.com,ted@zulip.com"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
// Smit should also generate ted@zulip.com (Ted Smith) as a suggestion.
|
// Smit should also generate ted@zulip.com (Ted Smith) as a suggestion.
|
||||||
query = "dm:bob@zulip.com,Smit";
|
query = "dm:bob@zulip.com,Smit";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["dm:bob@zulip.com,Smit", "dm:bob@zulip.com,ted@zulip.com"];
|
expected = ["dm:bob@zulip.com,Smit", "dm:bob@zulip.com,ted@zulip.com"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
// Do not suggest "myself@zulip.com" (the name of the current user)
|
// Do not suggest "myself@zulip.com" (the name of the current user)
|
||||||
query = "dm:ted@zulip.com,my";
|
query = "dm:ted@zulip.com,my";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["dm:ted@zulip.com,my"];
|
expected = ["dm:ted@zulip.com,my"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
// No superfluous suggestions should be generated.
|
// No superfluous suggestions should be generated.
|
||||||
query = "dm:bob@zulip.com,red";
|
query = "dm:bob@zulip.com,red";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["dm:bob@zulip.com,red"];
|
expected = ["dm:bob@zulip.com,red"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
|
@ -290,7 +290,7 @@ test("group_suggestions", () => {
|
||||||
// if the "dm" operator is negated.
|
// if the "dm" operator is negated.
|
||||||
|
|
||||||
query = "-dm:bob@zulip.com,";
|
query = "-dm:bob@zulip.com,";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = [
|
expected = [
|
||||||
"-dm:bob@zulip.com,",
|
"-dm:bob@zulip.com,",
|
||||||
"is:dm -dm:bob@zulip.com,alice@zulip.com",
|
"is:dm -dm:bob@zulip.com,alice@zulip.com",
|
||||||
|
@ -300,17 +300,17 @@ test("group_suggestions", () => {
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "-dm:bob@zulip.com,t";
|
query = "-dm:bob@zulip.com,t";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["-dm:bob@zulip.com,t", "is:dm -dm:bob@zulip.com,ted@zulip.com"];
|
expected = ["-dm:bob@zulip.com,t", "is:dm -dm:bob@zulip.com,ted@zulip.com"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "-dm:bob@zulip.com,Smit";
|
query = "-dm:bob@zulip.com,Smit";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["-dm:bob@zulip.com,Smit", "is:dm -dm:bob@zulip.com,ted@zulip.com"];
|
expected = ["-dm:bob@zulip.com,Smit", "is:dm -dm:bob@zulip.com,ted@zulip.com"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "-dm:bob@zulip.com,red";
|
query = "-dm:bob@zulip.com,red";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["-dm:bob@zulip.com,red"];
|
expected = ["-dm:bob@zulip.com,red"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ test("group_suggestions", () => {
|
||||||
// show suggestions for group direct messages with the "dm"
|
// show suggestions for group direct messages with the "dm"
|
||||||
// operator.
|
// operator.
|
||||||
query = "pm-with:bob@zulip.com,";
|
query = "pm-with:bob@zulip.com,";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = [
|
expected = [
|
||||||
"pm-with:bob@zulip.com,",
|
"pm-with:bob@zulip.com,",
|
||||||
"dm:bob@zulip.com,alice@zulip.com",
|
"dm:bob@zulip.com,alice@zulip.com",
|
||||||
|
@ -329,7 +329,7 @@ test("group_suggestions", () => {
|
||||||
|
|
||||||
// Test multiple operators
|
// Test multiple operators
|
||||||
query = "is:starred has:link dm:bob@zulip.com,Smit";
|
query = "is:starred has:link dm:bob@zulip.com,Smit";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = [
|
expected = [
|
||||||
"is:starred has:link dm:bob@zulip.com,Smit",
|
"is:starred has:link dm:bob@zulip.com,Smit",
|
||||||
"is:starred has:link dm:bob@zulip.com,ted@zulip.com",
|
"is:starred has:link dm:bob@zulip.com,ted@zulip.com",
|
||||||
|
@ -339,7 +339,7 @@ test("group_suggestions", () => {
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "stream:Denmark has:link dm:bob@zulip.com,Smit";
|
query = "stream:Denmark has:link dm:bob@zulip.com,Smit";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = [
|
expected = [
|
||||||
"stream:Denmark has:link dm:bob@zulip.com,Smit",
|
"stream:Denmark has:link dm:bob@zulip.com,Smit",
|
||||||
"stream:Denmark has:link",
|
"stream:Denmark has:link",
|
||||||
|
@ -365,7 +365,7 @@ test("group_suggestions", () => {
|
||||||
// Simulate a past group direct message which should now
|
// Simulate a past group direct message which should now
|
||||||
// prioritize ted over alice
|
// prioritize ted over alice
|
||||||
query = "dm:bob@zulip.com,";
|
query = "dm:bob@zulip.com,";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = [
|
expected = [
|
||||||
"dm:bob@zulip.com,",
|
"dm:bob@zulip.com,",
|
||||||
"dm:bob@zulip.com,ted@zulip.com",
|
"dm:bob@zulip.com,ted@zulip.com",
|
||||||
|
@ -377,7 +377,7 @@ test("group_suggestions", () => {
|
||||||
// bob, ted, and jeff are already an existing group direct message,
|
// bob, ted, and jeff are already an existing group direct message,
|
||||||
// so prioritize this one
|
// so prioritize this one
|
||||||
query = "dm:bob@zulip.com,ted@zulip.com,";
|
query = "dm:bob@zulip.com,ted@zulip.com,";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = [
|
expected = [
|
||||||
"dm:bob@zulip.com,ted@zulip.com,",
|
"dm:bob@zulip.com,ted@zulip.com,",
|
||||||
"dm:bob@zulip.com,ted@zulip.com,jeff@zulip.com",
|
"dm:bob@zulip.com,ted@zulip.com,jeff@zulip.com",
|
||||||
|
@ -389,7 +389,7 @@ test("group_suggestions", () => {
|
||||||
// but if we start with just jeff, then don't prioritize ted over
|
// but if we start with just jeff, then don't prioritize ted over
|
||||||
// alice because it doesn't complete the full group direct message.
|
// alice because it doesn't complete the full group direct message.
|
||||||
query = "dm:jeff@zulip.com,";
|
query = "dm:jeff@zulip.com,";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = [
|
expected = [
|
||||||
"dm:jeff@zulip.com,",
|
"dm:jeff@zulip.com,",
|
||||||
"dm:jeff@zulip.com,alice@zulip.com",
|
"dm:jeff@zulip.com,alice@zulip.com",
|
||||||
|
@ -399,7 +399,7 @@ test("group_suggestions", () => {
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "dm:jeff@zulip.com,ted@zulip.com hi";
|
query = "dm:jeff@zulip.com,ted@zulip.com hi";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["dm:jeff@zulip.com,ted@zulip.com hi", "dm:jeff@zulip.com,ted@zulip.com"];
|
expected = ["dm:jeff@zulip.com,ted@zulip.com hi", "dm:jeff@zulip.com,ted@zulip.com"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
});
|
});
|
||||||
|
@ -410,7 +410,7 @@ test("empty_query_suggestions", () => {
|
||||||
stream_data.add_sub({stream_id: 44, name: "devel", subscribed: true});
|
stream_data.add_sub({stream_id: 44, name: "devel", subscribed: true});
|
||||||
stream_data.add_sub({stream_id: 77, name: "office", subscribed: true});
|
stream_data.add_sub({stream_id: 77, name: "office", subscribed: true});
|
||||||
|
|
||||||
const suggestions = get_suggestions("", query);
|
const suggestions = get_suggestions(query);
|
||||||
|
|
||||||
const expected = [
|
const expected = [
|
||||||
"",
|
"",
|
||||||
|
@ -454,7 +454,7 @@ test("has_suggestions", ({override}) => {
|
||||||
stream_data.add_sub({stream_id: 77, name: "office", subscribed: true});
|
stream_data.add_sub({stream_id: 77, name: "office", subscribed: true});
|
||||||
override(narrow_state, "stream", () => {});
|
override(narrow_state, "stream", () => {});
|
||||||
|
|
||||||
let suggestions = get_suggestions("", query);
|
let suggestions = get_suggestions(query);
|
||||||
let expected = ["h", "has:link", "has:image", "has:attachment"];
|
let expected = ["h", "has:link", "has:image", "has:attachment"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
|
@ -467,7 +467,7 @@ test("has_suggestions", ({override}) => {
|
||||||
assert.equal(describe("has:attachment"), "Messages that contain attachments");
|
assert.equal(describe("has:attachment"), "Messages that contain attachments");
|
||||||
|
|
||||||
query = "-h";
|
query = "-h";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["-h", "-has:link", "-has:image", "-has:attachment"];
|
expected = ["-h", "-has:link", "-has:image", "-has:attachment"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
assert.equal(describe("-has:link"), "Exclude messages that contain links");
|
assert.equal(describe("-has:link"), "Exclude messages that contain links");
|
||||||
|
@ -477,27 +477,27 @@ test("has_suggestions", ({override}) => {
|
||||||
// operand suggestions follow.
|
// operand suggestions follow.
|
||||||
|
|
||||||
query = "has:";
|
query = "has:";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["has:link", "has:image", "has:attachment"];
|
expected = ["has:link", "has:image", "has:attachment"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "has:im";
|
query = "has:im";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["has:image"];
|
expected = ["has:image"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "-has:im";
|
query = "-has:im";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["-has:image"];
|
expected = ["-has:image"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "att";
|
query = "att";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["att", "has:attachment"];
|
expected = ["att", "has:attachment"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "stream:Denmark is:alerted has:lin";
|
query = "stream:Denmark is:alerted has:lin";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = [
|
expected = [
|
||||||
"stream:Denmark is:alerted has:link",
|
"stream:Denmark is:alerted has:link",
|
||||||
"stream:Denmark is:alerted",
|
"stream:Denmark is:alerted",
|
||||||
|
@ -512,7 +512,7 @@ test("check_is_suggestions", ({override}) => {
|
||||||
override(narrow_state, "stream", () => {});
|
override(narrow_state, "stream", () => {});
|
||||||
|
|
||||||
let query = "i";
|
let query = "i";
|
||||||
let suggestions = get_suggestions("", query);
|
let suggestions = get_suggestions(query);
|
||||||
let expected = [
|
let expected = [
|
||||||
"i",
|
"i",
|
||||||
"is:dm",
|
"is:dm",
|
||||||
|
@ -540,7 +540,7 @@ test("check_is_suggestions", ({override}) => {
|
||||||
assert.equal(describe("is:resolved"), "Topics marked as resolved");
|
assert.equal(describe("is:resolved"), "Topics marked as resolved");
|
||||||
|
|
||||||
query = "-i";
|
query = "-i";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = [
|
expected = [
|
||||||
"-i",
|
"-i",
|
||||||
"-is:dm",
|
"-is:dm",
|
||||||
|
@ -562,27 +562,27 @@ test("check_is_suggestions", ({override}) => {
|
||||||
// operand suggestions follow.
|
// operand suggestions follow.
|
||||||
|
|
||||||
query = "is:";
|
query = "is:";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["is:dm", "is:starred", "is:mentioned", "is:alerted", "is:unread", "is:resolved"];
|
expected = ["is:dm", "is:starred", "is:mentioned", "is:alerted", "is:unread", "is:resolved"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "is:st";
|
query = "is:st";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["is:starred"];
|
expected = ["is:starred"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "-is:st";
|
query = "-is:st";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["-is:starred"];
|
expected = ["-is:starred"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "st";
|
query = "st";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["st", "streams:public", "is:starred", "stream:"];
|
expected = ["st", "streams:public", "is:starred", "stream:"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "stream:Denmark has:link is:sta";
|
query = "stream:Denmark has:link is:sta";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["stream:Denmark has:link is:starred", "stream:Denmark has:link", "stream:Denmark"];
|
expected = ["stream:Denmark has:link is:starred", "stream:Denmark has:link", "stream:Denmark"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
});
|
});
|
||||||
|
@ -591,7 +591,7 @@ test("sent_by_me_suggestions", ({override}) => {
|
||||||
override(narrow_state, "stream", () => {});
|
override(narrow_state, "stream", () => {});
|
||||||
|
|
||||||
let query = "";
|
let query = "";
|
||||||
let suggestions = get_suggestions("", query);
|
let suggestions = get_suggestions(query);
|
||||||
assert.ok(suggestions.strings.includes("sender:myself@zulip.com"));
|
assert.ok(suggestions.strings.includes("sender:myself@zulip.com"));
|
||||||
assert.equal(
|
assert.equal(
|
||||||
suggestions.lookup_table.get("sender:myself@zulip.com").description_html,
|
suggestions.lookup_table.get("sender:myself@zulip.com").description_html,
|
||||||
|
@ -599,47 +599,47 @@ test("sent_by_me_suggestions", ({override}) => {
|
||||||
);
|
);
|
||||||
|
|
||||||
query = "sender";
|
query = "sender";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
let expected = ["sender", "sender:myself@zulip.com", "sender:"];
|
let expected = ["sender", "sender:myself@zulip.com", "sender:"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "-sender";
|
query = "-sender";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["-sender", "-sender:myself@zulip.com", "-sender:"];
|
expected = ["-sender", "-sender:myself@zulip.com", "-sender:"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "from";
|
query = "from";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["from", "from:myself@zulip.com", "from:"];
|
expected = ["from", "from:myself@zulip.com", "from:"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "-from";
|
query = "-from";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["-from", "-from:myself@zulip.com", "-from:"];
|
expected = ["-from", "-from:myself@zulip.com", "-from:"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "sender:bob@zulip.com";
|
query = "sender:bob@zulip.com";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["sender:bob@zulip.com"];
|
expected = ["sender:bob@zulip.com"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "from:bob@zulip.com";
|
query = "from:bob@zulip.com";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["from:bob@zulip.com"];
|
expected = ["from:bob@zulip.com"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "sent";
|
query = "sent";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["sent", "sender:myself@zulip.com"];
|
expected = ["sent", "sender:myself@zulip.com"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "-sent";
|
query = "-sent";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["-sent", "-sender:myself@zulip.com"];
|
expected = ["-sent", "-sender:myself@zulip.com"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "stream:Denmark topic:Denmark1 sent";
|
query = "stream:Denmark topic:Denmark1 sent";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = [
|
expected = [
|
||||||
"stream:Denmark topic:Denmark1 sent",
|
"stream:Denmark topic:Denmark1 sent",
|
||||||
"stream:Denmark topic:Denmark1 sender:myself@zulip.com",
|
"stream:Denmark topic:Denmark1 sender:myself@zulip.com",
|
||||||
|
@ -649,12 +649,12 @@ test("sent_by_me_suggestions", ({override}) => {
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "is:starred sender:m";
|
query = "is:starred sender:m";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["is:starred sender:m", "is:starred sender:myself@zulip.com", "is:starred"];
|
expected = ["is:starred sender:m", "is:starred sender:myself@zulip.com", "is:starred"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "sender:alice@zulip.com sender:";
|
query = "sender:alice@zulip.com sender:";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["sender:alice@zulip.com sender:", "sender:alice@zulip.com"];
|
expected = ["sender:alice@zulip.com sender:", "sender:alice@zulip.com"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
});
|
});
|
||||||
|
@ -672,7 +672,7 @@ test("topic_suggestions", ({override}) => {
|
||||||
stream_data.add_sub({stream_id: devel_id, name: "devel", subscribed: true});
|
stream_data.add_sub({stream_id: devel_id, name: "devel", subscribed: true});
|
||||||
stream_data.add_sub({stream_id: office_id, name: "office", subscribed: true});
|
stream_data.add_sub({stream_id: office_id, name: "office", subscribed: true});
|
||||||
|
|
||||||
suggestions = get_suggestions("", "te");
|
suggestions = get_suggestions("te");
|
||||||
expected = ["te", "sender:ted@zulip.com", "dm:ted@zulip.com", "dm-including:ted@zulip.com"];
|
expected = ["te", "sender:ted@zulip.com", "dm:ted@zulip.com", "dm-including:ted@zulip.com"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
|
@ -688,7 +688,7 @@ test("topic_suggestions", ({override}) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
suggestions = get_suggestions("", "te");
|
suggestions = get_suggestions("te");
|
||||||
expected = [
|
expected = [
|
||||||
"te",
|
"te",
|
||||||
"sender:ted@zulip.com",
|
"sender:ted@zulip.com",
|
||||||
|
@ -705,23 +705,23 @@ test("topic_suggestions", ({override}) => {
|
||||||
assert.equal(describe("te"), "Search for te");
|
assert.equal(describe("te"), "Search for te");
|
||||||
assert.equal(describe("stream:office topic:team"), "Stream office > team");
|
assert.equal(describe("stream:office topic:team"), "Stream office > team");
|
||||||
|
|
||||||
suggestions = get_suggestions("", "topic:staplers stream:office");
|
suggestions = get_suggestions("topic:staplers stream:office");
|
||||||
expected = ["topic:staplers stream:office", "topic:staplers"];
|
expected = ["topic:staplers stream:office", "topic:staplers"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
suggestions = get_suggestions("", "stream:devel topic:");
|
suggestions = get_suggestions("stream:devel topic:");
|
||||||
expected = ["stream:devel topic:", "stream:devel topic:REXX", "stream:devel"];
|
expected = ["stream:devel topic:", "stream:devel topic:REXX", "stream:devel"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
suggestions = get_suggestions("", "stream:devel -topic:");
|
suggestions = get_suggestions("stream:devel -topic:");
|
||||||
expected = ["stream:devel -topic:", "stream:devel -topic:REXX", "stream:devel"];
|
expected = ["stream:devel -topic:", "stream:devel -topic:REXX", "stream:devel"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
suggestions = get_suggestions("", "-topic:te");
|
suggestions = get_suggestions("-topic:te");
|
||||||
expected = ["-topic:te", "stream:office -topic:team", "stream:office -topic:test"];
|
expected = ["-topic:te", "stream:office -topic:team", "stream:office -topic:test"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
suggestions = get_suggestions("", "is:alerted stream:devel is:starred topic:");
|
suggestions = get_suggestions("is:alerted stream:devel is:starred topic:");
|
||||||
expected = [
|
expected = [
|
||||||
"is:alerted stream:devel is:starred topic:",
|
"is:alerted stream:devel is:starred topic:",
|
||||||
"is:alerted stream:devel is:starred topic:REXX",
|
"is:alerted stream:devel is:starred topic:REXX",
|
||||||
|
@ -731,11 +731,11 @@ test("topic_suggestions", ({override}) => {
|
||||||
];
|
];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
suggestions = get_suggestions("", "is:dm stream:devel topic:");
|
suggestions = get_suggestions("is:dm stream:devel topic:");
|
||||||
expected = ["is:dm stream:devel topic:", "is:dm stream:devel", "is:dm"];
|
expected = ["is:dm stream:devel topic:", "is:dm stream:devel", "is:dm"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
suggestions = get_suggestions("", "topic:REXX stream:devel topic:");
|
suggestions = get_suggestions("topic:REXX stream:devel topic:");
|
||||||
expected = ["topic:REXX stream:devel topic:", "topic:REXX stream:devel", "topic:REXX"];
|
expected = ["topic:REXX stream:devel topic:", "topic:REXX stream:devel", "topic:REXX"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
});
|
});
|
||||||
|
@ -789,7 +789,7 @@ test("whitespace_glitch", ({override}) => {
|
||||||
override(stream_topic_history_util, "get_server_history", () => {});
|
override(stream_topic_history_util, "get_server_history", () => {});
|
||||||
stream_data.add_sub({stream_id: 77, name: "office", subscribed: true});
|
stream_data.add_sub({stream_id: 77, name: "office", subscribed: true});
|
||||||
|
|
||||||
const suggestions = get_suggestions("", query);
|
const suggestions = get_suggestions(query);
|
||||||
|
|
||||||
const expected = ["stream:office"];
|
const expected = ["stream:office"];
|
||||||
|
|
||||||
|
@ -803,17 +803,17 @@ test("stream_completion", ({override}) => {
|
||||||
override(narrow_state, "stream", () => {});
|
override(narrow_state, "stream", () => {});
|
||||||
|
|
||||||
let query = "stream:of";
|
let query = "stream:of";
|
||||||
let suggestions = get_suggestions("", query);
|
let suggestions = get_suggestions(query);
|
||||||
let expected = ["stream:of", "stream:office"];
|
let expected = ["stream:of", "stream:office"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "-stream:of";
|
query = "-stream:of";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["-stream:of", "-stream:office"];
|
expected = ["-stream:of", "-stream:office"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "hel";
|
query = "hel";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["hel", "stream:dev+help"];
|
expected = ["hel", "stream:dev+help"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
});
|
});
|
||||||
|
@ -845,7 +845,7 @@ test("people_suggestions", ({override}) => {
|
||||||
people.add_active_user(bob);
|
people.add_active_user(bob);
|
||||||
people.add_active_user(alice);
|
people.add_active_user(alice);
|
||||||
|
|
||||||
let suggestions = get_suggestions("", query);
|
let suggestions = get_suggestions(query);
|
||||||
|
|
||||||
let expected = [
|
let expected = [
|
||||||
"te",
|
"te",
|
||||||
|
@ -898,7 +898,7 @@ test("people_suggestions", ({override}) => {
|
||||||
assert.equal(get_avatar_url("sender:bob@zulip.com"), expectedString);
|
assert.equal(get_avatar_url("sender:bob@zulip.com"), expectedString);
|
||||||
assert.equal(get_avatar_url("dm-including:bob@zulip.com"), expectedString);
|
assert.equal(get_avatar_url("dm-including:bob@zulip.com"), expectedString);
|
||||||
|
|
||||||
suggestions = get_suggestions("", "Ted "); // note space
|
suggestions = get_suggestions("Ted "); // note space
|
||||||
|
|
||||||
expected = ["Ted", "sender:ted@zulip.com", "dm:ted@zulip.com", "dm-including:ted@zulip.com"];
|
expected = ["Ted", "sender:ted@zulip.com", "dm:ted@zulip.com", "dm-including:ted@zulip.com"];
|
||||||
|
|
||||||
|
@ -906,17 +906,17 @@ test("people_suggestions", ({override}) => {
|
||||||
|
|
||||||
query = "sender:ted sm";
|
query = "sender:ted sm";
|
||||||
expected = ["sender:ted+sm", "sender:ted@zulip.com"];
|
expected = ["sender:ted+sm", "sender:ted@zulip.com"];
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "sender:ted@zulip.com new";
|
query = "sender:ted@zulip.com new";
|
||||||
expected = ["sender:ted@zulip.com new", "sender:ted@zulip.com"];
|
expected = ["sender:ted@zulip.com new", "sender:ted@zulip.com"];
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "sender:ted@tulip.com new";
|
query = "sender:ted@tulip.com new";
|
||||||
expected = ["sender:ted@tulip.com+new"];
|
expected = ["sender:ted@tulip.com+new"];
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -925,22 +925,22 @@ test("operator_suggestions", ({override}) => {
|
||||||
|
|
||||||
// Completed operator should return nothing
|
// Completed operator should return nothing
|
||||||
let query = "stream:";
|
let query = "stream:";
|
||||||
let suggestions = get_suggestions("", query);
|
let suggestions = get_suggestions(query);
|
||||||
let expected = ["stream:"];
|
let expected = ["stream:"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "st";
|
query = "st";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["st", "streams:public", "is:starred", "stream:"];
|
expected = ["st", "streams:public", "is:starred", "stream:"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "-s";
|
query = "-s";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["-s", "-streams:public", "-sender:myself@zulip.com", "-stream:", "-sender:"];
|
expected = ["-s", "-streams:public", "-sender:myself@zulip.com", "-stream:", "-sender:"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
query = "stream:Denmark is:alerted -f";
|
query = "stream:Denmark is:alerted -f";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = [
|
expected = [
|
||||||
"stream:Denmark is:alerted -f",
|
"stream:Denmark is:alerted -f",
|
||||||
"stream:Denmark is:alerted -from:myself@zulip.com",
|
"stream:Denmark is:alerted -from:myself@zulip.com",
|
||||||
|
@ -957,19 +957,19 @@ test("queries_with_spaces", () => {
|
||||||
|
|
||||||
// test allowing spaces with quotes surrounding operand
|
// test allowing spaces with quotes surrounding operand
|
||||||
let query = 'stream:"dev he"';
|
let query = 'stream:"dev he"';
|
||||||
let suggestions = get_suggestions("", query);
|
let suggestions = get_suggestions(query);
|
||||||
let expected = ["stream:dev+he", "stream:dev+help"];
|
let expected = ["stream:dev+he", "stream:dev+help"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
// test mismatched quote
|
// test mismatched quote
|
||||||
query = 'stream:"dev h';
|
query = 'stream:"dev h';
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["stream:dev+h", "stream:dev+help"];
|
expected = ["stream:dev+h", "stream:dev+help"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
|
|
||||||
// test extra space after operator still works
|
// test extra space after operator still works
|
||||||
query = "stream: offi";
|
query = "stream: offi";
|
||||||
suggestions = get_suggestions("", query);
|
suggestions = get_suggestions(query);
|
||||||
expected = ["stream:offi", "stream:office"];
|
expected = ["stream:offi", "stream:office"];
|
||||||
assert.deepEqual(suggestions.strings, expected);
|
assert.deepEqual(suggestions.strings, expected);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue