summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-01-13 13:41:24 -1000
committerPeter Stone <thepeterstone@gmail.com>2026-01-13 13:41:24 -1000
commit96a24772c4508cc7d088ee7b7a47c76858490446 (patch)
tree1006690df920a9ca5490b02babc9732e27af1cc5
parent81f1e7a489c62f21bb71b7402a2758735cddef57 (diff)
Fix template rendering error in notes tab (Bug 001)
Add Errors field to HandleNotes data structure to match notes-tab template expectations. The error-banner partial requires this field. - Add template_test.go with reproduction test - Update HandleNotes to include Errors field in data struct Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
-rw-r--r--internal/handlers/tabs.go6
-rw-r--r--internal/handlers/template_test.go40
2 files changed, 44 insertions, 2 deletions
diff --git a/internal/handlers/tabs.go b/internal/handlers/tabs.go
index 448dfbe..b8e7bcb 100644
--- a/internal/handlers/tabs.go
+++ b/internal/handlers/tabs.go
@@ -152,9 +152,11 @@ func (h *TabsHandler) HandleNotes(w http.ResponseWriter, r *http.Request) {
}
data := struct {
- Notes []models.Note
+ Notes []models.Note
+ Errors []string
}{
- Notes: notes,
+ Notes: notes,
+ Errors: nil,
}
// Check HX-Target header for partial update
diff --git a/internal/handlers/template_test.go b/internal/handlers/template_test.go
new file mode 100644
index 0000000..b0b2378
--- /dev/null
+++ b/internal/handlers/template_test.go
@@ -0,0 +1,40 @@
+package handlers_test
+
+import (
+ "html/template"
+ "io"
+ "testing"
+ "task-dashboard/internal/models"
+)
+
+func TestNotesTemplateRendering(t *testing.T) {
+ // Parse templates (adjust paths relative to where test runs, usually package root)
+ // Since we run 'go test ./...', paths might need to be absolute or relative to project root if we use a helper.
+ // But standard 'go test' in a subdir uses that subdir as CWD.
+ // We will assume the test runs from 'internal/handlers'.
+ // So paths are "../../web/templates/..."
+
+ tmpl, err := template.ParseGlob("../../web/templates/*.html")
+ if err != nil {
+ t.Fatalf("Failed to parse templates: %v", err)
+ }
+ tmpl, err = tmpl.ParseGlob("../../web/templates/partials/*.html")
+ if err != nil {
+ t.Fatalf("Failed to parse partials: %v", err)
+ }
+
+ // Define the data structure we EXPECT to use (with Errors)
+ data := struct {
+ Notes []models.Note
+ Errors []string
+ }{
+ Notes: []models.Note{},
+ Errors: []string{"Test Error"},
+ }
+
+ // Execute
+ err = tmpl.ExecuteTemplate(io.Discard, "notes-tab", data)
+ if err != nil {
+ t.Errorf("Failed to render notes-tab with corrected data: %v", err)
+ }
+}