feat(stats): tab Statistik (F-005) — bar CPU/RAM, riwayat sparkline 60 dtk, laju NET/Disk, PIDs
CI / test (push) Successful in 22s
CI / test (push) Successful in 22s
This commit is contained in:
1 parent
d3abc15a95
commit
86db90ea9a
10 files changed
+409
-18
No files matched your search
+38
-1
@@ -312,6 +312,42 @@ func TestResourceSections(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestStatsTab — tab Statistik: bar CPU/RAM, riwayat sparkline, NET/Disk,
|
||||
// PIDs muncul dari data nyata. Butuh docker + minimal 1 kontainer.
|
||||
func TestStatsTab(t *testing.T) {
|
||||
if _, err := os.Stat("/var/run/docker.sock"); err != nil {
|
||||
t.Skip("docker socket tidak ada")
|
||||
}
|
||||
cl, err := docker.New()
|
||||
if err != nil {
|
||||
t.Skipf("docker: %v", err)
|
||||
}
|
||||
defer cl.Close()
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
items, err := cl.ListContainers(ctx)
|
||||
if err != nil || len(items) == 0 {
|
||||
t.Skipf("tidak ada kontainer (err=%v)", err)
|
||||
}
|
||||
name := items[0].Name
|
||||
if len(name) > 12 {
|
||||
name = name[:12]
|
||||
}
|
||||
|
||||
u := startTUI(t)
|
||||
u.waitContains("beranda", 5*time.Second)
|
||||
u.send("1")
|
||||
u.waitContains(name, 5*time.Second)
|
||||
u.send("l") // tab Statistik (fokus pindah ke konten)
|
||||
u.waitContains("Riwayat CPU", 6*time.Second)
|
||||
u.waitContains("PIDs", 3*time.Second)
|
||||
u.send("h") // kembali ke Log
|
||||
u.send("q")
|
||||
if code := u.waitExit(5 * time.Second); code != 0 {
|
||||
t.Fatalf("exit code %d, mau 0", code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestThemeCycle(t *testing.T) {
|
||||
u := startTUI(t)
|
||||
u.waitContains("beranda", 5*time.Second)
|
||||
@@ -440,7 +476,8 @@ func TestLogTab(t *testing.T) {
|
||||
u.send("k")
|
||||
u.send("j")
|
||||
u.send("G")
|
||||
u.send("l") // tab berikutnya → placeholder
|
||||
u.send("l") // tab berikutnya (Statistik)
|
||||
u.send("l") // lalu Konfigurasi → placeholder
|
||||
u.waitContains("menyusul", 3*time.Second)
|
||||
u.send("h") // kembali ke tab Log
|
||||
u.send("\x1b[<0;60;10M\x1b[<0;60;10m") // klik area konten = fokus
|
||||
|
||||
Reference in new issue
Block a user