mirror of
https://github.com/mattermost/focalboard.git
synced 2024-12-21 13:38:56 +02:00
e3ae682eea
* initial commit for displaying board statistics * lint fixes * i18n-extract, remove log entries, cleanup * more lint fixes * add check for standalone mode * update tests due to change to NotImplemented * lint fix * revert removing empty comment lines Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
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)
|
|
})
|
|
}
|