Files
felhom.eu/hub/internal/web/r508_no_email_banner_test.go
T

34 lines
1.4 KiB
Go

package web
import (
"testing"
"gitea.dooplex.hu/admin/felhom-hub/internal/store"
)
// R-508 (hub v0.135.0): a configured customer with no box and no e-mail is told on the page — one render test per
// branch of the gate (absent with an e-mail; absent once a box is bound; present when both are missing).
// RED-PROOF (audits/hub-safety-2026-10-05/partG/red-proof.txt): set WaitingNoEmail to false → the "present" case fails.
const noEmailMarker = "No registered e-mail, and no box yet"
func TestR508_NoEmailBannerBranches(t *testing.T) {
s, st := newTestServer(t)
seedCustomer(t, st, "with-mail", "")
if contains(renderCustomerPageWithQuery(t, s, "with-mail", ""), noEmailMarker) {
t.Fatal("banner shown for a customer WITH an e-mail")
}
if err := st.SaveCustomerConfig(&store.CustomerConfig{CustomerID: "no-mail", CustomerName: "x", Domain: "x.hu",
RetrievalPassword: "pw", APIKey: "k2", Status: "active"}); err != nil {
t.Fatal(err)
}
if !contains(renderCustomerPageWithQuery(t, s, "no-mail", ""), noEmailMarker) {
t.Fatal("no banner for a waiting customer with no e-mail")
}
if err := st.UpsertHost(&store.Host{HostID: "h-no-mail", CustomerID: "no-mail", APIKey: "hk"}); err != nil {
t.Fatal(err)
}
if contains(renderCustomerPageWithQuery(t, s, "no-mail", ""), noEmailMarker) {
t.Fatal("banner shown for a customer whose box is already bound (nothing is waiting)")
}
}