Skip to content

Commit 609d1f1

Browse files
committed
MC-62: Admin should be able to create a cart price rule of type Fixed amount discount
- Fix code review feedback
1 parent 4c38cb8 commit 609d1f1

File tree

7 files changed

+58
-32
lines changed

7 files changed

+58
-32
lines changed

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Checkout/Section/CheckoutCartSummarySection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
<element name="shipping" type="text" selector="//*[@id='cart-totals']//tr[@class='totals shipping excl']//td//span[@class='price']"/>
1515
<element name="total" type="text" selector="//*[@id='cart-totals']//tr[@class='grand totals']//td//span[@class='price']"/>
1616
<element name="proceedToCheckout" type="button" selector=".action.primary.checkout span" timeout="30"/>
17+
<element name="discountAmount" type="text" selector="td[data-th='Discount']"/>
1718
</section>
1819
</sections>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/SalesRule/ActionGroup/StorefrontSalesRuleActionGroup.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,20 @@
3838
<see userInput="{{rule.store_labels[1][store_label]}}" selector="{{CheckoutCartSummarySection.discountLabel}}" stepKey="assertDiscountLabel" />
3939
<see userInput="-${{discount}}" selector="{{CheckoutCartSummarySection.discountTotal}}" stepKey="assertDiscountTotal" />
4040
</actionGroup>
41+
42+
<actionGroup name="VerifyDiscountAmount">
43+
<arguments>
44+
<argument name="productUrl" type="string"/>
45+
<argument name="quantity" type="string"/>
46+
<argument name="expectedDiscount" type="string"/>
47+
</arguments>
48+
<amOnPage url="{{productUrl}}" stepKey="goToProductPage"/>
49+
<waitForPageLoad stepKey="waitForProductPageLoad"/>
50+
<fillField selector="{{StorefrontProductActionSection.quantity}}" userInput="{{quantity}}" stepKey="fillQuantity"/>
51+
<click selector="{{StorefrontProductActionSection.addToCart}}" stepKey="addProductToCart"/>
52+
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCartPage"/>
53+
<waitForPageLoad stepKey="waitForCartPage"/>
54+
<waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="waitForDiscountElement"/>
55+
<see selector="{{CheckoutCartSummarySection.discountAmount}}" userInput="{{expectedDiscount}}" stepKey="seeDiscountTotal"/>
56+
</actionGroup>
4157
</actionGroups>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/SalesRule/Test/AdminCreateBuyXGetYFreeTest.xml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,10 @@
5454
</actionGroup>
5555

5656
<!-- Spot check the storefront -->
57-
<amOnPage url="{{_defaultProduct.urlKey}}.html" stepKey="goToProductPage"/>
58-
<waitForPageLoad stepKey="waitForProductPageLoad"/>
59-
<fillField selector="{{StorefrontProductActionSection.quantity}}" userInput="2" stepKey="fillQuantity"/>
60-
<click selector="{{StorefrontProductActionSection.addToCart}}" stepKey="addProductToCart"/>
61-
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCartPage"/>
62-
<waitForPageLoad stepKey="waitForCartPage"/>
63-
<waitForElementVisible selector="td[data-th='Discount']" stepKey="waitForDiscountElement"/>
64-
<see selector="td[data-th='Discount']" userInput="-$123.00" stepKey="seeDiscountTotal"/>
57+
<actionGroup ref="VerifyDiscountAmount" stepKey="verifyStorefront">
58+
<argument name="productUrl" value="{{_defaultProduct.urlKey}}.html"/>
59+
<argument name="quantity" value="2"/>
60+
<argument name="expectedDiscount" value="-$123.00"/>
61+
</actionGroup>
6562
</test>
6663
</tests>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/SalesRule/Test/AdminCreateCartPriceRuleForCouponCodeTest.xml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
</annotations>
2121

2222
<before>
23+
<createData entity="_defaultCategory" stepKey="createPreReqCategory"/>
2324
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
2425
</before>
2526

@@ -28,7 +29,7 @@
2829
<actionGroup ref="DeleteCartPriceRuleByName" stepKey="cleanUpRule">
2930
<argument name="ruleName" value="{{_defaultCoupon.code}}"/>
3031
</actionGroup>
31-
32+
<deleteData createDataKey="createPreReqCategory" stepKey="deletePreReqCategory"/>
3233
<amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/>
3334
</after>
3435

