MM-14461: make @-mentions (and searches) case insensitive (#2641)
This commit is contained in:
parent
8719d3f227
commit
692953e860
2 changed files with 60 additions and 1 deletions
|
|
@ -27,7 +27,7 @@ export const getMatchTermForAtMention = (() => {
|
|||
lastValue = value;
|
||||
lastIsSearch = isSearch;
|
||||
if (match) {
|
||||
lastMatchTerm = isSearch ? match[1] : match[2];
|
||||
lastMatchTerm = (isSearch ? match[1] : match[2]).toLowerCase();
|
||||
} else {
|
||||
lastMatchTerm = null;
|
||||
}
|
||||
|
|
|
|||
59
app/selectors/autocomplete.test.js
Normal file
59
app/selectors/autocomplete.test.js
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import assert from 'assert';
|
||||
|
||||
import {
|
||||
getMatchTermForAtMention,
|
||||
} from 'app/selectors/autocomplete';
|
||||
|
||||
/* eslint-disable max-nested-callbacks */
|
||||
|
||||
describe('Selectors.Autocomplete', () => {
|
||||
describe('getMatchTermForAtMention', () => {
|
||||
describe('match non-search at mentions', () => {
|
||||
const testCases = [
|
||||
['@', ''],
|
||||
['@a', 'a'],
|
||||
['@match', 'match'],
|
||||
['@Username', 'username'],
|
||||
['@USERNAME', 'username'],
|
||||
['not a match', null],
|
||||
];
|
||||
|
||||
testCases.forEach((testCase) => {
|
||||
it(testCase[0], () => {
|
||||
const value = testCase[0];
|
||||
const isSearch = false;
|
||||
const expected = testCase[1];
|
||||
const actual = getMatchTermForAtMention(value, isSearch);
|
||||
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('match search at mentions', () => {
|
||||
const testCases = [
|
||||
['from:', ''],
|
||||
['from:a', 'a'],
|
||||
['from:match', 'match'],
|
||||
['from:not a match', null],
|
||||
['from:Username', 'username'],
|
||||
['from:USERNAME', 'username'],
|
||||
['from: space', 'space'],
|
||||
];
|
||||
|
||||
testCases.forEach((testCase) => {
|
||||
it(testCase[0], () => {
|
||||
const value = testCase[0];
|
||||
const isSearch = true;
|
||||
const expected = testCase[1];
|
||||
const actual = getMatchTermForAtMention(value, isSearch);
|
||||
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue