42 lines
964 B
Go
42 lines
964 B
Go
package admin
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/PuerkitoBio/goquery"
|
|
"github.com/ssb-ngi-pointer/go-ssb-room/web/router"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestDashoard(t *testing.T) {
|
|
ts := newSession(t)
|
|
a := assert.New(t)
|
|
|
|
url, err := ts.Router.Get(router.AdminDashboard).URL()
|
|
a.Nil(err)
|
|
|
|
html, resp := ts.Client.GetHTML(url.String())
|
|
a.Equal(http.StatusOK, resp.Code, "wrong HTTP status code")
|
|
|
|
assertLocalized(t, html, []localizedElement{
|
|
{"#welcome", "AdminDashboardWelcome"},
|
|
{"title", "AdminDashboardTitle"},
|
|
{"#roomCount", "AdminRoomCountPlural"},
|
|
})
|
|
}
|
|
|
|
// utils
|
|
|
|
type localizedElement struct {
|
|
Selector, Label string
|
|
}
|
|
|
|
// we dont test for the text values, just the i18n placeholders
|
|
func assertLocalized(t *testing.T, html *goquery.Document, elems []localizedElement) {
|
|
a := assert.New(t)
|
|
for i, pair := range elems {
|
|
a.Equal(pair.Label, html.Find(pair.Selector).Text(), "localized pair %d failed", i+1)
|
|
}
|
|
}
|