From 5d63b0c8d2caf8ecaeae761e0938c83fed8e4680 Mon Sep 17 00:00:00 2001 From: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com> Date: Fri, 20 Aug 2021 17:14:19 +0200 Subject: [PATCH] hotfix: Allow sale_amount product updates (#346) --- .../api/__tests__/admin/product.js | 18 +++++++++++++++++- .../routes/admin/products/update-product.js | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/integration-tests/api/__tests__/admin/product.js b/integration-tests/api/__tests__/admin/product.js index f7bf61d78e..7b0696e02c 100644 --- a/integration-tests/api/__tests__/admin/product.js +++ b/integration-tests/api/__tests__/admin/product.js @@ -173,12 +173,18 @@ describe("/admin/products", () => { ); }); - it("updates a product (update tags, delete collection, delete type, replaces images)", async () => { + it("updates a product (update prices, tags, delete collection, delete type, replaces images)", async () => { const api = useApi(); const payload = { collection_id: null, type: null, + variants: [ + { + id: "test-variant", + prices: [{ currency_code: "usd", amount: 100, sale_amount: 75 }], + }, + ], tags: [{ value: "123" }], images: ["test-image-2.png"], type: { value: "test-type-2" }, @@ -209,6 +215,16 @@ describe("/admin/products", () => { value: "123", }), ], + variants: [ + expect.objectContaining({ + prices: [ + expect.objectContaining({ + sale_amount: 75, + amount: 100, + }), + ], + }), + ], type: null, collection: null, type: expect.objectContaining({ diff --git a/packages/medusa/src/api/routes/admin/products/update-product.js b/packages/medusa/src/api/routes/admin/products/update-product.js index f11982f3e1..71a2fe2cc2 100644 --- a/packages/medusa/src/api/routes/admin/products/update-product.js +++ b/packages/medusa/src/api/routes/admin/products/update-product.js @@ -246,6 +246,7 @@ export default async (req, res) => { amount: Validator.number() .integer() .required(), + sale_amount: Validator.number().optional(), }) .xor("region_id", "currency_code") ),