diff options
| author | Adam Mathes <adam@adammathes.com> | 2026-02-12 21:06:15 -0800 |
|---|---|---|
| committer | Adam Mathes <adam@adammathes.com> | 2026-02-12 21:06:15 -0800 |
| commit | 8a8f516ebd1115eed6256cd1b60be6393fd42c26 (patch) | |
| tree | e4fa77e29897d5f22f425464a9173bd3506449d3 /tui/tui_test.go | |
| parent | cfd583e9166330f053fa7cc28258b4467c48459c (diff) | |
| download | neko-8a8f516ebd1115eed6256cd1b60be6393fd42c26.tar.gz neko-8a8f516ebd1115eed6256cd1b60be6393fd42c26.tar.bz2 neko-8a8f516ebd1115eed6256cd1b60be6393fd42c26.zip | |
Fix TUI content view navigation and interaction
- Integrated viewport.Model for scrollable content view
- Fixed 'q' and 'esc' navigation from content view
- Added unit tests for content state transitions and rendering
- Cleaned up unused TUI delegate code
- Increased TUI package coverage to ~70%
Diffstat (limited to 'tui/tui_test.go')
| -rw-r--r-- | tui/tui_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tui/tui_test.go b/tui/tui_test.go index 6ae8d73..de9caf0 100644 --- a/tui/tui_test.go +++ b/tui/tui_test.go @@ -1,6 +1,7 @@ package tui import ( + "strings" "testing" "adammathes.com/neko/models/feed" @@ -28,6 +29,8 @@ func TestUpdateWindowSizeNoPanic(t *testing.T) { func TestStateTransitions(t *testing.T) { m := NewModel() + m1, _ := m.Update(tea.WindowSizeMsg{Width: 80, Height: 24}) + m = m1.(Model) // Feed loaded feeds := []*feed.Feed{{Id: 1, Title: "Test Feed"}} @@ -55,4 +58,35 @@ func TestStateTransitions(t *testing.T) { if tm4.state != viewFeeds { t.Errorf("Expected back to viewFeeds, got %v", tm4.state) } + + // Test entering content view + tm5, _ := tm3.Update(tea.KeyMsg{Type: tea.KeyEnter}) + tm5m := tm5.(Model) + if tm5m.state != viewContent { + t.Errorf("Expected state viewContent, got %v", tm5m.state) + } + if !strings.Contains(tm5m.contentView.View(), "Test Item") { + t.Error("Expected content view to show item title") + } + + // Back from content to items + tm6, _ := tm5.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune("q")}) + tm6m := tm6.(Model) + if tm6m.state != viewItems { + t.Errorf("Expected back to viewItems, got %v", tm6m.state) + } + + // Test View for all states + if v := m.View(); !strings.Contains(v, "NEKO TUI") { + t.Error("View should contain title") + } + if v := tm2.View(); !strings.Contains(v, "Feeds") { + t.Error("View should contain Feeds list") + } + if v := tm3.View(); !strings.Contains(v, "Items") && !strings.Contains(v, "Test Feed") { + t.Error("View should contain Items list or Feed title") + } + if v := tm5m.View(); !strings.Contains(v, "Test Item") { + t.Error("View should contain Item title in content view") + } } |
