chore(): Improve cascade soft deletetion/restoration and update (#11618)

**What**
- Fix soft deletion and restoration emitted events
- Improve soft deleted/restore algorithm
- Fix big number field handling null value during partial hydration from mikro orm
This commit is contained in:
Adrien de Peretti
2025-02-26 19:01:36 +01:00
committed by GitHub
parent caf83cf78c
commit d254b2ddba
9 changed files with 337 additions and 202 deletions

View File

@@ -52,7 +52,7 @@ export const buildProductAndRelationsData = ({
options,
variants,
collection_id,
}: Partial<ProductTypes.CreateProductDTO>) => {
}: Partial<ProductTypes.CreateProductDTO> & { tags?: { value: string }[] }) => {
const defaultOptionTitle = "test-option"
const defaultOptionValue = "test-value"

View File

@@ -30,7 +30,7 @@ import {
createTypes,
} from "../../__fixtures__/product"
jest.setTimeout(3000000)
jest.setTimeout(300000)
moduleIntegrationTestRunner<IProductModuleService>({
moduleName: Modules.PRODUCT,
@@ -975,6 +975,85 @@ moduleIntegrationTestRunner<IProductModuleService>({
const data = buildProductAndRelationsData({
images,
thumbnail: images[0].url,
options: [
{ title: "size", values: ["large", "small"] },
{ title: "color", values: ["red", "blue"] },
{ title: "material", values: ["cotton", "polyester"] },
],
variants: [
{
title: "Large Red Cotton",
sku: "LRG-RED-CTN",
options: {
size: "large",
color: "red",
material: "cotton",
},
},
{
title: "Large Red Polyester",
sku: "LRG-RED-PLY",
options: {
size: "large",
color: "red",
material: "polyester",
},
},
{
title: "Large Blue Cotton",
sku: "LRG-BLU-CTN",
options: {
size: "large",
color: "blue",
material: "cotton",
},
},
{
title: "Large Blue Polyester",
sku: "LRG-BLU-PLY",
options: {
size: "large",
color: "blue",
material: "polyester",
},
},
{
title: "Small Red Cotton",
sku: "SML-RED-CTN",
options: {
size: "small",
color: "red",
material: "cotton",
},
},
{
title: "Small Red Polyester",
sku: "SML-RED-PLY",
options: {
size: "small",
color: "red",
material: "polyester",
},
},
{
title: "Small Blue Cotton",
sku: "SML-BLU-CTN",
options: {
size: "small",
color: "blue",
material: "cotton",
},
},
{
title: "Small Blue Polyester",
sku: "SML-BLU-PLY",
options: {
size: "small",
color: "blue",
material: "polyester",
},
},
],
})
const products = await service.createProducts([data])
@@ -1074,6 +1153,26 @@ moduleIntegrationTestRunner<IProductModuleService>({
source: Modules.PRODUCT,
action: CommonEvents.DELETED,
}),
composeMessage(ProductEvents.PRODUCT_VARIANT_DELETED, {
data: { id: [products[0].variants[0].id] },
object: "product_variant",
source: Modules.PRODUCT,
action: CommonEvents.DELETED,
}),
composeMessage(ProductEvents.PRODUCT_OPTION_DELETED, {
data: { id: [products[0].options[0].id] },
object: "product_option",
source: Modules.PRODUCT,
action: CommonEvents.DELETED,
}),
composeMessage(ProductEvents.PRODUCT_OPTION_VALUE_DELETED, {
data: {
id: [products[0].options[0].values[0].id],
},
object: "product_option_value",
source: Modules.PRODUCT,
action: CommonEvents.DELETED,
}),
],
{
internal: true,