This commit is contained in:
2026-08-17 21:20:45 +02:00
parent 321f11e817
commit 6fcdc74843
157 changed files with 2895 additions and 7544 deletions
@@ -123,12 +123,18 @@ func TestV1DomainResourceCRUD(t *testing.T) {
t.Fatalf("get category status=%d body=%s", rec.Code, rec.Body.String())
}
gotCat := decode(t, rec)
if _, hasData := gotCat["data"]; hasData {
t.Fatalf("GET /categories/{uuid} should be flat dashboard JSON, got envelope: %v", gotCat)
}
if gotCat["unique_id"] != catUnique {
gotCatData, _ := gotCat["data"].(map[string]any)
if gotCatData["unique_id"] != catUnique {
t.Fatalf("get category=%v", gotCat)
}
for _, leak := range []string{"prompt", "prompts", "has_prompt", "title_template", "description_template"} {
if _, ok := gotCatData[leak]; ok {
t.Fatalf("v1 GET category leaked %q: %v", leak, gotCatData)
}
if _, ok := gotCat[leak]; ok {
t.Fatalf("v1 GET category envelope leaked %q: %v", leak, gotCat)
}
}
rec = do(http.MethodPatch, "/api/v1/categories/"+catUUID.String(),
`{"name":"Electronics & Audio"}`)
@@ -323,12 +329,15 @@ func TestV1DomainResourceCRUD(t *testing.T) {
t.Fatalf("get product status=%d body=%s", rec.Code, rec.Body.String())
}
gotProd := decode(t, rec)
if _, hasData := gotProd["data"]; hasData {
t.Fatalf("GET /products/{id} should be flat JSON, got envelope: %v", gotProd)
}
if fmt.Sprint(gotProd["product_id"]) != "SKU-1001" {
gotProdData, _ := gotProd["data"].(map[string]any)
if fmt.Sprint(gotProdData["product_id"]) != "SKU-1001" {
t.Fatalf("get product=%v", gotProd)
}
for _, leak := range []string{"mapped_data", "has_processed_name", "has_eprel", "processed_name"} {
if _, ok := gotProdData[leak]; ok {
t.Fatalf("v1 GET product leaked %q: %v", leak, gotProdData)
}
}
rec = do(http.MethodPatch, "/api/v1/products/"+productID.String(),
`{"processed_name":"Acme Wireless Earbuds ANC Midnight","status":"completed"}`)
@@ -427,7 +436,7 @@ func mountV1DomainTestRouter(s *Server) http.Handler {
r.Route("/api/v1", func(r chi.Router) {
r.Get("/products", s.handleV1ListProducts)
r.Get("/products/quality", s.handleV1ListProductQuality)
r.Get("/products/{id}", s.handleGetProduct)
r.Get("/products/{id}", s.handleV1GetProduct)
r.Patch("/products/{id}", s.handleUpdateProduct)
r.Get("/marketing/calendar", s.handleGetMarketingCalendar)
@@ -438,7 +447,7 @@ func mountV1DomainTestRouter(s *Server) http.Handler {
r.Get("/categories", s.handleV1ListCategories)
r.Post("/categories", s.handleV1CreateCategory)
r.Post("/categories/create", s.handleV1CreateCategory)
r.Get("/categories/{id}", s.handleGetCategory)
r.Get("/categories/{id}", s.handleV1GetCategory)
r.Patch("/categories/{id}", s.handleUpdateCategory)
r.Delete("/categories/{id}", s.handleV1DeleteCategory)
@@ -480,9 +489,9 @@ func TestV1OpenAPIDocumentsDomainCRUDSurface(t *testing.T) {
"/marketing/calendar:",
"/products:",
"/feeds/{id}/sync-process-sample:",
"Flat category JSON",
"no prompts or formulas",
"flat PresentFeed",
"flat ProcessedProduct",
"without mapped_data",
"CategoryDetail",
"FeedDeleted",
"FeedMappings",