66 lines
1.7 KiB
Go
66 lines
1.7 KiB
Go
package router
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/gochat/gochat/internal/config"
|
|
"github.com/gochat/gochat/internal/middleware"
|
|
)
|
|
|
|
func TestRegisterRoutesBootsWithChatwootParityConflictGroups(t *testing.T) {
|
|
gin.SetMode(gin.TestMode)
|
|
engine := gin.New()
|
|
|
|
RegisterRoutes(
|
|
engine,
|
|
nil,
|
|
nil,
|
|
nil,
|
|
&Handlers{},
|
|
nil,
|
|
nil,
|
|
&config.JWTConfig{},
|
|
middleware.CORSConfig{},
|
|
nil,
|
|
)
|
|
|
|
routes := map[string]bool{}
|
|
for _, route := range engine.Routes() {
|
|
routes[route.Method+" "+route.Path] = true
|
|
}
|
|
|
|
expected := []string{
|
|
"GET /api/v1/accounts/:account_id/captain/assistants/tools",
|
|
"GET /api/v1/accounts/:account_id/captain/assistants/:assistant_id",
|
|
"GET /api/v1/widget/conversations",
|
|
"GET /api/v1/widget/conversations/toggle_status",
|
|
"PUT /public/api/v1/inboxes/:inbox_id/contacts/:contact_id/conversations/:conversation_id/messages/:message_id",
|
|
"GET /hc/:slug",
|
|
"GET /hc/:slug/sitemap.xml",
|
|
"GET /hc/:slug/:locale",
|
|
"GET /hc/:slug/:locale/search",
|
|
"GET /hc/:slug/:locale/articles.json",
|
|
"GET /hc/:slug/:locale/categories.json",
|
|
"GET /hc/:slug/:locale/categories/:category_slug",
|
|
"GET /hc/:slug/articles/:article_slug",
|
|
"GET /api/v2/accounts/:account_id/reports/summary",
|
|
"GET /api/v2/accounts/:account_id/live_reports/grouped_conversation_metrics",
|
|
"GET /webhooks/twitter",
|
|
"POST /webhooks/twitter",
|
|
"POST /webhooks/telegram/:bot_token",
|
|
"POST /webhooks/line/:line_channel_id",
|
|
"POST /webhooks/sms/:phone_number",
|
|
"GET /webhooks/whatsapp/:phone_number",
|
|
"POST /webhooks/whatsapp/:phone_number",
|
|
"POST /webhooks/tiktok",
|
|
"POST /webhooks/shopify",
|
|
}
|
|
|
|
for _, key := range expected {
|
|
if !routes[key] {
|
|
t.Fatalf("expected route %s to be registered", key)
|
|
}
|
|
}
|
|
}
|