fix(core-flows, link-modules): return fulfillment creation (#12227)
* fix: return fulfillment creation * chore: changeset * fix: link * fix: cancel claim flow * chore: test fulfillment creation as a part of return lifecycle test * fix: exchanges cancle flow --------- Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
@@ -762,14 +762,39 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should go through cancel flow successfully", async () => {
|
||||
await api.post(`/admin/claims/${claimId}/cancel`, {}, adminHeaders)
|
||||
|
||||
const [claim] = (
|
||||
// fetch claim to get return id
|
||||
let claim = (
|
||||
await api.get(
|
||||
`/admin/claims?fields=*claim_items,*additional_items`,
|
||||
`/admin/claims/${claimId}?fields=return_id`,
|
||||
adminHeaders
|
||||
)
|
||||
).data.claims
|
||||
).data.claim
|
||||
|
||||
// fetch return and fulfillment
|
||||
const return_ = (
|
||||
await api.get(
|
||||
`/admin/returns/${claim.return_id}?fields=fulfillments.id`,
|
||||
adminHeaders
|
||||
)
|
||||
).data.return
|
||||
|
||||
/**
|
||||
* Claim cannot be canceled unless all fulfillments are not canceled
|
||||
*/
|
||||
await api.post(
|
||||
`/admin/fulfillments/${return_.fulfillments[0].id}/cancel`,
|
||||
{},
|
||||
adminHeaders
|
||||
)
|
||||
|
||||
await api.post(`/admin/claims/${claimId}/cancel`, {}, adminHeaders)
|
||||
|
||||
claim = (
|
||||
await api.get(
|
||||
`/admin/claims/${claimId}?fields=*claim_items,*additional_items`,
|
||||
adminHeaders
|
||||
)
|
||||
).data.claim
|
||||
|
||||
expect(claim.canceled_at).toBeDefined()
|
||||
|
||||
|
||||
@@ -582,6 +582,23 @@ medusaIntegrationTestRunner({
|
||||
expect(result[0].additional_items).toHaveLength(1)
|
||||
expect(result[0].canceled_at).toBeNull()
|
||||
|
||||
const return_ = (
|
||||
await api.get(
|
||||
`/admin/returns/${result[0].return_id}?fields=*fulfillments`,
|
||||
adminHeaders
|
||||
)
|
||||
).data.return
|
||||
|
||||
expect(return_.fulfillments).toHaveLength(1)
|
||||
expect(return_.fulfillments[0].canceled_at).toBeNull()
|
||||
|
||||
// all exchange return fulfillments should be canceled before canceling the exchange
|
||||
await api.post(
|
||||
`/admin/fulfillments/${return_.fulfillments[0].id}/cancel`,
|
||||
{},
|
||||
adminHeaders
|
||||
)
|
||||
|
||||
await api.post(
|
||||
`/admin/exchanges/${exchangeId}/cancel`,
|
||||
{},
|
||||
|
||||
@@ -724,6 +724,39 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
)
|
||||
|
||||
const return_ = (
|
||||
await api.get(
|
||||
`/admin/returns/${returnId}?fields=*fulfillments,*fulfillments.items`,
|
||||
adminHeaders
|
||||
)
|
||||
).data.return
|
||||
|
||||
// return fulfillment is created for the return
|
||||
expect(return_.fulfillments).toHaveLength(1)
|
||||
expect(return_.fulfillments[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
location_id: location.id,
|
||||
packed_at: null,
|
||||
shipped_at: null,
|
||||
marked_shipped_by: null,
|
||||
delivered_at: null,
|
||||
canceled_at: null,
|
||||
data: {},
|
||||
requires_shipping: true,
|
||||
provider_id: "manual_test-provider",
|
||||
items: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
title: "Custom Item 2",
|
||||
line_item_id: item.id,
|
||||
inventory_item_id: null,
|
||||
fulfillment_id: return_.fulfillments[0].id,
|
||||
quantity: 2,
|
||||
}),
|
||||
]),
|
||||
})
|
||||
)
|
||||
expect(result.data.order_preview).toEqual(
|
||||
expect.objectContaining({
|
||||
id: order.id,
|
||||
|
||||
Reference in New Issue
Block a user