fix(medusa): Variant update should include the id for the listeners to be able to identify the entity (#3539)
* fix(medusa): Variant update should include the id for the listeners to be able to identify the entity * fix unit tests * Create brave-seahorses-film.md
This commit is contained in:
committed by
GitHub
parent
17f615ef30
commit
98fe8fd00a
5
.changeset/brave-seahorses-film.md
Normal file
5
.changeset/brave-seahorses-film.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/medusa": patch
|
||||
---
|
||||
|
||||
Fix(medusa): Variant update should include the id for the listeners to be able to identify the entity
|
||||
@@ -333,6 +333,7 @@ describe("ProductVariantService", () => {
|
||||
expect(productVariantRepository.update).toHaveBeenCalledWith(
|
||||
{ id: IdMap.getId("ironman") },
|
||||
{
|
||||
id: IdMap.getId("ironman"),
|
||||
title: "new title",
|
||||
}
|
||||
)
|
||||
@@ -361,6 +362,7 @@ describe("ProductVariantService", () => {
|
||||
expect(productVariantRepository.update).toHaveBeenCalledWith(
|
||||
{ id: IdMap.getId("ironman") },
|
||||
{
|
||||
id: IdMap.getId("ironman"),
|
||||
title: "new title 2",
|
||||
}
|
||||
)
|
||||
@@ -415,6 +417,7 @@ describe("ProductVariantService", () => {
|
||||
expect(productVariantRepository.update).toHaveBeenCalledWith(
|
||||
{ id: IdMap.getId("ironman") },
|
||||
{
|
||||
id: IdMap.getId("ironman"),
|
||||
title: "new title",
|
||||
metadata: {
|
||||
testing: "this",
|
||||
@@ -444,6 +447,7 @@ describe("ProductVariantService", () => {
|
||||
expect(productVariantRepository.update).toHaveBeenCalledWith(
|
||||
{ id: IdMap.getId("ironman") },
|
||||
{
|
||||
id: IdMap.getId("ironman"),
|
||||
inventory_quantity: 98,
|
||||
title: "new title",
|
||||
}
|
||||
|
||||
@@ -396,7 +396,10 @@ class ProductVariantService extends TransactionBaseService {
|
||||
// No need to update if nothing on the variant has changed
|
||||
if (shouldUpdate) {
|
||||
const { id } = variant
|
||||
const rawResult = await variantRepo.update({ id }, toUpdate)
|
||||
const rawResult = await variantRepo.update(
|
||||
{ id },
|
||||
{ id, ...toUpdate }
|
||||
)
|
||||
result = variantRepo.create({
|
||||
...variant,
|
||||
...rawResult.generatedMaps[0],
|
||||
|
||||
Reference in New Issue
Block a user