feat(server): /api/info aggregator + frontend version footer

Sprint 2 of autonomous trainer day 2026-05-05. Mistral-implemented
through ICM workspace ship-info-aggregator (bootstrapped backend +
BDD before hitting price limit at stage 02), Claude-completed for
frontend + Playwright + verifier + PR.

Backend:
- GET /api/info aggregator returning version, commit_short, build_date,
  uptime_seconds, cache_enabled, healthz_status (single round trip)
- Optional cache via existing cache service (X-Cache: HIT/MISS)
- BDD scenario @critical covers happy path + version regex; cache
  scenario kept under @skip @bdd-deferred until BDD harness gains a
  cache-enabled mode

Frontend:
- AppFooterView (dumb) + AppFooter (smart wrapper, useFetch) following
  the HealthDashboard / HealthDashboardView pattern
- layouts/default.vue auto-applied via NuxtLayout in app.vue
- humaniseUptime helper in utils/
- Playwright tests use route.fulfill mocking (decoupled from dev-proxy
  infra), assert visible AND content (PR #32 lesson)

Docs:
- documentation/API.md /api/info entry with schema and rationale
- ADR-0026 documents composite endpoint vs separate calls choice

Verifier verdict (skill-driven, audit at stage 04): APPROVE_WITH_NITS.
Nits: handleInfo is 51 lines (could split into builder + emitter);
X-Cache: DISABLED could improve ops clarity.

Out-of-scope follow-up: existing tests/e2e/health.spec.ts happy path
hits the same dev-proxy infra issue as my footer happy path before
mocking. Same fix (server: false + route.fulfill) would apply.
This commit is contained in:
2026-05-05 08:28:00 +02:00
parent 4a3f1bb138
commit 4d2e0c1a42
16 changed files with 587 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ package steps
import (
"fmt"
"regexp"
"strings"
"dance-lessons-coach/pkg/bdd/testserver"
@@ -99,3 +100,69 @@ func (s *CommonSteps) theFieldShouldEqual(field, expectedValue string) error {
}
return nil
}
// Regex field matching
func (s *CommonSteps) theFieldShouldMatch(field, pattern string) error {
body := string(s.client.GetLastBody())
// Extract the value of the field from JSON
// Look for "field":"value" and extract value
fieldPattern := `"` + field + `":"([^"]*)"`
re := regexp.MustCompile(fieldPattern)
matches := re.FindStringSubmatch(body)
if matches == nil {
// Try without quotes (for numbers)
fieldPatternNum := `"` + field + `":(\d+\.?\d*)`
reNum := regexp.MustCompile(fieldPatternNum)
matches = reNum.FindStringSubmatch(body)
if matches == nil {
return fmt.Errorf("field %q not found in response: %s", field, body)
}
}
// matches[1] contains the value
value := matches[1]
// Compile and match the pattern
regex, err := regexp.Compile(pattern)
if err != nil {
return fmt.Errorf("invalid regex pattern %q: %v", pattern, err)
}
if !regex.MatchString(value) {
return fmt.Errorf("field %q value %q does not match pattern %q", field, value, pattern)
}
return nil
}
// Response is JSON check
func (s *CommonSteps) theResponseShouldBeJSON() error {
body := string(s.client.GetLastBody())
// Simple check for JSON structure
body = strings.TrimSpace(body)
if !strings.HasPrefix(body, "{") && !strings.HasPrefix(body, "[") {
return fmt.Errorf("response is not JSON: %s", body)
}
return nil
}
// Response contains field (simple string containment in body)
func (s *CommonSteps) theResponseShouldContain(field string) error {
body := string(s.client.GetLastBody())
if !strings.Contains(body, `"`+field+`"`) {
return fmt.Errorf("response does not contain field %q: %s", field, body)
}
return nil
}
// Response header validation
func (s *CommonSteps) theResponseHeader(header, expectedValue string) error {
resp := s.client.GetLastResponse()
if resp == nil {
return fmt.Errorf("no response captured for header check")
}
headerValue := resp.Header.Get(header)
if headerValue != expectedValue {
return fmt.Errorf("header %q expected %q, got %q", header, expectedValue, headerValue)
}
return nil
}