From f7c3f1414df40c1260ac12dd40e7bd68fb510dd2 Mon Sep 17 00:00:00 2001 From: Pratik Chanda Date: Tue, 16 Jul 2024 05:15:26 +0530 Subject: [PATCH] search_suggestion: Change suggestion string for has: operator. Earlier in search suggestion, has: operator returned two different suggestion string which were `messages with one or more links` and `messages that contain links`. This commit changes this to a consistent suggestion string. Fixes: zulip#30908 --- web/src/filter.ts | 2 +- web/src/search_suggestion.ts | 8 ++++---- web/templates/search_description.hbs | 2 +- web/tests/filter.test.js | 4 ++-- web/tests/search_suggestion.test.js | 18 +++++++++--------- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/web/src/filter.ts b/web/src/filter.ts index 001e9a85d9..7945d59e80 100644 --- a/web/src/filter.ts +++ b/web/src/filter.ts @@ -665,7 +665,7 @@ export class Filter { // Note: We hack around using this in "describe" below. case "has": - return verb + "messages with one or more"; + return verb + "messages with"; case "id": return verb + "message ID"; diff --git a/web/src/search_suggestion.ts b/web/src/search_suggestion.ts index 45e4df1bfe..cd385dfe0a 100644 --- a/web/src/search_suggestion.ts +++ b/web/src/search_suggestion.ts @@ -720,25 +720,25 @@ function get_has_filter_suggestions(last: NarrowTerm, terms: NarrowTerm[]): Sugg const suggestions: SuggestionAndIncompatiblePatterns[] = [ { search_string: "has:link", - description_html: "messages that contain links", + description_html: "messages with links", is_people: false, incompatible_patterns: [{operator: "has", operand: "link"}], }, { search_string: "has:image", - description_html: "messages that contain images", + description_html: "messages with images", is_people: false, incompatible_patterns: [{operator: "has", operand: "image"}], }, { search_string: "has:attachment", - description_html: "messages that contain attachments", + description_html: "messages with attachments", is_people: false, incompatible_patterns: [{operator: "has", operand: "attachment"}], }, { search_string: "has:reaction", - description_html: "messages that contain reactions", + description_html: "messages with reactions", is_people: false, incompatible_patterns: [{operator: "has", operand: "reaction"}], }, diff --git a/web/templates/search_description.hbs b/web/templates/search_description.hbs index b6d9f6d4eb..81bdefeef9 100644 --- a/web/templates/search_description.hbs +++ b/web/templates/search_description.hbs @@ -12,7 +12,7 @@ {{~!-- squash whitespace --~}} {{else if (eq this.type "prefix_for_operator")}} {{~!-- squash whitespace --~}} - {{this.prefix_for_operator}} {{this.operand}} + {{this.prefix_for_operator}} {{this.operand}}{{#if (or (eq this.operand "link") (eq this.operand "image") (eq this.operand "attachment") (eq this.operand "reaction"))}}s{{/if}} {{~!-- squash whitespace --~}} {{else if (eq this.type "user_pill")}} {{~!-- squash whitespace --~}} diff --git a/web/tests/filter.test.js b/web/tests/filter.test.js index 8eb2dd73fd..b8479b837d 100644 --- a/web/tests/filter.test.js +++ b/web/tests/filter.test.js @@ -1500,7 +1500,7 @@ test("describe", ({mock_template}) => { {operator: "channel", operand: "devel"}, {operator: "has", operand: "image", negated: true}, ]; - string = "channel devel, exclude messages with one or more image"; + string = "channel devel, exclude messages with images"; assert.equal(Filter.search_description_as_html(narrow), string); narrow = [ @@ -1514,7 +1514,7 @@ test("describe", ({mock_template}) => { {operator: "has", operand: "image", negated: true}, {operator: "channel", operand: "devel"}, ]; - string = "exclude messages with one or more image, channel devel"; + string = "exclude messages with images, channel devel"; assert.equal(Filter.search_description_as_html(narrow), string); narrow = []; diff --git a/web/tests/search_suggestion.test.js b/web/tests/search_suggestion.test.js index ad2783a19e..29d360126a 100644 --- a/web/tests/search_suggestion.test.js +++ b/web/tests/search_suggestion.test.js @@ -381,9 +381,9 @@ test("empty_query_suggestions", () => { assert.equal(describe("is:resolved"), "Topics marked as resolved"); assert.equal(describe("is:followed"), "Followed topics"); assert.equal(describe("sender:myself@zulip.com"), "Sent by me"); - assert.equal(describe("has:link"), "Messages that contain links"); - assert.equal(describe("has:image"), "Messages that contain images"); - assert.equal(describe("has:attachment"), "Messages that contain attachments"); + assert.equal(describe("has:link"), "Messages with links"); + assert.equal(describe("has:image"), "Messages with images"); + assert.equal(describe("has:attachment"), "Messages with attachments"); }); test("has_suggestions", ({override, mock_template}) => { @@ -404,17 +404,17 @@ test("has_suggestions", ({override, mock_template}) => { return suggestions.lookup_table.get(q).description_html; } - assert.equal(describe("has:link"), "Messages that contain links"); - assert.equal(describe("has:image"), "Messages that contain images"); - assert.equal(describe("has:attachment"), "Messages that contain attachments"); + assert.equal(describe("has:link"), "Messages with links"); + assert.equal(describe("has:image"), "Messages with images"); + assert.equal(describe("has:attachment"), "Messages with attachments"); query = "-h"; suggestions = get_suggestions(query); expected = ["-h", "-has:link", "-has:image", "-has:attachment", "-has:reaction"]; assert.deepEqual(suggestions.strings, expected); - assert.equal(describe("-has:link"), "Exclude messages that contain links"); - assert.equal(describe("-has:image"), "Exclude messages that contain images"); - assert.equal(describe("-has:attachment"), "Exclude messages that contain attachments"); + assert.equal(describe("-has:link"), "Exclude messages with links"); + assert.equal(describe("-has:image"), "Exclude messages with images"); + assert.equal(describe("-has:attachment"), "Exclude messages with attachments"); // operand suggestions follow.