Skip to content

Commit 09d13b8

Browse files
committed
Test showing that a discount applied by a salesrule affects the table rate shipping method
1 parent 2602b9f commit 09d13b8

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
3+
<test name="SalesRuleDiscountIsAppliedOnPackageValueForTableRateTest">
4+
<annotations>
5+
<features value="Shipping"/>
6+
<stories value="Offline Shipping Methods"/>
7+
<title value="SalesRule Discount Is Applied On PackageValue For TableRate"/>
8+
<description value="SalesRule Discount Is Applied On PackageValue For TableRate"/>
9+
<severity value="AVERAGE"/>
10+
<group value="shipping"/>
11+
</annotations>
12+
<before>
13+
<!-- Add simple product -->
14+
<createData entity="SimpleProduct2" stepKey="createSimpleProduct">
15+
<field key="price">13.00</field>
16+
</createData>
17+
18+
<!-- Create cart price rule -->
19+
<createData entity="ActiveSalesRuleForNotLoggedIn" stepKey="createCartPriceRule"/>
20+
<createData entity="SimpleSalesRuleCoupon" stepKey="createCouponForCartPriceRule">
21+
<requiredEntity createDataKey="createCartPriceRule"/>
22+
</createData>
23+
24+
<!-- Login as admin -->
25+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
26+
27+
<!-- Go to Stores > Configuration > Sales > Shipping Methods -->
28+
<actionGroup ref="AdminOpenShippingMethodsConfigPageActionGroup" stepKey="openShippingMethodConfigPage"/>
29+
30+
<!-- Switch to Website scope -->
31+
<actionGroup ref="AdminSwitchWebsiteActionGroup" stepKey="AdminSwitchStoreView">
32+
<argument name="website" value="_defaultWebsite"/>
33+
</actionGroup>
34+
35+
<!-- Enable Table Rate method and save config -->
36+
<actionGroup ref="AdminChangeTableRatesShippingMethodStatusActionGroup" stepKey="enableTableRatesShippingMethod"/>
37+
38+
<!-- Uncheck Use Default checkbox for Default Condition -->
39+
<uncheckOption selector="{{AdminShippingMethodTableRatesSection.carriersTableRateConditionName}}" stepKey="disableUseDefaultCondition"/>
40+
41+
<!-- Make sure you have Condition Price vs. Destination -->
42+
<selectOption selector="{{AdminShippingMethodTableRatesSection.condition}}" userInput="{{TableRateShippingMethodConfig.package_value_with_discount}}" stepKey="setCondition"/>
43+
44+
<!-- Import file and save config -->
45+
<attachFile selector="{{AdminShippingMethodTableRatesSection.importFile}}" userInput="usa_tablerates.csv" stepKey="attachFileForImport"/>
46+
<actionGroup ref="AdminSaveConfigActionGroup" stepKey="saveConfigs"/>
47+
</before>
48+
<after>
49+
<!-- Go to Stores > Configuration > Sales > Shipping Methods -->
50+
<actionGroup ref="AdminOpenShippingMethodsConfigPageActionGroup" stepKey="openShippingMethodConfigPage"/>
51+
52+
<!-- Switch to Website scope -->
53+
<actionGroup ref="AdminSwitchWebsiteActionGroup" stepKey="AdminSwitchStoreView">
54+
<argument name="website" value="_defaultWebsite"/>
55+
</actionGroup>
56+
57+
<!-- Check Use Default checkbox for Default Condition and Active -->
58+
<checkOption selector="{{AdminShippingMethodTableRatesSection.carriersTableRateConditionName}}" stepKey="enableUseDefaultCondition"/>
59+
<checkOption selector="{{AdminShippingMethodTableRatesSection.enabledUseSystemValue}}" stepKey="enableUseDefaultActive"/>
60+
61+
<actionGroup ref="AdminSaveConfigActionGroup" stepKey="saveConfigs"/>
62+
63+
<!-- Log out -->
64+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
65+
66+
<!-- Remove simple product-->
67+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
68+
69+
<!-- Delete sales rule -->
70+
<deleteData createDataKey="createCartPriceRule" stepKey="deleteCartPriceRule"/>
71+
72+
</after>
73+
<!-- Add simple product to cart -->
74+
<actionGroup ref="AddSimpleProductToCartActionGroup" stepKey="addProductToCart">
75+
<argument name="product" value="$$createSimpleProduct$$"/>
76+
</actionGroup>
77+
78+
<!-- Assert that table rate value is correct for US -->
79+
<actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCheckout"/>
80+
<waitForElement time="30" selector="{{CheckoutCartSummarySection.estimateShippingAndTaxForm}}" stepKey="waitForEstimateShippingAndTaxForm"/>
81+
<waitForElement time="30" selector="{{CheckoutCartSummarySection.shippingMethodForm}}" stepKey="waitForShippingMethodForm"/>
82+
<conditionalClick selector="{{CheckoutCartSummarySection.estimateShippingAndTax}}" dependentSelector="{{CheckoutCartSummarySection.country}}" visible="false" stepKey="expandEstimateShippingandTax" />
83+
<selectOption selector="{{CheckoutCartSummarySection.country}}" userInput="United States" stepKey="selectUSCountry"/>
84+
<waitForPageLoad stepKey="waitForSelectCountry"/>
85+
<see selector="{{CheckoutCartSummarySection.shippingPrice}}" userInput="$5.99" stepKey="seeShippingForUS"/>
86+
87+
<!-- Apply Coupon -->
88+
<actionGroup ref="StorefrontApplyCouponActionGroup" stepKey="applyDiscount">
89+
<argument name="coupon" value="$$createCouponForCartPriceRule$$"/>
90+
</actionGroup>
91+
92+
<see selector="{{CheckoutCartSummarySection.shippingPrice}}" userInput="$7.99" stepKey="seeShippingForUSWithDiscount"/>
93+
</test>
94+
</tests>

app/code/Magento/Shipping/Test/Mftf/Data/TableRatesShippingMethodData.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,10 @@
1616
<data key="title">Best Way</data>
1717
<data key="methodName">Table Rate</data>
1818
</entity>
19+
<!-- Set Table Rate Shipping method Condition -->
20+
<entity name="TableRateShippingMethodConfig" type="shipping_method">
21+
<data key="package_weight">Weight vs. Destination</data>
22+
<data key="package_value_with_discount">Price vs. Destination</data>
23+
<data key="package_qty"># of Items vs. Destination</data>
24+
</entity>
1925
</entities>

0 commit comments

Comments
 (0)