diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-09 22:45:05 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-09 22:45:05 +0200 |
| commit | eb53d7c881b6b8a513c1350736c5f5df770e4089 (patch) | |
| tree | 2bdaa31d3275cf8077c47ad0a8ba5018f0b85e37 /internal/tui/dashboard/processes_test.go | |
| parent | 1af7cf5fe51fa13e828cdef6268348ec9cd7bd7c (diff) | |
tui: add sortable processes dashboard table (task 365)
Diffstat (limited to 'internal/tui/dashboard/processes_test.go')
| -rw-r--r-- | internal/tui/dashboard/processes_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/internal/tui/dashboard/processes_test.go b/internal/tui/dashboard/processes_test.go index bfc26fc..7c04497 100644 --- a/internal/tui/dashboard/processes_test.go +++ b/internal/tui/dashboard/processes_test.go @@ -28,6 +28,12 @@ func TestRenderProcessesIncludesHeaders(t *testing.T) { if !strings.Contains(out, "100") || !strings.Contains(out, "proc-a") { t.Fatalf("expected process row in output") } + if !strings.Contains(out, "s:sort") { + t.Fatalf("expected processes sort hint in output") + } + if !strings.Contains(out, "sort: default") { + t.Fatalf("expected processes default sort label in output") + } } func TestRenderProcessesShowsSinglePIDNote(t *testing.T) { @@ -53,3 +59,20 @@ func TestTruncateText(t *testing.T) { t.Fatalf("unexpected truncation result: %q", got) } } + +func TestSortedProcessTableRowsUsesSelectedSortKey(t *testing.T) { + rows := []statsengine.ProcessSnapshot{ + {PID: 200, Comm: "worker", Syscalls: 9}, + {PID: 100, Comm: "agent", Syscalls: 3}, + } + + sorted := sortedProcessTableRows(rows, tableSortState[processSortKey]{active: true, key: processSortKeyComm}) + if sorted[0].PID != 100 { + t.Fatalf("expected comm sort to put PID 100 first, got %d", sorted[0].PID) + } + + sorted = sortedProcessTableRows(rows, tableSortState[processSortKey]{active: true, key: processSortKeyPID}) + if sorted[0].PID != 100 { + t.Fatalf("expected pid asc sort to put PID 100 first, got %d", sorted[0].PID) + } +} |
