diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-05 19:42:22 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-05 19:42:22 +0200 |
| commit | 1318a3a927ea3bae77a7560e149070583f215982 (patch) | |
| tree | fde86b0250643da119ca75e051028e3e92466d32 /internal/tui/tui_test.go | |
| parent | 47c53c0d9f06451972fa32d6d74ebe572757c639 (diff) | |
feat(tui): pause dashboard refresh on terminal blur
Diffstat (limited to 'internal/tui/tui_test.go')
| -rw-r--r-- | internal/tui/tui_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.go index 5c1ea5f..e705f41 100644 --- a/internal/tui/tui_test.go +++ b/internal/tui/tui_test.go @@ -5,6 +5,7 @@ import ( "errors" "ior/internal/probemanager" "ior/internal/statsengine" + dashboardui "ior/internal/tui/dashboard" "ior/internal/tui/eventstream" tuiexport "ior/internal/tui/export" "ior/internal/tui/messages" @@ -606,3 +607,36 @@ func TestProbeModalViewDoesNotStackDashboardContent(t *testing.T) { t.Fatalf("expected probe modal to render as standalone view, got stacked dashboard content") } } + +func TestBlurPausesDashboardRefreshAndFocusResumesIt(t *testing.T) { + m := NewModel(-1, func(context.Context) error { return nil }) + m.screen = ScreenDashboard + m.attaching = false + m.dashboard = dashboardui.NewModelWithConfig(nil, nil, 1, m.keys) + m.focused = true + + next, _ := m.Update(tea.BlurMsg{}) + m = next.(Model) + if m.focused { + t.Fatalf("expected focused=false after blur") + } + + tickMsg := m.dashboard.Init()() + next, tickCmd := m.Update(tickMsg) + m = next.(Model) + if tickCmd != nil { + t.Fatalf("expected no follow-up tick command while blurred") + } + + next, focusCmd := m.Update(tea.FocusMsg{}) + m = next.(Model) + if !m.focused { + t.Fatalf("expected focused=true after focus") + } + if focusCmd == nil { + t.Fatalf("expected focus to resume refresh with a command batch") + } + if _, ok := focusCmd().(tea.BatchMsg); !ok { + t.Fatalf("expected focus command to be a batch") + } +} |
