fix: make prices optional param when updating a variant (#2155)
**Why** - It should be possible to update variant props without having to send the prices array with every update
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(medusa): make prices optional param when updating a variant
|
||||||
@@ -2374,6 +2374,48 @@ describe("/admin/products", () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("POST /admin/products/:id/variants/:id", () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
await adminSeeder(dbConnection)
|
||||||
|
|
||||||
|
await simpleProductFactory(dbConnection, {
|
||||||
|
id: "test-product-to-update",
|
||||||
|
variants: [
|
||||||
|
{
|
||||||
|
id: "test-variant-to-update",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
const db = useDb()
|
||||||
|
await db.teardown()
|
||||||
|
})
|
||||||
|
|
||||||
|
it("successfully updates variant without prices", async () => {
|
||||||
|
const api = useApi()
|
||||||
|
|
||||||
|
const res = await api
|
||||||
|
.post(
|
||||||
|
"/admin/products/test-product-to-update/variants/test-variant-to-update",
|
||||||
|
{
|
||||||
|
inventory_quantity: 10,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Authorization: "Bearer test_token",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.catch((err) => {
|
||||||
|
console.log(err)
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(res.status).toEqual(200)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("GET /admin/products/tag-usage", () => {
|
describe("GET /admin/products/tag-usage", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await productSeeder(dbConnection)
|
await productSeeder(dbConnection)
|
||||||
|
|||||||
@@ -310,6 +310,7 @@ export class AdminPostProductsProductVariantsVariantReq {
|
|||||||
metadata?: object
|
metadata?: object
|
||||||
|
|
||||||
@IsArray()
|
@IsArray()
|
||||||
|
@IsOptional()
|
||||||
@ValidateNested({ each: true })
|
@ValidateNested({ each: true })
|
||||||
@Type(() => ProductVariantPricesUpdateReq)
|
@Type(() => ProductVariantPricesUpdateReq)
|
||||||
prices: ProductVariantPricesUpdateReq[]
|
prices: ProductVariantPricesUpdateReq[]
|
||||||
|
|||||||
Reference in New Issue
Block a user