v0.280.0: the setup gate (decision 46); R-710 'I changed it' + absent-record window; R-709 password fields off the page; password:N:special generator
gates / gates (push) Successful in 25s
gates / gates (push) Successful in 25s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"gitea.dooplex.hu/admin/felhom-controller/internal/stacks"
|
||||
)
|
||||
|
||||
// v0.280.0 — the app page's two new presses render only where they belong (one render per branch: a seam built
|
||||
// and never wired is this project's commonest silent defect). ASCII fragments of the Hungarian copy.
|
||||
func renderAppInfoWith(t *testing.T, extra map[string]interface{}) string {
|
||||
t.Helper()
|
||||
s := securityHarness(t)
|
||||
s.loadTemplates()
|
||||
data := map[string]interface{}{
|
||||
"Page": "stacks", "Title": "T", "Domain": "example.hu",
|
||||
"Stack": stacks.Stack{Name: "gapp", Deployed: true, State: "running"},
|
||||
"Meta": stacks.Metadata{DisplayName: "G", Slug: "gapp"},
|
||||
"AppInfo": stacks.AppInfo{Tagline: "t", DefaultCreds: "admin / admin123"}, "HasAppInfo": true,
|
||||
"CSRFToken": "tok",
|
||||
}
|
||||
for k, v := range extra {
|
||||
data[k] = v
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
if err := s.tmpl.ExecuteTemplate(&buf, "app_info", data); err != nil {
|
||||
t.Fatalf("render: %v", err)
|
||||
}
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
func TestSetupGatePage_TheCardAndItsButton(t *testing.T) {
|
||||
closedNoProbe := renderAppInfoWith(t, map[string]interface{}{"SetupGateClosed": true})
|
||||
if !strings.Contains(closedNoProbe, `id="setup-gate-card"`) || !strings.Contains(closedNoProbe, "/apps/gapp/setup-gate/open") || !strings.Contains(closedNoProbe, "Kész, beállítottam") {
|
||||
t.Fatal("closed, no probe: the card or its button is missing")
|
||||
}
|
||||
closedProbe := renderAppInfoWith(t, map[string]interface{}{"SetupGateClosed": true, "SetupGateHasProbe": true})
|
||||
if !strings.Contains(closedProbe, `id="setup-gate-card"`) || strings.Contains(closedProbe, "/apps/gapp/setup-gate/open") || !strings.Contains(closedProbe, "magától észreveszi") {
|
||||
t.Fatal("closed with a probe: want the card and the 'notices it by itself' line, no button")
|
||||
}
|
||||
if open := renderAppInfoWith(t, nil); strings.Contains(open, `id="setup-gate-card"`) {
|
||||
t.Fatal("an app with no closed gate shows the gate card")
|
||||
}
|
||||
}
|
||||
|
||||
func TestKnownLoginPage_TheChangedItButton(t *testing.T) {
|
||||
warn := renderAppInfoWith(t, map[string]interface{}{"KnownLoginLine": "This app starts with a known, shared password: admin / admin123."})
|
||||
if !strings.Contains(warn, "/apps/gapp/default-login/changed") || !strings.Contains(warn, "Megv") {
|
||||
t.Fatal("the default is named, but there is no 'I changed it' press")
|
||||
}
|
||||
if plain := renderAppInfoWith(t, nil); strings.Contains(plain, "/apps/gapp/default-login/changed") {
|
||||
t.Fatal("'I changed it' shown with no default named")
|
||||
}
|
||||
if replaced := renderAppInfoWith(t, map[string]interface{}{"DefaultLoginReplaced": true, "KnownLoginLine": ""}); strings.Contains(replaced, "admin / admin123") {
|
||||
t.Fatal("the default card is still shown after it was replaced")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user