fix(medusa): Order/Cart decorate totals should assign the items totals (#2546)
**What** If `total` or `subtotal` are selected then get the line item totals and assign them to the items. I also had to remove the totals from the cart update service since they are not used and that by having them the items get the tax lines attached and since the update is performed by passing the entire cart, it is trying to insert the tax lines with the cart update **Tests** Add an integration tests to validate that the items includes the totals in the order and draft order FIXES CORE-687
This commit is contained in:
committed by
GitHub
parent
15d6f92964
commit
129ad4b687
@@ -785,6 +785,40 @@ describe("/admin/draft-orders", () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe("GET /admin/draft-orders/:id", () => {
|
||||
beforeEach(async () => {
|
||||
await adminSeeder(dbConnection)
|
||||
await draftOrderSeeder(dbConnection)
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
const db = useDb()
|
||||
await db.teardown()
|
||||
})
|
||||
|
||||
it("retrieves a draft-order should include the items totals", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const order = await api.get("/admin/draft-orders/test-draft-order", {
|
||||
headers: {
|
||||
authorization: "Bearer test_token",
|
||||
},
|
||||
})
|
||||
|
||||
expect(order.status).toEqual(200)
|
||||
expect(order.data.draft_order).toEqual(
|
||||
expect.objectContaining({
|
||||
id: "test-draft-order",
|
||||
})
|
||||
)
|
||||
|
||||
order.data.draft_order.cart.items.forEach((item) => {
|
||||
expect(item.total).toBeDefined()
|
||||
expect(item.subtotal).toBeDefined()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("DELETE /admin/draft-orders/:id", () => {
|
||||
beforeEach(async () => {
|
||||
await adminSeeder(dbConnection)
|
||||
|
||||
Reference in New Issue
Block a user