fix(link-modules): recreate dismissed link (#6764)
* fix(link-modules): recreate dismissed link * rm type --------- Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
co-authored by
Oli Juhl
parent
eefde48eef
commit
60070fb65f
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/link-modules": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Recreate dismissed link
|
||||||
@@ -238,6 +238,35 @@ medusaIntegrationTestRunner({
|
|||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("Should dismiss the link of a given pair of keys and recreate it", async function () {
|
||||||
|
await links.linkServiceName.create("123", "abc", {
|
||||||
|
extra_field: 333,
|
||||||
|
another_field: "value**",
|
||||||
|
})
|
||||||
|
|
||||||
|
await links.linkServiceName.dismiss("123", "abc")
|
||||||
|
|
||||||
|
const values = await links.linkServiceName.list()
|
||||||
|
|
||||||
|
expect(values).toHaveLength(0)
|
||||||
|
|
||||||
|
await links.linkServiceName.create("123", "abc", {
|
||||||
|
another_field: "changed",
|
||||||
|
})
|
||||||
|
|
||||||
|
const values2 = await links.linkServiceName.list()
|
||||||
|
|
||||||
|
expect(values2).toEqual([
|
||||||
|
expect.objectContaining({
|
||||||
|
product_id: "123",
|
||||||
|
inventory_item_id: "abc",
|
||||||
|
extra_field: 333,
|
||||||
|
another_field: "changed",
|
||||||
|
deleted_at: null,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ export function getLinkRepository(model: EntitySchema) {
|
|||||||
link.id,
|
link.id,
|
||||||
this.joinerConfig_.databaseConfig?.idPrefix ?? "link"
|
this.joinerConfig_.databaseConfig?.idPrefix ?? "link"
|
||||||
)
|
)
|
||||||
|
link.deleted_at = null
|
||||||
|
|
||||||
return manager.create(model, link)
|
return manager.create(model, link)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -84,6 +84,13 @@ export function generateEntity(
|
|||||||
filters: {
|
filters: {
|
||||||
[SoftDeletableFilterKey]: mikroOrmSoftDeletableFilterOptions,
|
[SoftDeletableFilterKey]: mikroOrmSoftDeletableFilterOptions,
|
||||||
},
|
},
|
||||||
|
hooks: {
|
||||||
|
beforeUpdate: [
|
||||||
|
(args) => {
|
||||||
|
args.entity.updated_at = new Date()
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
indexes: [
|
indexes: [
|
||||||
{
|
{
|
||||||
properties: ["id"],
|
properties: ["id"],
|
||||||
|
|||||||
Reference in New Issue
Block a user