refactor(tui): status icons, clean STATUS column, relative time
CI / test (pull_request) Successful in 2m30s
CI / lint (pull_request) Successful in 56s
CI / vulncheck (pull_request) Successful in 51s

- STATUS column shows icon + clean state only (▲ UP, ▼ DOWN, ◆ LATE,
  ◆ STALE, ◇ PAUSED, ◼ MAINT, ○ PENDING). Error classification
  (DNS/TLS/TMO) removed from STATUS — stays in NAME inline hint.
- Detail panel Last Check shows relative time ("12s ago") instead of
  absolute timestamp.
- Extract shared fmtTimeAgo() to format.go, consolidate duplicate
  formatters in tab_alerts.go and tab_nodes.go.
This commit was merged in pull request #62.
This commit is contained in:
2026-06-04 17:03:04 -04:00
parent 33a3ff9bcb
commit fb709b34c5
6 changed files with 44 additions and 62 deletions
+12 -17
View File
@@ -55,32 +55,27 @@ func TestSiteOrder(t *testing.T) {
}
}
func TestFmtStatus_ErrorCategory(t *testing.T) {
func TestFmtStatus(t *testing.T) {
tests := []struct {
status string
paused bool
inMaint bool
cat ErrorCategory
wantSub string
}{
{"DOWN", false, false, ErrCatDNS, "DOWN:DNS"},
{"DOWN", false, false, ErrCatTLS, "DOWN:TLS"},
{"DOWN", false, false, ErrCatHTTP, "DOWN:HTTP"},
{"DOWN", false, false, ErrCatTCP, "DOWN:TCP"},
{"DOWN", false, false, ErrCatTimeout, "DOWN:TMO"},
{"DOWN", false, false, ErrCatICMP, "DOWN:ICMP"},
{"DOWN", false, false, ErrCatPrivate, "DOWN:PRIV"},
{"DOWN", false, false, ErrCatUnknown, "DOWN"},
{"UP", false, false, ErrCatUnknown, "UP"},
{"SSL EXP", false, false, ErrCatUnknown, "SSL EXP"},
{"DOWN", true, false, ErrCatDNS, "PAUSED"},
{"DOWN", false, true, ErrCatDNS, "MAINT"},
{"DOWN", false, false, "▼ DOWN"},
{"UP", false, false, "▲ UP"},
{"SSL EXP", false, false, "▼ SSL EXP"},
{"LATE", false, false, "◆ LATE"},
{"STALE", false, false, "◆ STALE"},
{"PENDING", false, false, "○ PENDING"},
{"DOWN", true, false, "◇ PAUSED"},
{"DOWN", false, true, "◼ MAINT"},
}
for _, tt := range tests {
got := fmtStatus(tt.status, tt.paused, tt.inMaint, tt.cat)
got := fmtStatus(tt.status, tt.paused, tt.inMaint)
if !containsPlain(got, tt.wantSub) {
t.Errorf("fmtStatus(%q, paused=%v, maint=%v, %q): %q missing %q",
tt.status, tt.paused, tt.inMaint, tt.cat, got, tt.wantSub)
t.Errorf("fmtStatus(%q, paused=%v, maint=%v): %q missing %q",
tt.status, tt.paused, tt.inMaint, got, tt.wantSub)
}
}
}