From e3195a6534bae000a63e884ff647fac95d9d2498 Mon Sep 17 00:00:00 2001 From: Claudomator Agent Date: Wed, 18 Mar 2026 07:06:03 +0000 Subject: chore: autocommit uncommitted changes --- internal/handlers/handlers_test.go | 108 +++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) (limited to 'internal/handlers/handlers_test.go') diff --git a/internal/handlers/handlers_test.go b/internal/handlers/handlers_test.go index 470ea5c..9a2287f 100644 --- a/internal/handlers/handlers_test.go +++ b/internal/handlers/handlers_test.go @@ -2827,6 +2827,114 @@ 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 +// ============================================================================= + +// TestHandleGetTaskDetail_RendersTemplate verifies that HandleGetTaskDetail uses +// the renderer with the "task-detail" template. +func TestHandleGetTaskDetail_RendersTemplate(t *testing.T) { + h, cleanup := setupTestHandler(t) + defer cleanup() + + req := httptest.NewRequest("GET", "/tasks/detail?id=abc&source=todoist", nil) + w := httptest.NewRecorder() + h.HandleGetTaskDetail(w, req) + + mr := h.renderer.(*MockRenderer) + var found bool + for _, call := range mr.Calls { + if call.Name == "task-detail" { + found = true + break + } + } + if !found { + t.Error("Expected renderer to be called with 'task-detail' template") + } +} + +// ============================================================================= +// HandleGetListsOptions template tests +// ============================================================================= + +// TestHandleGetListsOptions_RendersTemplate verifies that HandleGetListsOptions uses +// the renderer with the "lists-options" template. +func TestHandleGetListsOptions_RendersTemplate(t *testing.T) { + h, cleanup := setupTestHandler(t) + defer cleanup() + + h.trelloClient = &mockTrelloClient{boards: []models.Board{}} + + req := httptest.NewRequest("GET", "/trello/lists?board_id=board1", nil) + w := httptest.NewRecorder() + h.HandleGetListsOptions(w, req) + + mr := h.renderer.(*MockRenderer) + var found bool + for _, call := range mr.Calls { + if call.Name == "lists-options" { + found = true + break + } + } + if !found { + t.Error("Expected renderer to be called with 'lists-options' template") + } +} + // TestHandleSyncSources_AddsLogEntry verifies that syncing sources creates a sync log entry. func TestHandleSyncSources_AddsLogEntry(t *testing.T) { h, cleanup := setupTestHandler(t) -- cgit v1.2.3