fix(fulfillment): Update shipping options rules (#7204)
**What** Fix the update shipping options to apply the rules update properly and remove unused code
This commit is contained in:
+42
-3
@@ -226,7 +226,18 @@ medusaIntegrationTestRunner({
|
||||
amount: 1000,
|
||||
},
|
||||
],
|
||||
rules: [shippingOptionRule],
|
||||
rules: [
|
||||
{
|
||||
operator: RuleOperator.EQ,
|
||||
attribute: "old_attr",
|
||||
value: "old value",
|
||||
},
|
||||
{
|
||||
operator: RuleOperator.EQ,
|
||||
attribute: "old_attr_2",
|
||||
value: "true",
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
const response = await api.post(
|
||||
@@ -240,6 +251,14 @@ medusaIntegrationTestRunner({
|
||||
const eurPrice = response.data.shipping_option.prices.find(
|
||||
(p) => p.currency_code === "eur"
|
||||
)
|
||||
|
||||
const oldAttrRule = response.data.shipping_option.rules.find(
|
||||
(r) => r.attribute === "old_attr"
|
||||
)
|
||||
const oldAttr2Rule = response.data.shipping_option.rules.find(
|
||||
(r) => r.attribute === "old_attr_2"
|
||||
)
|
||||
|
||||
const updateShippingOptionPayload = {
|
||||
name: "Updated shipping option",
|
||||
provider_id: "manual_test-provider",
|
||||
@@ -255,8 +274,22 @@ medusaIntegrationTestRunner({
|
||||
},
|
||||
],
|
||||
rules: [
|
||||
shippingOptionRule,
|
||||
{
|
||||
// Un touched
|
||||
id: oldAttrRule.id,
|
||||
operator: RuleOperator.EQ,
|
||||
attribute: "old_attr",
|
||||
value: "old value",
|
||||
},
|
||||
{
|
||||
// Updated
|
||||
id: oldAttr2Rule.id,
|
||||
operator: RuleOperator.EQ,
|
||||
attribute: "old_attr_2",
|
||||
value: "false",
|
||||
},
|
||||
{
|
||||
// Created
|
||||
operator: RuleOperator.EQ,
|
||||
attribute: "new_attr",
|
||||
value: "true",
|
||||
@@ -272,7 +305,7 @@ medusaIntegrationTestRunner({
|
||||
|
||||
expect(updateResponse.status).toEqual(200)
|
||||
expect(updateResponse.data.shipping_option.prices).toHaveLength(2)
|
||||
expect(updateResponse.data.shipping_option.rules).toHaveLength(2)
|
||||
expect(updateResponse.data.shipping_option.rules).toHaveLength(3)
|
||||
expect(updateResponse.data.shipping_option).toEqual(
|
||||
expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
@@ -310,6 +343,12 @@ medusaIntegrationTestRunner({
|
||||
attribute: "old_attr",
|
||||
value: "old value",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
operator: "eq",
|
||||
attribute: "old_attr_2",
|
||||
value: "false",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
operator: "eq",
|
||||
|
||||
Reference in New Issue
Block a user