package httpx_test

import (
	"testing"

	"github.com/stretchr/testify/require"
	"senlinai-agent/backend/internal/config"
	"senlinai-agent/backend/internal/httpx"
	"senlinai-agent/backend/internal/logic/ai"
	"senlinai-agent/backend/internal/logic/auth"
	"senlinai-agent/backend/internal/logic/files"
	"senlinai-agent/backend/internal/logic/inbox"
	"senlinai-agent/backend/internal/logic/projects"
	"senlinai-agent/backend/internal/logic/search"
	"senlinai-agent/backend/internal/logic/tasks"
)

func TestMainRegistrarsRegisterTogether(t *testing.T) {
	require.NotPanics(t, func() {
		cfg := config.Config{
			Env:                   "test",
			AuthSecret:            "test-auth-secret",
			AIKeyEncryptionSecret: "test-ai-encryption-secret",
		}
		authService := auth.NewService(cfg.AuthSecret)
		projectService := projects.NewService()
		httpx.NewProtectedRouter(
			cfg,
			authService.VerifySession,
			auth.NewHandler(authService),
			projects.NewHandler(projectService),
			projects.NewTagHandler(projectService),
			projects.NewCronHandler(projectService),
			tasks.NewHandler(tasks.NewService()),
			files.NewHandler(files.NewService(t.TempDir())),
			inbox.NewHandler(inbox.NewService(inbox.StaticAnalyzer{})),
			search.NewHandler(search.NewService(nil)),
			ai.NewHandler(ai.NewSessionService(ai.NewGatewayWithSecret(cfg.SystemAIKey, cfg.AIKeyEncryptionSecret))),
		)
	})
}
