diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-06 23:14:09 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-06 23:14:09 +0200 |
| commit | 106fcb3fe959966dec19d1242ff87df644a43fad (patch) | |
| tree | 5152e1d4dadbf991040d0db069c8d76db889364d /internal/tui/tui_test.go | |
| parent | 013e46d7856a604d4890a880b8bbfb4b8c58202b (diff) | |
fix(tui): restore bubble modes and stabilize flame zoom lineage
Diffstat (limited to 'internal/tui/tui_test.go')
| -rw-r--r-- | internal/tui/tui_test.go | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.go index e4bdbff..82fe9da 100644 --- a/internal/tui/tui_test.go +++ b/internal/tui/tui_test.go @@ -209,6 +209,88 @@ func TestQuitKeyDoesNotExitOnPIDPickerScreen(t *testing.T) { } } +func TestQuitKeyOnReselectPIDPickerReturnsToDashboardLikeEsc(t *testing.T) { + m := NewModel(-1, func(context.Context) error { return nil }) + m.screen = ScreenDashboard + m.attaching = false + m.width = 120 + m.height = 30 + m.pidFilter = 1111 + m.tidFilter = 2222 + m.dashboard.SetPidFilter(1111) + + next, _ := m.Update(tea.KeyPressMsg{Code: []rune{'2'}[0], Text: string([]rune{'2'})}) + m = next.(Model) + + next, _ = m.Update(tea.KeyPressMsg{Code: []rune{'p'}[0], Text: string([]rune{'p'})}) + m = next.(Model) + if m.screen != ScreenPIDPicker { + t.Fatalf("expected pid picker screen after reselect, got %v", m.screen) + } + + next, cmd := m.Update(tea.KeyPressMsg{Code: []rune{'q'}[0], Text: string([]rune{'q'})}) + updated := next.(Model) + if cmd == nil { + t.Fatalf("expected q in reselect picker to return to dashboard and restart tracing") + } + if updated.screen != ScreenDashboard { + t.Fatalf("expected dashboard screen after q cancel, got %v", updated.screen) + } + if !updated.attaching { + t.Fatalf("expected attaching=true after q cancel") + } + if updated.quitting { + t.Fatalf("expected q in reselect picker to behave like esc, not quit") + } + if updated.pickerReturn != nil { + t.Fatalf("expected picker return context to clear after cancel") + } + if updated.pidFilter != 1111 || updated.tidFilter != 2222 { + t.Fatalf("expected previous pid/tid filters restored, got pid=%d tid=%d", updated.pidFilter, updated.tidFilter) + } +} + +func TestEscOnReselectPIDPickerReturnsToDashboard(t *testing.T) { + m := NewModel(-1, func(context.Context) error { return nil }) + m.screen = ScreenDashboard + m.attaching = false + m.width = 120 + m.height = 30 + m.pidFilter = 3333 + m.tidFilter = 4444 + m.dashboard.SetPidFilter(3333) + + next, _ := m.Update(tea.KeyPressMsg{Code: []rune{'2'}[0], Text: string([]rune{'2'})}) + m = next.(Model) + + next, _ = m.Update(tea.KeyPressMsg{Code: []rune{'p'}[0], Text: string([]rune{'p'})}) + m = next.(Model) + if m.screen != ScreenPIDPicker { + t.Fatalf("expected pid picker screen after reselect, got %v", m.screen) + } + + next, cmd := m.Update(tea.KeyPressMsg{Code: tea.KeyEsc}) + updated := next.(Model) + if cmd == nil { + t.Fatalf("expected esc in reselect picker to return to dashboard and restart tracing") + } + if updated.screen != ScreenDashboard { + t.Fatalf("expected dashboard screen after esc cancel, got %v", updated.screen) + } + if !updated.attaching { + t.Fatalf("expected attaching=true after esc cancel") + } + if updated.quitting { + t.Fatalf("expected esc in reselect picker not to quit app") + } + if updated.pickerReturn != nil { + t.Fatalf("expected picker return context to clear after cancel") + } + if updated.pidFilter != 3333 || updated.tidFilter != 4444 { + t.Fatalf("expected previous pid/tid filters restored, got pid=%d tid=%d", updated.pidFilter, updated.tidFilter) + } +} + func TestQuitKeyClosesProbeModalLikeEsc(t *testing.T) { m := NewModel(-1, func(context.Context) error { return nil }) m.screen = ScreenDashboard |
