[MM-41998] Channel Info RHS: display number of files for a channel (#19822)

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Julien Tant
2022-03-25 13:28:14 -07:00
коммит произвёл GitHub
родитель 1c49366f00
Коммит 0babc01749
15 изменённых файлов: 181 добавлений и 0 удалений

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

@@ -22,6 +22,7 @@ import (
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/plugin/plugintest/mock"
"github.com/mattermost/mattermost-server/v6/store/storetest/mocks"
"github.com/mattermost/mattermost-server/v6/utils/testutils"
)
func TestCreateChannel(t *testing.T) {
@@ -2507,12 +2508,24 @@ func TestGetChannelStats(t *testing.T) {
require.Equal(t, channel.Id, stats.ChannelId, "couldn't get extra info")
require.Equal(t, int64(1), stats.MemberCount, "got incorrect member count")
require.Equal(t, int64(0), stats.PinnedPostCount, "got incorrect pinned post count")
require.Equal(t, int64(0), stats.FilesCount, "got incorrect file count")
th.CreatePinnedPostWithClient(th.Client, channel)
stats, _, err = client.GetChannelStats(channel.Id, "")
require.NoError(t, err)
require.Equal(t, int64(1), stats.PinnedPostCount, "should have returned 1 pinned post count")
// create a post with a file
sent, err := testutils.ReadTestFile("test.png")
require.NoError(t, err)
fileResp, _, err := client.UploadFile(sent, channel.Id, "test.png")
require.NoError(t, err)
th.CreatePostInChannelWithFiles(channel, fileResp.FileInfos...)
// make sure the file count channel stats is updated
stats, _, err = client.GetChannelStats(channel.Id, "")
require.NoError(t, err)
require.Equal(t, int64(1), stats.FilesCount, "should have returned 1 file count")
_, resp, err := client.GetChannelStats("junk", "")
require.Error(t, err)
CheckBadRequestStatus(t, resp)