filter: Validate and parse sender:me when turning into a pill.

Fixes #31315.

We want to parse sender:me with the email when turning it into
a pill, but not before then so that "Sent by me" is still the
search string in the suggestions.
This commit is contained in:
evykassirer
2025-03-12 16:36:33 -07:00
committed by Tim Abbott
parent 673309f3dc
commit 08ed639763
3 changed files with 24 additions and 4 deletions

View File

@@ -1405,8 +1405,8 @@ test("parse", () => {
let string;
let terms;
function _test() {
const result = Filter.parse(string);
function _test(for_pills = false) {
const result = Filter.parse(string, for_pills);
assert_same_terms(result, terms);
}
@@ -1444,6 +1444,14 @@ test("parse", () => {
terms = [{operator: "sender", operand: "leo+test@zulip.com"}];
_test();
string = "sender:me";
terms = [{operator: "sender", operand: `${me.email}`}];
_test(true);
string = "-sender:me";
terms = [{operator: "sender", operand: `${me.email}`, negated: true}];
_test(true);
string = "https://www.google.com";
terms = [{operator: "search", operand: "https://www.google.com"}];
_test();
@@ -1964,6 +1972,7 @@ test("is_valid_search_term", () => {
["topic:GhostTown", true],
["dm-including:alice@example.com", true],
["sender:ghost@zulip.com", false],
["sender:me", true],
["dm:alice@example.com,ghost@example.com", false],
["dm:alice@example.com,joe@example.com", true],
];