MM-23015: Enable or disable group mentions (#14010)

* MM-23015: Enable or disable group mentions + show them in suggestion list


Co-authored-by: Catalin Tomai <catalin.tomai@mattermost.com>
Этот коммит содержится в:
catalintomai
2020-04-13 11:37:29 -07:00
коммит произвёл GitHub
родитель 0bfb063c78
Коммит b90f4f46e2
15 изменённых файлов: 777 добавлений и 102 удалений

Просмотреть файл

@@ -7,6 +7,7 @@ import (
"testing"
"github.com/mattermost/mattermost-server/v5/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -243,6 +244,45 @@ func TestGetGroupsByChannel(t *testing.T) {
require.Empty(t, groups)
}
func TestGetGroupsAssociatedToChannelsByTeam(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
group := th.CreateGroup()
// Create a group channel
groupSyncable := &model.GroupSyncable{
GroupId: group.Id,
AutoAdd: false,
SyncableId: th.BasicChannel.Id,
Type: model.GroupSyncableTypeChannel,
}
gs, err := th.App.UpsertGroupSyncable(groupSyncable)
require.Nil(t, err)
require.NotNil(t, gs)
opts := model.GroupSearchOpts{
PageOpts: &model.PageOpts{
Page: 0,
PerPage: 60,
},
}
groups, err := th.App.GetGroupsAssociatedToChannelsByTeam(th.BasicTeam.Id, opts)
require.Nil(t, err)
assert.Equal(t, map[string][]*model.GroupWithSchemeAdmin{
th.BasicChannel.Id: {
{Group: *group, SchemeAdmin: model.NewBool(false)},
},
}, groups)
require.NotNil(t, groups[th.BasicChannel.Id][0].SchemeAdmin)
groups, err = th.App.GetGroupsAssociatedToChannelsByTeam(model.NewId(), opts)
require.Nil(t, err)
require.Empty(t, groups)
}
func TestGetGroupsByTeam(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()