package app

import (
	"strings"
	"testing"
)

// The event-stream badge must track the selected session's lifecycle, not just the socket:
// a terminal/paused session emits no more events, so it must not keep reading "● live".
func TestEventStreamBadgeReflectsSessionStatus(t *testing.T) {
	cases := []struct{ status, want string }{
		{"ACTIVE", "● live"},
		{"COMPLETED", "✓ done"},
		{"FAILED", "✗ failed"},
		{"PAUSED awaiting approval", "‖ paused"},
	}
	for _, c := range cases {
		m := inSessionModel(120, 40)
		m.connected = true
		m.sessions[0].Status = c.status
		if got := m.eventStreamBadge(); !strings.Contains(got, c.want) {
			t.Errorf("status %q: badge = %q, want substring %q", c.status, got, c.want)
		}
	}

	// Disconnected always reads idle, regardless of the session's status.
	m := inSessionModel(120, 40)
	m.connected = false
	m.sessions[0].Status = "ACTIVE"
	if got := m.eventStreamBadge(); !strings.Contains(got, "○ idle") {
		t.Errorf("disconnected: badge = %q, want idle", got)
	}
}