@@ -62,5 +63,24 @@
6263
<click selector="{{AdminCartPriceRulesFormSection.actionsHeader}}" stepKey="clickToExpandActions2"/>
6364
<seeOptionIsSelected selector="{{AdminCartPriceRulesFormSection.apply}}" userInput="Fixed amount discount for whole cart" stepKey="seeActionType"/>
6465
<seeInField selector="{{AdminCartPriceRulesFormSection.discountAmount}}" userInput="5" stepKey="seeDiscountAmount"/>
66+
67+
<!-- Create a product to check the storefront -->
68+
<actionGroup ref="FillAdminSimpleProductForm" stepKey="fillProductFieldsInAdmin">
69+
<argument name="category" value="$$createPreReqCategory$$"/>
70+
<argument name="simpleProduct" value="_defaultProduct"/>
71+
</actionGroup>
72+
73+
<!-- Spot check the storefront -->
74+
<amOnPage url="{{_defaultProduct.urlKey}}.html" stepKey="goToProductPage"/>
75+
<waitForPageLoad stepKey="waitForProductPageLoad"/>
76+
<click selector="{{StorefrontProductActionSection.addToCart}}" stepKey="addProductToCart"/>
77+
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCartPage"/>
78+
<waitForPageLoad stepKey="waitForCartPage"/>
79+
<actionGroup ref="StorefrontApplyCouponActionGroup" stepKey="applyCoupon">
80+
<argument name="coupon" value="_defaultCoupon"/>
81+
</actionGroup>
82+
<waitForPageLoad stepKey="waitForProductPageLoad2"/>
83+
<waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="waitForDiscountElement"/>
84+
<see selector="{{CheckoutCartSummarySection.discountAmount}}" userInput="-$5.00" stepKey="seeDiscountTotal"/>
6585
</test>
6686
</tests>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/SalesRule/Test/AdminCreateFixedAmountDiscountTest.xml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,10 @@
5353
</actionGroup>
5454

5555
<!-- Spot check the storefront -->
56-
<amOnPage url="{{_defaultProduct.urlKey}}.html" stepKey="goToProductPage"/>
57-
<waitForPageLoad stepKey="waitForProductPageLoad"/>
58-
<click selector="{{StorefrontProductActionSection.addToCart}}" stepKey="addProductToCart"/>
59-
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCartPage"/>
60-
<waitForPageLoad stepKey="waitForCartPage"/>
61-
<waitForElementVisible selector="td[data-th='Discount']" stepKey="waitForDiscountElement"/>
62-
<see selector="td[data-th='Discount']" userInput="-$10.00" stepKey="seeDiscountTotal"/>
56+
<actionGroup ref="VerifyDiscountAmount" stepKey="verifyStorefront">
57+
<argument name="productUrl" value="{{_defaultProduct.urlKey}}.html"/>
58+
<argument name="quantity" value="2"/>
59+
<argument name="expectedDiscount" value="-$20.00"/>
60+
</actionGroup>
6361
</test>
6462
</tests>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/SalesRule/Test/AdminCreateFixedAmountWholeCartDiscountTest.xml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,10 @@
5353
</actionGroup>
5454

5555
<!-- Spot check the storefront -->
56-
<amOnPage url="{{_defaultProduct.urlKey}}.html" stepKey="goToProductPage"/>
57-
<waitForPageLoad stepKey="waitForProductPageLoad"/>
58-
<!-- Use quantity 2 to verify that this discount is only applied once for the entire cart and not once per item -->
59-
<fillField selector="{{StorefrontProductActionSection.quantity}}" userInput="2" stepKey="fillQuantity"/>
60-
<click selector="{{StorefrontProductActionSection.addToCart}}" stepKey="addProductToCart"/>
61-
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCartPage"/>
62-
<waitForPageLoad stepKey="waitForCartPage"/>
63-
<waitForElementVisible selector="td[data-th='Discount']" stepKey="waitForDiscountElement"/>
64-
<see selector="td[data-th='Discount']" userInput="-$19.99" stepKey="seeDiscountTotal"/>
56+
<actionGroup ref="VerifyDiscountAmount" stepKey="verifyStorefront">
57+
<argument name="productUrl" value="{{_defaultProduct.urlKey}}.html"/>
58+
<argument name="quantity" value="2"/>
59+
<argument name="expectedDiscount" value="-$19.99"/>
60+
</actionGroup>
6561
</test>
6662
</tests>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/SalesRule/Test/AdminCreatePercentOfProductPriceTest.xml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,10 @@
5353
</actionGroup>
5454

5555
<!-- Spot check the storefront -->
56-
<amOnPage url="{{_defaultProduct.urlKey}}.html" stepKey="goToProductPage"/>
57-
<waitForPageLoad stepKey="waitForProductPageLoad"/>
58-
<click selector="{{StorefrontProductActionSection.addToCart}}" stepKey="addProductToCart"/>
59-
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCartPage"/>
60-
<waitForPageLoad stepKey="waitForCartPage"/>
61-
<waitForElementVisible selector="td[data-th='Discount']" stepKey="waitForDiscountElement"/>
62-
<see selector="td[data-th='Discount']" userInput="-$61.50" stepKey="seeDiscountTotal"/>
56+
<actionGroup ref="VerifyDiscountAmount" stepKey="verifyStorefront">
57+
<argument name="productUrl" value="{{_defaultProduct.urlKey}}.html"/>
58+
<argument name="quantity" value="1"/>
59+
<argument name="expectedDiscount" value="-$61.50"/>
60+
</actionGroup>
6361
</test>
6462
</tests>

0 commit comments

Comments
 (0)