2021-02-11 15:43:19 +00:00
|
|
|
package admin
|
|
|
|
|
|
|
|
import (
|
2021-03-29 14:33:15 +00:00
|
|
|
"bytes"
|
2021-02-11 15:43:19 +00:00
|
|
|
"net/http"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/ssb-ngi-pointer/go-ssb-room/web/router"
|
2021-03-11 08:55:38 +00:00
|
|
|
"github.com/ssb-ngi-pointer/go-ssb-room/web/webassert"
|
2021-02-11 15:43:19 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
2021-03-29 14:33:15 +00:00
|
|
|
refs "go.mindeco.de/ssb-refs"
|
2021-02-11 15:43:19 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestDashoard(t *testing.T) {
|
|
|
|
ts := newSession(t)
|
|
|
|
a := assert.New(t)
|
|
|
|
|
2021-03-29 14:33:15 +00:00
|
|
|
testRef := refs.FeedRef{Algo: "test", ID: bytes.Repeat([]byte{0}, 16)}
|
|
|
|
ts.RoomState.AddEndpoint(testRef, nil) // 1 online
|
2021-03-29 15:21:26 +00:00
|
|
|
ts.MembersDB.CountReturns(4, nil) // 4 members
|
|
|
|
ts.InvitesDB.CountReturns(3, nil) // 3 invites
|
|
|
|
ts.DeniedKeysDB.CountReturns(2, nil) // 2 banned
|
2021-03-29 14:33:15 +00:00
|
|
|
|
2021-04-01 07:04:38 +00:00
|
|
|
dashURL := ts.URLTo(router.AdminDashboard)
|
2021-02-11 15:43:19 +00:00
|
|
|
|
2021-04-01 07:04:38 +00:00
|
|
|
html, resp := ts.Client.GetHTML(dashURL)
|
2021-02-11 15:43:19 +00:00
|
|
|
a.Equal(http.StatusOK, resp.Code, "wrong HTTP status code")
|
2021-02-15 13:56:17 +00:00
|
|
|
|
2021-03-29 14:33:15 +00:00
|
|
|
a.Equal("1", html.Find("#online-count").Text())
|
|
|
|
a.Equal("4", html.Find("#member-count").Text())
|
|
|
|
a.Equal("3", html.Find("#invite-count").Text())
|
|
|
|
a.Equal("2", html.Find("#denied-count").Text())
|
2021-03-29 12:25:25 +00:00
|
|
|
|
2021-03-11 08:55:38 +00:00
|
|
|
webassert.Localized(t, html, []webassert.LocalizedElement{
|
2021-02-11 15:43:19 +00:00
|
|
|
{"title", "AdminDashboardTitle"},
|
|
|
|
})
|
|
|
|
}
|