M7: Frontend - HTML/JS/CSS mit dunklem Design, Vollbild, WebSocket-Updates, embed.FS-Integration

- Frontend: index.html, style.css, app.js
  - Dunkles Kontrast-Design mit Team-Farben (Rot/Grün)
  - Vollbild-Toggle, Responsive Design
  - Echtzeit-Updates über WebSocket + Polling-Fallback
  - Tastatur-Shortcuts (R/G für Punkte, N für nächste Runde)
  - Rundenverlauf mit Farbcodierung

- Go-Integration:
  - frontend.go: embed.FS für statische Dateien
  - websocket.go: WebSocket-Handler (/ws) für State-Broadcast
  - httpapi.go: broadcastState() nach jeder Mutation, /ws-Route
  - main.go: api.SetupFrontend() für Frontend-Einbettung
  - Frontend unter '/' verfügbar, API unter '/api/'

- Tests: 17 End-to-End-Tests bestanden
  - Alle HTTP-Endpunkte funktionsfähig
  - Frontend-Assets korrekt eingebettet
  - Persistenz (state.json) funktioniert
This commit is contained in:
2026-07-14 16:32:21 +02:00
parent ac9d7eff1d
commit bd05edfb9c
9 changed files with 1669 additions and 30 deletions
+25 -1
View File
@@ -12,7 +12,7 @@ import (
func newTestServer() (*Server, *logik.Scoreboard) {
sb := logik.NewScoreboard()
s := NewServer("127.0.0.1:0", sb)
s := NewServer("127.0.0.1:0", sb, nil)
return s, sb
}
@@ -325,6 +325,30 @@ func TestEndToEnd(t *testing.T) {
}
}
func TestPersistCallback(t *testing.T) {
sb := logik.NewScoreboard()
saved := false
var savedScore int
s := NewServer("127.0.0.1:0", sb, func(state interface{}) error {
saved = true
savedScore = state.(*logik.Scoreboard).RedScore
return nil
})
defer s.Close()
req := httptest.NewRequest(http.MethodPost, "/api/score?team=red", nil)
w := httptest.NewRecorder()
s.mux.ServeHTTP(w, req)
if !saved {
t.Error("persist callback was not called")
}
if savedScore != 1 {
t.Errorf("savedScore = %d, want 1", savedScore)
}
}
// contains is a simple string contains check.
func contains(s, substr string) bool {
for i := 0; i <= len(s)-len(substr); i++ {