mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 11:44:49 +08:00
FIX: Search checkboxes incorrectly being checked on similar prefix.
Incorrect search filters like `in:personalasd` will end up checking the checkbox for `in:personal` because the regexp used was only doing prefix matching.
This commit is contained in:
parent
7f2f87bf59
commit
521782fc9c
|
@ -21,10 +21,10 @@ const REGEXP_MIN_POST_COUNT_PREFIX = /^min_post_count:/gi;
|
||||||
const REGEXP_POST_TIME_PREFIX = /^(before|after):/gi;
|
const REGEXP_POST_TIME_PREFIX = /^(before|after):/gi;
|
||||||
const REGEXP_TAGS_REPLACE = /(^(tags?:|#(?=[a-z0-9\-]+::tag))|::tag\s?$)/gi;
|
const REGEXP_TAGS_REPLACE = /(^(tags?:|#(?=[a-z0-9\-]+::tag))|::tag\s?$)/gi;
|
||||||
|
|
||||||
const REGEXP_SPECIAL_IN_LIKES_MATCH = /^in:likes/gi;
|
const REGEXP_SPECIAL_IN_LIKES_MATCH = /^in:likes$/gi;
|
||||||
const REGEXP_SPECIAL_IN_TITLE_MATCH = /^in:title/gi;
|
const REGEXP_SPECIAL_IN_TITLE_MATCH = /^in:title$/gi;
|
||||||
const REGEXP_SPECIAL_IN_PERSONAL_MATCH = /^in:personal/gi;
|
const REGEXP_SPECIAL_IN_PERSONAL_MATCH = /^in:personal$/gi;
|
||||||
const REGEXP_SPECIAL_IN_SEEN_MATCH = /^in:seen/gi;
|
const REGEXP_SPECIAL_IN_SEEN_MATCH = /^in:seen$/gi;
|
||||||
|
|
||||||
const REGEXP_CATEGORY_SLUG = /^(\#[a-zA-Z0-9\-:]+)/gi;
|
const REGEXP_CATEGORY_SLUG = /^(\#[a-zA-Z0-9\-:]+)/gi;
|
||||||
const REGEXP_CATEGORY_ID = /^(category:[0-9]+)/gi;
|
const REGEXP_CATEGORY_ID = /^(category:[0-9]+)/gi;
|
||||||
|
|
|
@ -188,6 +188,13 @@ QUnit.test(
|
||||||
"none in:title",
|
"none in:title",
|
||||||
'has updated search term to "none in:title"'
|
'has updated search term to "none in:title"'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await fillIn(".search-query", "none in:titleasd");
|
||||||
|
|
||||||
|
assert.not(
|
||||||
|
exists(".search-advanced-options .in-title:checked"),
|
||||||
|
"does not populate title only checkbox"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -221,11 +228,19 @@ QUnit.test(
|
||||||
exists(".search-advanced-options .in-private:checked"),
|
exists(".search-advanced-options .in-private:checked"),
|
||||||
'has "are in my messages" populated'
|
'has "are in my messages" populated'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
find(".search-query").val(),
|
find(".search-query").val(),
|
||||||
"none in:personal",
|
"none in:personal",
|
||||||
'has updated search term to "none in:personal"'
|
'has updated search term to "none in:personal"'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await fillIn(".search-query", "none in:personal-direct");
|
||||||
|
|
||||||
|
assert.not(
|
||||||
|
exists(".search-advanced-options .in-private:checked"),
|
||||||
|
"does not populate messages checkbox"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -246,6 +261,13 @@ QUnit.test(
|
||||||
"none in:seen",
|
"none in:seen",
|
||||||
"it should update the search term"
|
"it should update the search term"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await fillIn(".search-query", "none in:seenasdan");
|
||||||
|
|
||||||
|
assert.not(
|
||||||
|
exists(".search-advanced-options .in-seen:checked"),
|
||||||
|
"does not populate seen checkbox"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -382,9 +404,17 @@ QUnit.test("validate advanced search when initially empty", async (assert) => {
|
||||||
selectKit(".search-advanced-options .in-likes:checked"),
|
selectKit(".search-advanced-options .in-likes:checked"),
|
||||||
'has "I liked" populated'
|
'has "I liked" populated'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
find(".search-query").val(),
|
find(".search-query").val(),
|
||||||
"in:likes",
|
"in:likes",
|
||||||
'has updated search term to "in:likes"'
|
'has updated search term to "in:likes"'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await fillIn(".search-query", "in:likesasdas");
|
||||||
|
|
||||||
|
assert.not(
|
||||||
|
exists(".search-advanced-options .in-likes:checked"),
|
||||||
|
"does not populate the likes checkbox"
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user