D1 Part 2: settings.html split into four pages + sidebar restructure

- settings.html (1451 lines) deleted; sections moved verbatim into
  settings_system.html (Rendszer konfiguráció, Verzió és frissítés,
  Vezérlő/Kiszolgáló újraindítása + update/restart JS),
  settings_notifications.html (Értesítések, Alkalmazás-email),
  settings_security.html (Jelszó módosítás, Földrajzi korlátozás + geo
  JS, Vészhelyzeti információk — heading + section copy accents fixed),
  storage.html (Adattárolók, NAS, migrate progress, agent view + all
  storage JS; wizard entry links now /storage/init|attach with sprite
  icons instead of emoji). The NAS + migrate sections were nested inside
  {{if .StoragePaths}} in the monolith and vanished with zero drives —
  now unconditional on /storage.
- layout.html: Tárhely main-nav item (hard-drive icon) + the
  'Beállítások' sidebar group with Rendszer / Értesítések / Biztonság és
  hozzáférés sub-links (active-state per page key); orphaned
  .sidebar-settings-link CSS deleted (grep-zero), .nav-group-label /
  .nav-links-sub added.
- Handlers wired to their own builders + templates; the legacy
  settingsData() merge deleted.
- scripts/template_id_gate.py: the §10 JS element-ID integrity gate
  (getElementById/querySelector('#…') must resolve in the SAME template;
  JS-created + template-parameterized IDs handled; layout modal IDs
  allowlisted). Red-proven: a storage function planted in the
  notifications template failed the gate with 'static #migrate-progress
  not defined'.
- Tests: per-page section markers + cross-leak assertions, h3 section
  inventory (all 11 old headings accounted for; typo rename asserted).
This commit is contained in:
2026-07-02 19:07:32 +02:00
parent d50a919404
commit f8e18a9ec9
9 changed files with 1062 additions and 890 deletions
+70 -5
View File
@@ -50,15 +50,80 @@ func getPage(t *testing.T, s *Server, path string) *httptest.ResponseRecorder {
return rec
}
// TestSettingsSplitPagesRender (D1 Scenario A skeleton): the four pages respond 200.
// Per-page unique-section markers are asserted once the template split lands (Part 2).
// TestSettingsSplitPagesRender (D1 Scenario A): each page responds 200, carries its own
// sections, and does NOT carry another page's sections (no cross-leak).
func TestSettingsSplitPagesRender(t *testing.T) {
s := testPageServer(t)
for _, path := range []string{"/settings", "/settings/notifications", "/settings/security", "/storage"} {
rec := getPage(t, s, path)
cases := []struct {
path string
must []string
mustNot []string
}{
{"/settings",
[]string{"Rendszer konfiguráció", "Verzió és frissítés", "Vezérlő újraindítása", "Kiszolgáló újraindítása"},
[]string{"Adattárolók", "Jelszó módosítás", "Értesítési szünet"}},
{"/settings/notifications",
[]string{"Beállítások — Értesítések"},
[]string{"Rendszer konfiguráció", "Adattárolók", "Jelszó módosítás"}},
{"/settings/security",
[]string{"Jelszó módosítás", "Földrajzi korlátozás"},
[]string{"Rendszer konfiguráció", "Adattárolók", "Értesítési szünet"}},
{"/storage",
[]string{"Adattárolók", "Hálózati tárhely (NAS)"},
[]string{"Rendszer konfiguráció", "Jelszó módosítás", "Értesítési szünet"}},
}
for _, c := range cases {
rec := getPage(t, s, c.path)
if rec.Code != 200 {
t.Errorf("GET %s = %d, want 200", path, rec.Code)
t.Errorf("GET %s = %d, want 200", c.path, rec.Code)
continue
}
body := rec.Body.String()
for _, m := range c.must {
if !strings.Contains(body, m) {
t.Errorf("GET %s: missing section %q", c.path, m)
}
}
for _, m := range c.mustNot {
if strings.Contains(body, m) {
t.Errorf("GET %s: leaked foreign section %q", c.path, m)
}
}
}
}
// TestSettingsSectionInventory (D1 §10): every h3 section of the pre-split settings.html is
// accounted for in the UNION of the four split templates (one deliberate rename noted).
func TestSettingsSectionInventory(t *testing.T) {
oldHeadings := []string{
"Rendszer konfiguráció",
"Verzió és frissítés",
"Adattárolók",
"Hálózati tárhely (NAS)",
"Földrajzi korlátozás",
"Jelszó módosítás",
"Értesítések",
"Alkalmazás-email",
"Vészhelyzeti információk", // renamed from the misspelled "Veszhelyzeti informaciok"
"Vezérlő újraindítása",
"Kiszolgáló újraindítása",
}
var union strings.Builder
for _, f := range []string{"settings_system.html", "settings_notifications.html", "settings_security.html", "storage.html"} {
b, err := templateFS.ReadFile("templates/" + f)
if err != nil {
t.Fatalf("read %s: %v", f, err)
}
union.Write(b)
}
u := union.String()
for _, h := range oldHeadings {
if !strings.Contains(u, h) {
t.Errorf("old settings section %q missing from the union of the split templates", h)
}
}
if strings.Contains(u, "Veszhelyzeti informaciok") {
t.Error("the misspelled heading survived the split")
}
}