summaryrefslogtreecommitdiff
path: root/internal/tui/tui_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-26 22:22:02 +0200
committerPaul Buetow <paul@buetow.org>2026-02-26 22:22:02 +0200
commit39a11ed5997a3829751dfbe4b666d3568d466276 (patch)
treede48f2661fe5986c61d91373737d452eff660757 /internal/tui/tui_test.go
parent21e713c3006d1295cbc68cecef90b54659fc1720 (diff)
tui: add shortcut to reselect pid and restart tracing
Diffstat (limited to 'internal/tui/tui_test.go')
-rw-r--r--internal/tui/tui_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.go
index d9a69a5..761ac0f 100644
--- a/internal/tui/tui_test.go
+++ b/internal/tui/tui_test.go
@@ -281,6 +281,35 @@ func TestExportKeyOpensModalOnDashboard(t *testing.T) {
}
}
+func TestSelectPIDKeyReturnsToFreshPickerAndStopsTrace(t *testing.T) {
+ m := NewModel(-1, func(context.Context) error { return nil })
+ m.screen = ScreenDashboard
+ m.attaching = false
+ m.width = 120
+ m.height = 30
+ stopped := false
+ m.traceStop = func() { stopped = true }
+
+ next, cmd := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'s'}})
+ updated := next.(Model)
+
+ if !stopped {
+ t.Fatalf("expected active tracing to be stopped before returning to picker")
+ }
+ if updated.screen != ScreenPIDPicker {
+ t.Fatalf("expected PID picker screen, got %v", updated.screen)
+ }
+ if updated.attaching {
+ t.Fatalf("expected attaching=false on picker screen")
+ }
+ if updated.traceStop != nil {
+ t.Fatalf("expected traceStop to be cleared after stopping")
+ }
+ if cmd == nil {
+ t.Fatalf("expected picker init command when returning to picker")
+ }
+}
+
func TestExportKeyIgnoredWhenExportDisabled(t *testing.T) {
flags.SetTUIExportEnable(false)
t.Cleanup(func() { flags.SetTUIExportEnable(true) })