mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-56090 Group Search fix (#26128)
* make group search on modal and invite to work like group mentions * update tests for better coverage * change it back to startsWith * update test --------- Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
parent
18f7c3775a
commit
b0015c5a5d
@ -9,9 +9,9 @@ describe('group utils', () => {
|
||||
describe('filterGroupsMatchingTerm', () => {
|
||||
const groupA = {
|
||||
id: 'groupid1',
|
||||
name: 'board-group',
|
||||
name: 'board.group',
|
||||
description: 'group1 description',
|
||||
display_name: 'board-group',
|
||||
display_name: 'board.group',
|
||||
source: 'ldap',
|
||||
remote_id: 'group1',
|
||||
create_at: 1,
|
||||
@ -39,7 +39,7 @@ describe('group utils', () => {
|
||||
};
|
||||
const groupC = {
|
||||
id: 'groupid3',
|
||||
name: 'software-engineers',
|
||||
name: 'softwareengineers',
|
||||
description: 'group3 description',
|
||||
display_name: 'software engineers',
|
||||
source: 'ldap',
|
||||
@ -63,7 +63,7 @@ describe('group utils', () => {
|
||||
});
|
||||
|
||||
it('should match by name', () => {
|
||||
expect(filterGroupsMatchingTerm(groups, 'software-engineers')).toEqual([groupC]);
|
||||
expect(filterGroupsMatchingTerm(groups, 'softwareengineers')).toEqual([groupC]);
|
||||
});
|
||||
|
||||
it('should match by split part of the name', () => {
|
||||
@ -71,6 +71,10 @@ describe('group utils', () => {
|
||||
expect(filterGroupsMatchingTerm(groups, 'board')).toEqual([groupA]);
|
||||
});
|
||||
|
||||
it('should match by split part of the display name', () => {
|
||||
expect(filterGroupsMatchingTerm(groups, 'engineers')).toEqual([groupC]);
|
||||
});
|
||||
|
||||
it('should match by display_name fully', () => {
|
||||
expect(filterGroupsMatchingTerm(groups, 'software engineers')).toEqual([groupC]);
|
||||
});
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
import type {Group} from '@mattermost/types/groups';
|
||||
|
||||
import {getSuggestionsSplitByMultiple} from './user_utils';
|
||||
import {getSuggestionsSplitBy, getSuggestionsSplitByMultiple} from './user_utils';
|
||||
|
||||
import {General} from '../constants';
|
||||
|
||||
@ -11,7 +11,7 @@ export function filterGroupsMatchingTerm(groups: Group[], term: string): Group[]
|
||||
const lowercasedTerm = term.toLowerCase();
|
||||
let trimmedTerm = lowercasedTerm;
|
||||
if (trimmedTerm.startsWith('@')) {
|
||||
trimmedTerm = trimmedTerm.substr(1);
|
||||
trimmedTerm = trimmedTerm.slice(1);
|
||||
}
|
||||
|
||||
return groups.filter((group: Group) => {
|
||||
@ -22,10 +22,10 @@ export function filterGroupsMatchingTerm(groups: Group[], term: string): Group[]
|
||||
const groupSuggestions: string[] = [];
|
||||
|
||||
const groupnameSuggestions = getSuggestionsSplitByMultiple((group.name || '').toLowerCase(), General.AUTOCOMPLETE_SPLIT_CHARACTERS);
|
||||
|
||||
groupSuggestions.push(...groupnameSuggestions);
|
||||
const displayname = (group.display_name || '').toLowerCase();
|
||||
groupSuggestions.push(displayname);
|
||||
|
||||
const suggestions = getSuggestionsSplitBy(group.display_name.toLowerCase(), ' ');
|
||||
groupSuggestions.push(...suggestions);
|
||||
|
||||
return groupSuggestions.
|
||||
filter((suggestion) => suggestion !== '').
|
||||
|
Loading…
Reference in New Issue
Block a user