Skip to content

Commit

Permalink
chore: fix specs
Browse files Browse the repository at this point in the history
  • Loading branch information
riqwan committed Sep 11, 2024
1 parent 8b01022 commit f5f3adf
Showing 1 changed file with 59 additions and 6 deletions.
65 changes: 59 additions & 6 deletions integration-tests/http/__tests__/exchanges/exchanges.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ medusaIntegrationTestRunner({
testSuite: ({ dbConnection, getContainer, api }) => {
let order, order2
let returnShippingOption
let outboundShippingOption
let shippingProfile
let fulfillmentSet
let returnReason
Expand Down Expand Up @@ -345,6 +346,44 @@ medusaIntegrationTestRunner({
],
}

const outboundShippingOptionPayload = {
name: "Oubound shipping",
service_zone_id: fulfillmentSet.service_zones[0].id,
shipping_profile_id: shippingProfile.id,
provider_id: shippingProviderId,
price_type: "flat",
type: {
label: "Test type",
description: "Test description",
code: "test-code",
},
prices: [
{
currency_code: "usd",
amount: 20,
},
],
rules: [
{
operator: RuleOperator.EQ,
attribute: "is_return",
value: "false",
},
{
operator: RuleOperator.EQ,
attribute: "enabled_in_store",
value: "true",
},
],
}
outboundShippingOption = (
await api.post(
"/admin/shipping-options",
outboundShippingOptionPayload,
adminHeaders
)
).data.shipping_option

returnShippingOption = (
await api.post(
"/admin/shipping-options",
Expand Down Expand Up @@ -560,7 +599,7 @@ medusaIntegrationTestRunner({

const item = order.items[0]

let result = await api.post(
await api.post(
`/admin/exchanges/${exchange.id}/inbound/items`,
{
items: [
Expand All @@ -580,7 +619,7 @@ medusaIntegrationTestRunner({
adminHeaders
)

result = await api.post(
await api.post(
`/admin/exchanges/${exchange.id}/outbound/items`,
{
items: [
Expand All @@ -593,6 +632,12 @@ medusaIntegrationTestRunner({
adminHeaders
)

await api.post(
`/admin/exchanges/${exchange.id}/outbound/shipping-method`,
{ shipping_option_id: outboundShippingOption.id },
adminHeaders
)

orderPreview = (
await api.get(`/admin/orders/${order.id}/preview`, adminHeaders)
).data.order
Expand All @@ -610,7 +655,10 @@ medusaIntegrationTestRunner({

const exchangeShippingMethods = orderPreview.shipping_methods.filter(
(item) =>
!!item.actions?.find((action) => action.action === "SHIPPING_ADD")
!!item.actions?.find(
(action) =>
action.action === "SHIPPING_ADD" && !action.return_id
)
)

expect(exchangeItems).toHaveLength(1)
Expand All @@ -634,7 +682,8 @@ medusaIntegrationTestRunner({
orderPreview.shipping_methods.filter(
(item) =>
!!item.actions?.find(
(action) => action.action === "SHIPPING_ADD"
(action) =>
action.action === "SHIPPING_ADD" && !action.return_id
)
)

Expand All @@ -654,7 +703,10 @@ medusaIntegrationTestRunner({

const exchangeShippingMethods = orderPreview.shipping_methods.filter(
(item) =>
!!item.actions?.find((action) => action.action === "SHIPPING_ADD")
!!item.actions?.find(
(action) =>
action.action === "SHIPPING_ADD" && !!action.return_id
)
)

expect(exchangeItems).toHaveLength(1)
Expand All @@ -678,7 +730,8 @@ medusaIntegrationTestRunner({
orderPreview.shipping_methods.filter(
(item) =>
!!item.actions?.find(
(action) => action.action === "SHIPPING_ADD"
(action) =>
action.action === "SHIPPING_ADD" && !!action.return_id
)
)

Expand Down

0 comments on commit f5f3adf

Please sign in to comment.