557629d2bf
gates / gates (push) Successful in 2m3s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
47 lines
1.8 KiB
Go
47 lines
1.8 KiB
Go
package web
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
"gitea.dooplex.hu/admin/felhom-hub/internal/i18n"
|
|
)
|
|
|
|
// R-725: the expired bind page that SHOWS the „Új linket kérek" button must point the household at the
|
|
// button, not send them to support („kérj újat az ügyfélszolgálattól") above it. The page without a
|
|
// button (no token: rate-limited / not found) keeps the sentence that names another way.
|
|
// ASCII fragment "szolg" is the support word; the no-button page is its positive control.
|
|
func TestBindExpiredPage_PointsAtTheButton(t *testing.T) {
|
|
b := i18n.Shared()
|
|
s, st := newTestServer(t)
|
|
seedForMint(t, st, "tester", "tester1@felhom.example")
|
|
old := mintLink(t, st, "tester", -time.Hour)
|
|
|
|
withButton := bindGET(t, s, old).Body.String()
|
|
if !strings.Contains(withButton, "/bind/"+old+"/resend") {
|
|
t.Fatal("precondition: the expired page carries the resend button")
|
|
}
|
|
if !strings.Contains(withButton, b.Msg("hu", "bind.invalid.body_resend")) {
|
|
t.Error("the expired page with a button does not carry the sentence that points at it")
|
|
}
|
|
if strings.Contains(withButton, "szolg") {
|
|
t.Error("the expired page with a button still sends the household to support")
|
|
}
|
|
|
|
// Positive control: the no-button page still carries the support sentence (the fragment is live).
|
|
rr := httptest.NewRecorder()
|
|
s.renderBind(rr, http.StatusNotFound, bindPageData{State: "expired", Lang: i18n.Default})
|
|
noButton := rr.Body.String()
|
|
if !strings.Contains(noButton, "szolg") || strings.Contains(noButton, "/resend") {
|
|
t.Errorf("no-button page: want the support sentence and no resend form")
|
|
}
|
|
|
|
// English twin: present, different, and pointing at the button.
|
|
if en := b.Msg("en", "bind.invalid.body_resend"); !strings.Contains(en, "button below") {
|
|
t.Errorf("English twin = %q, want it to point at the button", en)
|
|
}
|
|
}
|