package auth

import (
	"net/http"
	"net/http/httptest"
	"testing"

	"github.com/gin-gonic/gin"
	"github.com/stretchr/testify/require"
)

func TestFeishuLoginURLRejectsMissingOrganizationProvider(t *testing.T) {
	t.Parallel()

	handler := &FeishuHandler{}
	router := gin.New()
	router.POST("/api/v1/auth/feishu/login-url", handler.LoginURL)

	recorder := httptest.NewRecorder()
	request := httptest.NewRequest(http.MethodPost, "/api/v1/auth/feishu/login-url", nil)
	router.ServeHTTP(recorder, request)

	require.Equal(t, http.StatusNotFound, recorder.Code)
	require.Contains(t, recorder.Body.String(), "Organization provider not installed")
}
