feat: Phase 2 UX Polish — theme system, config profiles, error banner, tests

- Add Theme struct with 3 predefined themes (dark/light/druntime)
- Add Profile struct for named configuration profiles
- Add ErrorBanner with severity levels and auto-dismiss
- Add unit tests for theme, error banner, and models
- Update CHANGELOG.md and PROJECT_STATE.md
This commit is contained in:
swanadiva
2026-06-29 11:50:46 +07:00
parent 93957e3989
commit 408681c8e4
8 changed files with 617 additions and 7 deletions
+71
View File
@@ -0,0 +1,71 @@
package tui_test
import (
"testing"
"git.tukangketik.id/swanadiva/hostkeeper/pkg/tui"
)
func TestGetTheme(t *testing.T) {
// Test getting existing themes
tests := []struct {
name string
expected string
}{
{"dark", "dark"},
{"light", "light"},
{"dracula", "dracula"},
}
for _, tt := range tests {
theme := tui.GetTheme(tt.name)
if theme.Name != tt.expected {
t.Errorf("GetTheme(%q) = %q, want %q", tt.name, theme.Name, tt.expected)
}
}
// Test getting non-existing theme defaults to dark
theme := tui.GetTheme("nonexistent")
if theme.Name != "dark" {
t.Errorf("GetTheme(nonexistent) = %q, want %q", theme.Name, "dark")
}
}
func TestSetTheme(t *testing.T) {
// Set theme to light
tui.SetTheme("light")
active := tui.GetActiveTheme()
if active.Name != "light" {
t.Errorf("After SetTheme(light), GetActiveTheme() = %q, want %q", active.Name, "light")
}
// Set theme back to dark
tui.SetTheme("dark")
active = tui.GetActiveTheme()
if active.Name != "dark" {
t.Errorf("After SetTheme(dark), GetActiveTheme() = %q, want %q", active.Name, "dark")
}
}
func TestGetActiveTheme(t *testing.T) {
// Default should be dark
active := tui.GetActiveTheme()
if active.Name != "dark" {
t.Errorf("GetActiveTheme() = %q, want %q", active.Name, "dark")
}
}
func TestThemeRegistry(t *testing.T) {
// Test that all themes are registered
expectedThemes := []string{"dark", "light", "dracula"}
for _, name := range expectedThemes {
if _, ok := tui.Themes[name]; !ok {
t.Errorf("Theme %q not found in Themes map", name)
}
}
// Test theme count
if len(tui.Themes) != 3 {
t.Errorf("Themes map has %d entries, want 3", len(tui.Themes))
}
}