feat(tabs): Proses (docker top) + Konfigurasi (JSON inspect, scroll) + Env (KEY=value) — Phase 2 tuntas
CI / test (push) Successful in 23s

This commit is contained in:
oxpoe committed 2026-10-16 01:14:02 +07:00
1 parent 86db90ea9a
commit 177e27910b
7 files changed
+419 -17

No files matched your search

+78 -3
View File
@@ -348,6 +348,82 @@ func TestStatsTab(t *testing.T) {
}
}
// TestProcessTab — tab Proses: tabel `docker top` tampil.
func TestProcessTab(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("h") // dari Log membungkus ke tab Proses (paling akhir)
u.waitContains("PID", 6*time.Second)
u.send("q")
if code := u.waitExit(5 * time.Second); code != 0 {
t.Fatalf("exit code %d, mau 0", code)
}
}
// TestConfigEnvTabs — tab Konfigurasi (JSON inspect) & Env (KEY=value).
func TestConfigEnvTabs(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]
}
env, err := cl.InspectEnv(ctx, items[0].ID)
if err != nil || len(env) == 0 {
t.Skipf("env kosong (err=%v)", err)
}
firstKey, _, _ := strings.Cut(env[0], "=")
u := startTUI(t)
u.waitContains("beranda", 5*time.Second)
u.send("1")
u.waitContains(name, 5*time.Second)
u.send("l") // Stats
u.send("l") // Konfigurasi
u.waitContains(`"Id"`, 6*time.Second)
u.send("l") // Env
u.waitContains(firstKey+"=", 6*time.Second)
u.send("k") // scroll dokumen tidak crash
u.send("G")
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)
@@ -477,9 +553,8 @@ func TestLogTab(t *testing.T) {
u.send("j")
u.send("G")
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("l") // Konfigurasi — kini data nyata: JSON inspect
u.waitContains(`"Id"`, 6*time.Second)
u.send("\x1b[<0;60;10M\x1b[<0;60;10m") // klik area konten = fokus
u.send("q")