summaryrefslogtreecommitdiff
path: root/internal/handlers/handlers_test.go
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-03-21 21:24:02 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-03-21 21:24:02 +0000
commit764d4d2d07449aec72c87afe941b7c63ea05e08c (patch)
tree042b157cfff2ab358b5bb9b891f26944133b7065 /internal/handlers/handlers_test.go
parent5f4f59fc6302a4e44773d4a939ae7b3304d61f1f (diff)
feat: Phase 1 — remove bug feature and dead code
- Delete Bug struct, BugToAtom, SourceBug, TypeBug, TypeNote - Remove bug store methods (SaveBug, GetBugs, ResolveBug, etc.) - Remove HandleGetBugs, HandleReportBug, bug branches in handlers - Remove bug routes, bugs.html template, bug UI from index.html - Remove AddMealToPlanner stub + interface method - Migration 018: DROP TABLE IF EXISTS bugs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/handlers/handlers_test.go')
-rw-r--r--internal/handlers/handlers_test.go194
1 files changed, 0 insertions, 194 deletions
diff --git a/internal/handlers/handlers_test.go b/internal/handlers/handlers_test.go
index e30c6d5..793ccdd 100644
--- a/internal/handlers/handlers_test.go
+++ b/internal/handlers/handlers_test.go
@@ -1367,33 +1367,6 @@ func TestShoppingTabFiltersCheckedItems(t *testing.T) {
}
// =============================================================================
-// Bug Reporting Tests
-// NOTE: Some tests skipped due to schema mismatch (resolved_at column)
-// =============================================================================
-
-func TestHandleReportBug_MissingDescription(t *testing.T) {
- db, cleanup := setupTestDB(t)
- defer cleanup()
-
- h := &Handler{
- store: db,
- config: &config.Config{},
- }
-
- req := httptest.NewRequest("POST", "/report-bug", nil)
- req.Form = map[string][]string{
- "description": {""},
- }
- w := httptest.NewRecorder()
-
- h.HandleReportBug(w, req)
-
- if w.Code != http.StatusBadRequest {
- t.Errorf("Expected status 400 for empty description, got %d", w.Code)
- }
-}
-
-// =============================================================================
// Tab Handler Tests
// =============================================================================
@@ -2828,58 +2801,6 @@ func TestHandleSettingsPage_IncludesSyncLog(t *testing.T) {
}
// =============================================================================
-// HandleGetBugs template tests
-// =============================================================================
-
-// TestHandleGetBugs_RendersTemplate verifies that HandleGetBugs uses the renderer
-// with the "bugs" template and passes the bug list as data.
-func TestHandleGetBugs_RendersTemplate(t *testing.T) {
- h, cleanup := setupTestHandler(t)
- defer cleanup()
-
- _ = h.store.SaveBug("test bug description")
-
- req := httptest.NewRequest("GET", "/bugs", nil)
- w := httptest.NewRecorder()
- h.HandleGetBugs(w, req)
-
- mr := h.renderer.(*MockRenderer)
- var found bool
- for _, call := range mr.Calls {
- if call.Name == "bugs" {
- found = true
- break
- }
- }
- if !found {
- t.Error("Expected renderer to be called with 'bugs' template")
- }
-}
-
-// TestHandleGetBugs_NoBugs_RendersTemplate verifies that HandleGetBugs uses the
-// renderer even when there are no bugs.
-func TestHandleGetBugs_NoBugs_RendersTemplate(t *testing.T) {
- h, cleanup := setupTestHandler(t)
- defer cleanup()
-
- req := httptest.NewRequest("GET", "/bugs", nil)
- w := httptest.NewRecorder()
- h.HandleGetBugs(w, req)
-
- mr := h.renderer.(*MockRenderer)
- var found bool
- for _, call := range mr.Calls {
- if call.Name == "bugs" {
- found = true
- break
- }
- }
- if !found {
- t.Error("Expected renderer to be called with 'bugs' template even when no bugs")
- }
-}
-
-// =============================================================================
// HandleGetTaskDetail template tests
// =============================================================================
@@ -3223,118 +3144,3 @@ func TestHandleTabMeals_GroupingMergesRecipes(t *testing.T) {
}
}
-// =============================================================================
-// HandleGetBugs and HandleReportBug data tests
-// =============================================================================
-
-// TestHandleGetBugs_ReturnsBugList verifies that the bugs template receives a
-// non-empty bug list when bugs exist in the store.
-func TestHandleGetBugs_ReturnsBugList(t *testing.T) {
- h, cleanup := setupTestHandler(t)
- defer cleanup()
-
- _ = h.store.SaveBug("login button not working")
- _ = h.store.SaveBug("dashboard shows wrong date")
-
- req := httptest.NewRequest("GET", "/bugs", nil)
- w := httptest.NewRecorder()
- h.HandleGetBugs(w, req)
-
- if w.Code != http.StatusOK {
- t.Errorf("Expected 200, got %d", w.Code)
- }
-
- mr := h.renderer.(*MockRenderer)
- var found bool
- for _, call := range mr.Calls {
- if call.Name == "bugs" {
- found = true
- bugs, ok := call.Data.([]store.Bug)
- if !ok {
- t.Fatalf("Expected []store.Bug data, got %T", call.Data)
- }
- if len(bugs) != 2 {
- t.Errorf("Expected 2 bugs in template data, got %d", len(bugs))
- }
- break
- }
- }
- if !found {
- t.Error("Expected renderer called with 'bugs' template")
- }
-}
-
-// TestHandleGetBugs_EmptyList verifies that the bugs template receives an
-// empty (non-nil) slice when no bugs exist.
-func TestHandleGetBugs_EmptyList(t *testing.T) {
- h, cleanup := setupTestHandler(t)
- defer cleanup()
-
- req := httptest.NewRequest("GET", "/bugs", nil)
- w := httptest.NewRecorder()
- h.HandleGetBugs(w, req)
-
- if w.Code != http.StatusOK {
- t.Errorf("Expected 200, got %d", w.Code)
- }
-
- mr := h.renderer.(*MockRenderer)
- var found bool
- for _, call := range mr.Calls {
- if call.Name == "bugs" {
- found = true
- bugs, ok := call.Data.([]store.Bug)
- if !ok {
- t.Fatalf("Expected []store.Bug data, got %T", call.Data)
- }
- if len(bugs) != 0 {
- t.Errorf("Expected 0 bugs in template data, got %d", len(bugs))
- }
- break
- }
- }
- if !found {
- t.Error("Expected renderer called with 'bugs' template")
- }
-}
-
-// TestHandleReportBug_Success verifies that a valid bug report is saved and the
-// updated bugs list is re-rendered.
-func TestHandleReportBug_Success(t *testing.T) {
- h, cleanup := setupTestHandler(t)
- defer cleanup()
-
- req := httptest.NewRequest("POST", "/report-bug", strings.NewReader("description=button+broken"))
- req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
- w := httptest.NewRecorder()
- h.HandleReportBug(w, req)
-
- if w.Code != http.StatusOK {
- t.Errorf("Expected 200, got %d", w.Code)
- }
-
- // Verify bug was saved to store
- bugs, err := h.store.GetBugs()
- if err != nil {
- t.Fatalf("GetBugs failed: %v", err)
- }
- if len(bugs) != 1 {
- t.Fatalf("Expected 1 bug saved, got %d", len(bugs))
- }
- if bugs[0].Description != "button broken" {
- t.Errorf("Expected description 'button broken', got %q", bugs[0].Description)
- }
-
- // Verify renderer was called with "bugs" template (HandleGetBugs is called internally)
- mr := h.renderer.(*MockRenderer)
- var bugsRendered bool
- for _, call := range mr.Calls {
- if call.Name == "bugs" {
- bugsRendered = true
- break
- }
- }
- if !bugsRendered {
- t.Error("Expected 'bugs' template to be rendered after successful report")
- }
-}