53 lines
1.8 KiB
Go
53 lines
1.8 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestChatwoot415RoutesAreTrackedAndReportedMissing(t *testing.T) {
|
|
expected := []string{
|
|
"GET /api/v1/accounts/:account_id/onboarding/help_center_generation",
|
|
"GET /api/v1/accounts/:account_id/captain/assistants/:assistant_id/stats",
|
|
"GET /api/v1/accounts/:account_id/captain/assistants/:assistant_id/summary",
|
|
"GET /api/v1/accounts/:account_id/captain/assistants/:assistant_id/drilldown",
|
|
"POST /api/v1/accounts/:account_id/captain/message_reports",
|
|
"GET /api/v1/accounts/:account_id/calls",
|
|
"POST /api/v1/accounts/:account_id/inboxes/:inbox_id/set_inbound_calls",
|
|
"GET /api/v1/profile/sessions",
|
|
"DELETE /api/v1/profile/sessions/:id",
|
|
"GET /api/v2/accounts/:account_id/reports/drilldown",
|
|
"POST /enterprise/api/v1/accounts/:account_id/select_billing_currency",
|
|
"GET /enterprise/api/v1/accounts/:account_id/topup_options",
|
|
}
|
|
tracked := make(map[string]bool, len(criticalRoutes))
|
|
for _, item := range criticalRoutes {
|
|
tracked[item.Method+" "+item.Path] = true
|
|
}
|
|
for _, item := range expected {
|
|
if !tracked[item] {
|
|
t.Fatalf("Chatwoot 4.15.1 route is not tracked: %s", item)
|
|
}
|
|
}
|
|
|
|
routes := make(map[string]route, len(criticalRoutes))
|
|
for _, item := range criticalRoutes {
|
|
routes[key(item.Method, item.Path)] = item
|
|
}
|
|
delete(routes, key("GET", "/api/v2/accounts/:account_id/reports/drilldown"))
|
|
out := filepath.Join(t.TempDir(), "parity.md")
|
|
if err := writeParity(out, "gochat-routes.txt", "docs/chatwoot/config/routes.rb", routes); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
data, err := os.ReadFile(out)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
report := string(data)
|
|
if !strings.Contains(report, "`/api/v2/accounts/:account_id/reports/drilldown`") || !strings.Contains(report, "| missing |") {
|
|
t.Fatalf("removed 4.15.1 route was not reported missing:\n%s", report)
|
|
}
|
|
}
|