mirror of
https://github.com/mattermost/focalboard.git
synced 2024-12-24 13:43:12 +02:00
56 lines
1.4 KiB
Go
56 lines
1.4 KiB
Go
|
package integrationtests
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/mattermost/focalboard/server/client"
|
||
|
"github.com/mattermost/focalboard/server/model"
|
||
|
"github.com/stretchr/testify/require"
|
||
|
)
|
||
|
|
||
|
func TestStatisticsLocalMode(t *testing.T) {
|
||
|
th := SetupTestHelper(t).InitBasic()
|
||
|
defer th.TearDown()
|
||
|
|
||
|
t.Run("an unauthenticated client should not be able to get statistics", func(t *testing.T) {
|
||
|
th.Logout(th.Client)
|
||
|
|
||
|
stats, resp := th.Client.GetStatistics()
|
||
|
th.CheckUnauthorized(resp)
|
||
|
require.Nil(t, stats)
|
||
|
})
|
||
|
|
||
|
t.Run("Check authenticated user, not admin", func(t *testing.T) {
|
||
|
th.Login1()
|
||
|
|
||
|
stats, resp := th.Client.GetStatistics()
|
||
|
th.CheckNotImplemented(resp)
|
||
|
require.Nil(t, stats)
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func TestStatisticsPluginMode(t *testing.T) {
|
||
|
th := SetupTestHelperPluginMode(t)
|
||
|
defer th.TearDown()
|
||
|
|
||
|
// Permissions are tested in permissions_test.go
|
||
|
// This tests the functionality.
|
||
|
t.Run("Check authenticated user, admin", func(t *testing.T) {
|
||
|
th.Client = client.NewClient(th.Server.Config().ServerRoot, "")
|
||
|
th.Client.HTTPHeader["Mattermost-User-Id"] = userAdmin
|
||
|
|
||
|
stats, resp := th.Client.GetStatistics()
|
||
|
th.CheckOK(resp)
|
||
|
require.NotNil(t, stats)
|
||
|
|
||
|
numberCards := 2
|
||
|
th.CreateBoardAndCards("testTeam", model.BoardTypeOpen, numberCards)
|
||
|
|
||
|
stats, resp = th.Client.GetStatistics()
|
||
|
th.CheckOK(resp)
|
||
|
require.NotNil(t, stats)
|
||
|
require.Equal(t, 1, stats.Boards)
|
||
|
require.Equal(t, numberCards, stats.Cards)
|
||
|
})
|
||
|
}
|