diff options
Diffstat (limited to 'internal/tui/probes')
| -rw-r--r-- | internal/tui/probes/model.go | 4 | ||||
| -rw-r--r-- | internal/tui/probes/model_test.go | 41 |
2 files changed, 43 insertions, 2 deletions
diff --git a/internal/tui/probes/model.go b/internal/tui/probes/model.go index dffa30f..5cec2c7 100644 --- a/internal/tui/probes/model.go +++ b/internal/tui/probes/model.go @@ -117,9 +117,9 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) { } return m, toggleCmd(m.manager, selected) case "a": - return m, bulkToggleCmd(m.manager, m.filtered(), false) + return m, bulkToggleCmd(m.manager, m.probes, false) case "n": - return m, bulkToggleCmd(m.manager, m.filtered(), true) + return m, bulkToggleCmd(m.manager, m.probes, true) } } return m, nil diff --git a/internal/tui/probes/model_test.go b/internal/tui/probes/model_test.go index 74f6a6b..73a83bc 100644 --- a/internal/tui/probes/model_test.go +++ b/internal/tui/probes/model_test.go @@ -78,3 +78,44 @@ func TestToggleEmitsProbeToggledMsg(t *testing.T) { } _ = next } + +func TestBulkKeysApplyGloballyNotOnlyFiltered(t *testing.T) { + fm := &fakeManager{ + states: []probemanager.ProbeState{ + {Syscall: "read", Active: true}, + {Syscall: "write", Active: true}, + {Syscall: "openat", Active: true}, + }, + } + m := NewModel(fm).Open() + m.search = "read" + + _, cmd := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'n'}}) + if cmd == nil { + t.Fatalf("expected bulk off command") + } + msg := cmd() + if toggled, ok := msg.(ProbeToggledMsg); !ok || toggled.Err != nil { + t.Fatalf("unexpected bulk off msg: %#v", msg) + } + if len(fm.toggles) != 3 { + t.Fatalf("expected all probes toggled off despite filter, got toggles=%+v", fm.toggles) + } + + // Re-open with all inactive and filtered search still present; "a" should + // toggle all probes back on. + m = NewModel(fm).Open() + m.search = "read" + fm.toggles = nil + _, cmd = m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'a'}}) + if cmd == nil { + t.Fatalf("expected bulk on command") + } + msg = cmd() + if toggled, ok := msg.(ProbeToggledMsg); !ok || toggled.Err != nil { + t.Fatalf("unexpected bulk on msg: %#v", msg) + } + if len(fm.toggles) != 3 { + t.Fatalf("expected all probes toggled on despite filter, got toggles=%+v", fm.toggles) + } +} |
