const s=require("../../app/validation/catalogue.schemas");const wrap=body=>({body,params:{},query:{}});const base=()=>({brandId:"brand-1",slug:"linen-shirt",productCode:"SHIRT-1",translations:[{locale:"en",name:"Linen Shirt"}],categoryIds:["cat-1"],variants:[{sku:"SHIRT-1-M",basePrice:"1990.00",currency:"LKR"}],mediaUploadIds:[1]}); describe("Phase 4 catalogue validation",()=>{ test("accepts a minimal strict draft product",()=>expect(s.productCreate.safeParse(wrap(base())).success).toBe(true)); test("rejects unknown administrative product fields",()=>expect(s.productCreate.safeParse(wrap({...base(),stock:100})).success).toBe(false)); test("rejects invalid slug",()=>expect(s.productCreate.safeParse(wrap({...base(),slug:"Unsafe Slug!"})).success).toBe(false)); test.each(["12","12.3","12.34"])("accepts decimal money %s",v=>expect(s.money.safeParse(v).success).toBe(true)); test.each(["-1","1.234","NaN","1e3"])("rejects invalid money %s",v=>expect(s.money.safeParse(v).success).toBe(false)); test("supports en si ta and rejects other translations",()=>{for(const locale of ["en","si","ta"])expect(s.productCreate.safeParse(wrap({...base(),translations:[{locale,name:"Name"}]})).success).toBe(true);expect(s.productCreate.safeParse(wrap({...base(),translations:[{locale:"fr",name:"Name"}]})).success).toBe(false);}); test("client cannot set review verification or moderation",()=>{expect(s.review.safeParse(wrap({rating:5,title:"Great",body:"Excellent product"})).success).toBe(true);expect(s.review.safeParse(wrap({rating:5,title:"Great",body:"Excellent product",verifiedPurchase:true,status:"APPROVED"})).success).toBe(false);}); test("validates rating range",()=>{expect(s.review.safeParse(wrap({rating:0,title:"Bad",body:"Not valid"})).success).toBe(false);expect(s.review.safeParse(wrap({rating:5,title:"Good",body:"Valid review"})).success).toBe(true);}); test("size guide accepts structured data and not HTML",()=>{expect(s.sizeGuide.safeParse(wrap({code:"MEN_TOPS",name:"Men tops",locale:"en",data:{columns:["Size","Chest"],rows:[["M","40"]]}})).success).toBe(true);expect(s.sizeGuide.safeParse(wrap({code:"X",name:"X",locale:"en",data:{html:"