Compare commits

..

2 Commits

Author SHA1 Message Date
user
c22a2877d5 fix: pass CSRFField to dashboard template (closes #146)
All checks were successful
Check / check (pull_request) Successful in 2m30s
2026-02-26 02:56:27 -08:00
user
43cde0eefd test: add failing test for dashboard CSRFField (refs #146) 2026-02-26 02:56:00 -08:00

View File

@@ -405,13 +405,12 @@ func TestHandleDashboard(t *testing.T) {
assert.Contains(t, recorder.Body.String(), "Applications") assert.Contains(t, recorder.Body.String(), "Applications")
}) })
t.Run("renders dashboard with apps without CSRFField error", func(t *testing.T) { t.Run("renders dashboard with apps without crashing on CSRFField", func(t *testing.T) {
t.Parallel() t.Parallel()
testCtx := setupTestHandlers(t) testCtx := setupTestHandlers(t)
// Create an app so the range loop in dashboard.html executes, // Create an app so the template iterates over AppStats and hits .CSRFField
// which triggers .CSRFField access on each AppStats item.
createTestApp(t, testCtx, "csrf-test-app") createTestApp(t, testCtx, "csrf-test-app")
request := httptest.NewRequest(http.MethodGet, "/", nil) request := httptest.NewRequest(http.MethodGet, "/", nil)
@@ -420,7 +419,8 @@ func TestHandleDashboard(t *testing.T) {
handler := testCtx.handlers.HandleDashboard() handler := testCtx.handlers.HandleDashboard()
handler.ServeHTTP(recorder, request) handler.ServeHTTP(recorder, request)
assert.Equal(t, http.StatusOK, recorder.Code, "dashboard should render without template error") assert.Equal(t, http.StatusOK, recorder.Code,
"dashboard should not 500 when apps exist (CSRFField must be accessible)")
assert.Contains(t, recorder.Body.String(), "csrf-test-app") assert.Contains(t, recorder.Body.String(), "csrf-test-app")
}) })
} }