package agy

import (
	"testing"

	"github.com/aoagents/agent-orchestrator/backend/internal/domain"
)

func TestDeriveActivityState(t *testing.T) {
	tests := []struct {
		name   string
		event  string
		want   domain.ActivityState
		wantOK bool
	}{
		{"before agent -> active", "before-agent", domain.ActivityActive, true},
		{"after agent -> idle", "after-agent", domain.ActivityIdle, true},
		{"after tool -> active", "after-tool", domain.ActivityActive, true},
		{"session end -> exited", "session-end", domain.ActivityExited, true},
		{"session start -> no signal", "session-start", "", false},
		{"unknown event -> no signal", "unknown", "", false},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			got, ok := DeriveActivityState(tt.event, []byte(`{}`))
			if got != tt.want || ok != tt.wantOK {
				t.Fatalf("DeriveActivityState(%q) = (%q, %v), want (%q, %v)",
					tt.event, got, ok, tt.want, tt.wantOK)
			}
		})
	}
}
