[MM-25268] Implement prefix/suffix searching on teams and channel page in system console (#14698)
* Implement prefix/suffix search on teams page * Make Channel Page prefix/suffix search as well * address PR comments * add tests * fix styling * take postgres into account * add more api tests * update test * add team store test * write store test for team and channel * fix lint * update description * revert go mod Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
92c98dac3e
Коммит
2c9c58ff50
@@ -1152,11 +1152,91 @@ func TestSearchAllChannels(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
search := &model.ChannelSearch{Term: th.BasicChannel.Name}
|
||||
channel := &model.Channel{
|
||||
DisplayName: "FOOBAR",
|
||||
Name: "whatever",
|
||||
Type: model.CHANNEL_OPEN,
|
||||
TeamId: th.BasicTeam.Id,
|
||||
}
|
||||
|
||||
// Testing Mixed Case (Ensure we get results for partial word searches)
|
||||
|
||||
// Search by using display name
|
||||
foobarchannel, err := th.SystemAdminClient.CreateChannel(channel)
|
||||
CheckNoError(t, err)
|
||||
|
||||
search := &model.ChannelSearch{Term: "oob"}
|
||||
|
||||
channels, resp := th.SystemAdminClient.SearchAllChannels(search)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
assert.Len(t, *channels, 1)
|
||||
assert.Equal(t, foobarchannel.Id, (*channels)[0].Id)
|
||||
|
||||
search = &model.ChannelSearch{Term: "foo"}
|
||||
|
||||
channels, resp = th.SystemAdminClient.SearchAllChannels(search)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
assert.Len(t, *channels, 1)
|
||||
assert.Equal(t, foobarchannel.Id, (*channels)[0].Id)
|
||||
|
||||
search = &model.ChannelSearch{Term: "bar"}
|
||||
|
||||
channels, resp = th.SystemAdminClient.SearchAllChannels(search)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
assert.Len(t, *channels, 1)
|
||||
assert.Equal(t, foobarchannel.Id, (*channels)[0].Id)
|
||||
|
||||
// Search by using Name
|
||||
search = &model.ChannelSearch{Term: "what"}
|
||||
|
||||
channels, resp = th.SystemAdminClient.SearchAllChannels(search)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
assert.Len(t, *channels, 1)
|
||||
assert.Equal(t, foobarchannel.Id, (*channels)[0].Id)
|
||||
|
||||
search = &model.ChannelSearch{Term: "ever"}
|
||||
|
||||
channels, resp = th.SystemAdminClient.SearchAllChannels(search)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
// Seach by partial word search and testing case sensitivty
|
||||
assert.Len(t, *channels, 1)
|
||||
assert.Equal(t, foobarchannel.Id, (*channels)[0].Id)
|
||||
|
||||
search = &model.ChannelSearch{Term: th.BasicChannel.Name[2:14]}
|
||||
|
||||
channels, resp = th.SystemAdminClient.SearchAllChannels(search)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
assert.Len(t, *channels, 1)
|
||||
assert.Equal(t, th.BasicChannel.Id, (*channels)[0].Id)
|
||||
|
||||
search = &model.ChannelSearch{Term: strings.ToUpper(th.BasicChannel.Name)}
|
||||
|
||||
channels, resp = th.SystemAdminClient.SearchAllChannels(search)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
assert.Len(t, *channels, 1)
|
||||
assert.Equal(t, th.BasicChannel.Id, (*channels)[0].Id)
|
||||
|
||||
search = &model.ChannelSearch{Term: th.BasicChannel.Name[0:2] + strings.ToUpper(th.BasicChannel.Name[2:5]) + th.BasicChannel.Name[5:]}
|
||||
|
||||
channels, resp = th.SystemAdminClient.SearchAllChannels(search)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
assert.Len(t, *channels, 1)
|
||||
assert.Equal(t, th.BasicChannel.Id, (*channels)[0].Id)
|
||||
|
||||
// Testing Non-Mixed Case test cases
|
||||
search = &model.ChannelSearch{Term: th.BasicChannel.Name}
|
||||
|
||||
channels, resp = th.SystemAdminClient.SearchAllChannels(search)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
assert.Len(t, *channels, 1)
|
||||
assert.Equal(t, th.BasicChannel.Id, (*channels)[0].Id)
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user