fix(medusa): Deleted discount missing on order (#6837)
* Fix deleted discount missing on order * Added integration test * Added changeset
This commit is contained in:
1 parent
86f499de2f
commit
6113af0a66
3 files changed
+39
-2
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix deleted discount missing on order
|
||||||
@@ -2649,6 +2649,34 @@ describe("/admin/orders", () => {
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("retrieves an order should include a deleted discount", async () => {
|
||||||
|
const api = useApi()
|
||||||
|
|
||||||
|
await dbConnection.manager.query(
|
||||||
|
`UPDATE discount
|
||||||
|
set deleted_at = NOW()
|
||||||
|
WHERE id = 'test-discount';`
|
||||||
|
)
|
||||||
|
|
||||||
|
const order = await api.get(
|
||||||
|
`/admin/orders/${testOrderId}`,
|
||||||
|
adminReqConfig
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(order.status).toEqual(200)
|
||||||
|
expect(order.data.order).toEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
id: "test-order",
|
||||||
|
discounts: expect.arrayContaining([
|
||||||
|
expect.objectContaining({
|
||||||
|
id: "test-discount",
|
||||||
|
deleted_at: expect.any(String),
|
||||||
|
}),
|
||||||
|
]),
|
||||||
|
})
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("POST /orders/:id/refund", () => {
|
describe("POST /orders/:id/refund", () => {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
|
|
||||||
const ITEMS_REL_NAME = "items"
|
const ITEMS_REL_NAME = "items"
|
||||||
const REGION_REL_NAME = "region"
|
const REGION_REL_NAME = "region"
|
||||||
|
const DISCOUNTS_REL_NAME = "discounts"
|
||||||
|
|
||||||
export const OrderRepository = dataSource.getRepository(Order).extend({
|
export const OrderRepository = dataSource.getRepository(Order).extend({
|
||||||
async findWithRelations(
|
async findWithRelations(
|
||||||
@@ -28,8 +29,11 @@ export const OrderRepository = dataSource.getRepository(Order).extend({
|
|||||||
where: { id: In(entitiesIds) },
|
where: { id: In(entitiesIds) },
|
||||||
select: ["id"],
|
select: ["id"],
|
||||||
relations: rels,
|
relations: rels,
|
||||||
withDeleted:
|
withDeleted: [
|
||||||
topLevel === ITEMS_REL_NAME || topLevel === REGION_REL_NAME,
|
ITEMS_REL_NAME,
|
||||||
|
REGION_REL_NAME,
|
||||||
|
DISCOUNTS_REL_NAME,
|
||||||
|
].includes(topLevel),
|
||||||
relationLoadStrategy: "join",
|
relationLoadStrategy: "join",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in new issue
Block a user