use more robust identifier for test
This commit is contained in:
parent
a5f7701437
commit
c6077337d1
@ -68,7 +68,6 @@ func (c Config) SetPrivacyMode(ctx context.Context, pm roomdb.PrivacyMode) error
|
||||
return nil // alles gut!!
|
||||
}
|
||||
|
||||
// TODO: use proper language tag from "golang.org/x/text/language"?
|
||||
func (c Config) GetDefaultLanguage(ctx context.Context) (string, error) {
|
||||
config, err := models.FindConfig(ctx, c.db, configRowID)
|
||||
if err != nil {
|
||||
|
@ -21,8 +21,8 @@ import (
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/roomstate"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/web"
|
||||
weberrors "github.com/ssb-ngi-pointer/go-ssb-room/web/errors"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/web/router"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/web/i18n"
|
||||
"github.com/ssb-ngi-pointer/go-ssb-room/web/router"
|
||||
)
|
||||
|
||||
// HTMLTemplates define the list of files the template system should load.
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
||||
/* can't test English atm due to web/i18n/i18ntesting/testing.go:justTheKeys, which generates translations that are just
|
||||
* translationLabel = "translationLabel"
|
||||
*/
|
||||
|
@ -116,7 +116,7 @@ func TestInviteConsumeInviteHTTP(t *testing.T) {
|
||||
doc, resp := ts.Client.GetHTML(validAcceptURL)
|
||||
a.Equal(http.StatusOK, resp.Code)
|
||||
|
||||
form := doc.Find("form#consume")
|
||||
form := doc.Find("form#inviteConsume")
|
||||
r.Equal(1, form.Length())
|
||||
|
||||
consumeInviteURLString, has := form.Attr("action")
|
||||
@ -131,7 +131,7 @@ func TestInviteConsumeInviteHTTP(t *testing.T) {
|
||||
})
|
||||
|
||||
// get the corresponding token from the page
|
||||
csrfTokenElem := doc.Find(`form[action="/invite/consume"] input[name="gorilla.csrf.Token"]`)
|
||||
csrfTokenElem := form.Find(`input[name="gorilla.csrf.Token"]`)
|
||||
a.Equal(1, csrfTokenElem.Length())
|
||||
csrfName, has := csrfTokenElem.Attr("name")
|
||||
a.True(has, "should have a name attribute")
|
||||
|
@ -92,7 +92,7 @@ func TestNoticesEditButtonVisible(t *testing.T) {
|
||||
csrfCookie := resp.Result().Cookies()
|
||||
a.True(len(csrfCookie) > 0, "should have one cookie for CSRF protection validation")
|
||||
|
||||
csrfTokenElem := doc.Find(`form[action="/fallback/finalize"] input[type="hidden"]`)
|
||||
csrfTokenElem := doc.Find(`form#password-fallback input[type="hidden"]`)
|
||||
a.Equal(1, csrfTokenElem.Length())
|
||||
|
||||
csrfName, has := csrfTokenElem.Attr("name")
|
||||
|
@ -1,7 +1,6 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
@ -17,13 +16,11 @@ func TestLanguageDefaultNoCookie(t *testing.T) {
|
||||
ts := setup(t)
|
||||
a := assert.New(t)
|
||||
route := ts.URLTo(router.CompleteIndex)
|
||||
postEndpoint := ts.URLTo(router.CompleteSetLanguage)
|
||||
formAction := postEndpoint.Path
|
||||
|
||||
html, res := ts.Client.GetHTML(route)
|
||||
a.Equal(http.StatusOK, res.Code, "wrong HTTP status code")
|
||||
|
||||
languageForms := html.Find(fmt.Sprintf(`form[action="%s"]`, formAction))
|
||||
languageForms := html.Find("#visitor-set-language form")
|
||||
// two languages: english, deutsch => two <form> elements
|
||||
a.Equal(2, languageForms.Length())
|
||||
|
||||
@ -40,13 +37,12 @@ func TestLanguageChooseGerman(t *testing.T) {
|
||||
a := assert.New(t)
|
||||
route := ts.URLTo(router.CompleteIndex)
|
||||
postEndpoint := ts.URLTo(router.CompleteSetLanguage)
|
||||
formAction := postEndpoint.Path
|
||||
|
||||
html, res := ts.Client.GetHTML(route)
|
||||
a.Equal(http.StatusOK, res.Code, "wrong HTTP status code")
|
||||
|
||||
csrfTokenElem := html.Find(fmt.Sprintf(`form[action="%s"] input[type="hidden"]`, formAction))
|
||||
a.Equal(6, csrfTokenElem.Length())
|
||||
csrfTokenElem := html.Find(`#visitor-set-language input[name="gorilla.csrf.Token"]`)
|
||||
a.Equal(2, csrfTokenElem.Length())
|
||||
|
||||
csrfName, has := csrfTokenElem.First().Attr("name")
|
||||
a.True(has, "should have a name attribute")
|
||||
|
@ -98,7 +98,7 @@
|
||||
class="mb-2 mx-auto px-3 py-1 text-gray-500 w-32 rounded shadow bg-gray-50 ring-1 ring-gray-300 hover:bg-gray-100 cursor-pointer">
|
||||
Language
|
||||
</summary>
|
||||
<div class="grid grid-cols-2 justify-items-center gap-x-1">
|
||||
<div id="visitor-set-language" class="grid grid-cols-2 justify-items-center gap-x-1">
|
||||
{{ list_languages $setLanguageUrl "text-gray-500 hover:underline cursor-pointer" }}
|
||||
</div>
|
||||
</details>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<span id="welcome" class="text-center mt-8">{{i18n "InviteInsertWelcome"}}</span>
|
||||
|
||||
<form
|
||||
id="consume"
|
||||
id="inviteConsume"
|
||||
action="{{urlTo "complete:invite:consume"}}"
|
||||
method="POST"
|
||||
class="flex flex-col items-center self-stretch"
|
||||
|
Loading…
Reference in New Issue
Block a user