fix: Remove unused cookie helper functions and fix desktop sidebar visibility

1. Removed unused getPreferenceCookie and setPreferenceCookie functions
   - These were flagged by golangci-lint as unused
   - Cookie preferences now handled client-side via localStorage
   - Removed unused net/http import

2. Fixed desktop sidebar accordion auto-opening
   - Updated handleLandscapeAccordions() to open accordions in desktop view (≥769px)
   - Sidebars now show content in desktop, landscape mobile, and portrait mobile
   - Only keep accordions collapsed in portrait mobile for space saving

3. Created comprehensive multi-viewport test (66-comprehensive-all-viewports-test.mjs)
   - Tests desktop (1278px), portrait mobile (375×667), landscape mobile (667×375)
   - Validates sidebars, accordion state, content visibility, AND all buttons
   - Checks button backdrop visibility in mobile views
   - Every feature now has corresponding test coverage

Fixes golangci-lint errors:
- internal/handlers/cv_helpers.go:366: func getPreferenceCookie is unused
- internal/handlers/cv_helpers.go:375: func setPreferenceCookie is unused
- internal/handlers/cv_helpers.go:7: net/http imported and not used
This commit is contained in:
juanatsap
2025-11-25 06:00:39 +00:00
parent 82f73cf724
commit 76d80edd7e
5 changed files with 455 additions and 31 deletions
+2 -23
View File
@@ -4,7 +4,6 @@ import (
"context"
"fmt"
"log"
"net/http"
"os"
"os/exec"
"path/filepath"
@@ -361,25 +360,5 @@ func (h *CVHandler) prepareTemplateData(lang string) (map[string]interface{}, er
// ==============================================================================
// COOKIE HELPERS
// ==============================================================================
// getPreferenceCookie gets a preference cookie value, returns default if not found
func getPreferenceCookie(r *http.Request, name string, defaultValue string) string {
cookie, err := r.Cookie(name)
if err != nil {
return defaultValue
}
return cookie.Value
}
// setPreferenceCookie sets a preference cookie (1 year expiry)
func setPreferenceCookie(w http.ResponseWriter, name string, value string) {
http.SetCookie(w, &http.Cookie{
Name: name,
Value: value,
Path: "/",
MaxAge: 365 * 24 * 60 * 60, // 1 year
HttpOnly: true,
SameSite: http.SameSiteStrictMode,
Secure: false, // Set to true in production with HTTPS
})
}
// Note: Cookie preference management is now handled client-side via JavaScript
// and localStorage. Server-side cookie helpers have been removed as unused.