Skip to content

Commit 51a11c8

Browse files
author
Stas Puga
committed
Merge remote-tracking branch 'origin/MAGETWO-94843' into 2.3-develop-mftf-pr6
2 parents 174cc93 + bd16304 commit 51a11c8

File tree

4 files changed

+198
-12
lines changed

4 files changed

+198
-12
lines changed

app/code/Magento/Catalog/Test/Mftf/Section/StorefrontMessagesSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1111
<section name="StorefrontMessagesSection">
1212
<element name="success" type="text" selector="div.message-success.success.message"/>
13+
<element name="error" type="text" selector="div.message-error.error.message"/>
1314
</section>
1415
</sections>

app/code/Magento/SalesRule/Test/Mftf/ActionGroup/ApplyCartRuleOnStorefrontActionGroup.xml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,16 @@
99
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
1010
<actionGroup name="ApplyCartRuleOnStorefrontActionGroup">
1111
<arguments>
12-
<argument name="Product" defaultValue="_defaultProduct"/>
13-
<argument name="Coupon" defaultValue="SimpleSalesRuleCoupon"/>
12+
<argument name="product"/>
13+
<argument name="couponCode" type="string"/>
1414
</arguments>
15-
<amOnPage url="{{Product.name}}.html" stepKey="navigateToProductPage"/>
16-
<waitForPageLoad stepKey="waitForPageLoad1"/>
1715
<click selector="{{StorefrontProductActionSection.addToCart}}" stepKey="addToCart" />
18-
<waitForText userInput="You added {{Product.name}} to your shopping cart." stepKey="waitForAddedBtn"/>
19-
<amOnPage url="/checkout/cart/" stepKey="onPageShoppingCart"/>
20-
<waitForPageLoad stepKey="waitForPageLoad2"/>
21-
<click selector="{{DiscountSection.DiscountTab}}" stepKey="scrollToDiscountTab" />
22-
<fillField selector="{{DiscountSection.CouponInput}}" userInput="{{Coupon.code}}" stepKey="fillCouponCode" />
16+
<waitForText userInput="You added {{product.name}} to your shopping cart." stepKey="waitForText"/>
17+
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCheckoutPage"/>
18+
<waitForPageLoad stepKey="waitForPageLoad1"/>
19+
<click selector="{{DiscountSection.DiscountTab}}" stepKey="clickToDiscountTab" />
20+
<fillField selector="{{DiscountSection.CouponInput}}" userInput="{{couponCode}}" stepKey="fillCouponCode"/>
2321
<click selector="{{DiscountSection.ApplyCodeBtn}}" stepKey="applyCode"/>
24-
<waitForPageLoad stepKey="waitForPageLoad3"/>
25-
<waitForText userInput="You used coupon code" stepKey="waitForText"/>
26-
<see userInput="You used coupon code" stepKey="assertText"/>
22+
<waitForPageLoad stepKey="waitForPageLoad2"/>
2723
</actionGroup>
2824
</actionGroups>

app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,32 @@
6060
<data key="apply">Percent of product price discount</data>
6161
<data key="discountAmount">50</data>
6262
</entity>
63+
<entity name="SalesRuleSpecificCoupon" type="SalesRule">
64+
<data key="name" unique="suffix">SimpleSalesRule</data>
65+
<data key="description">Sales Rule Descritpion</data>
66+
<array key="website_ids">
67+
<item>1</item>
68+
</array>
69+
<array key="customer_group_ids">
70+
<item>0</item>
71+
<item>1</item>
72+
<item>3</item>
73+
</array>
74+
<data key="uses_per_customer">1</data>
75+
<data key="is_active">true</data>
76+
<data key="stop_rules_processing">false</data>
77+
<data key="is_advanced">true</data>
78+
<data key="sort_order">2</data>
79+
<data key="simple_action">by_percent</data>
80+
<data key="discount_amount">10</data>
81+
<data key="discount_qty">1</data>
82+
<data key="discount_step">0</data>
83+
<data key="apply_to_shipping">false</data>
84+
<data key="times_used">1</data>
85+
<data key="is_rss">false</data>
86+
<data key="coupon_type">SPECIFIC_COUPON</data>
87+
<data key="use_auto_generation">true</data>
88+
<data key="uses_per_coupon">2</data>
89+
<data key="simple_free_shipping">1</data>
90+
</entity>
6391
</entities>
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="StorefrontAutoGeneratedCouponCodeTest">
12+
<annotations>
13+
<features value="SalesRule"/>
14+
<stories value="Create cart price rule"/>
15+
<title value="[Cart Price Rule] Auto generated coupon code considers 'Uses per Coupon' and 'Uses per Customer' options"/>
16+
<description
17+
value="[Cart Price Rule] Auto generated coupon code considers 'Uses per Coupon' and 'Uses per Customer' options"/>
18+
<severity value="AVERAGE"/>
19+
<testCaseId value="MAGETWO-59323"/>
20+
<group value="salesRule"/>
21+
</annotations>
22+
23+
<before>
24+
<!-- Create customer -->
25+
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
26+
<!-- Create simple product-->
27+
<createData entity="SimpleProduct2" stepKey="createSimpleProduct"/>
28+
<!-- Create a cart price rule -->
29+
<createData entity="SalesRuleSpecificCoupon" stepKey="createSalesRule"/>
30+
</before>
31+
32+
<after>
33+
<!-- Delete the cart price rule we made during the test -->
34+
<deleteData createDataKey="createSalesRule" stepKey="deleteSalesRule"/>
35+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
36+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
37+
<actionGroup ref="logout" stepKey="logout"/>
38+
</after>
39+
<!-- Login as Admin -->
40+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
41+
42+
<!-- Search Cart Price Rule and go to edit Cart Price Rule -->
43+
<amOnPage url="{{AdminCartPriceRulesPage.url}}" stepKey="amOnCartPriceList"/>
44+
<waitForPageLoad stepKey="waitForPageLoad"/>
45+
<fillField selector="{{AdminCartPriceRulesSection.filterByNameInput}}" userInput="$$createSalesRule.name$$"
46+
stepKey="fillFieldFilterByName"/>
47+
<click selector="{{AdminCartPriceRulesSection.searchButton}}" stepKey="clickSearchButton"/>
48+
<see selector="{{AdminCartPriceRulesSection.nameColumns}}" userInput="$$createSalesRule.name$$"
49+
stepKey="seeRuleName"/>
50+
<click selector="{{AdminCartPriceRulesSection.rowContainingText($$createSalesRule.name$$)}}"
51+
stepKey="goToEditRule"/>
52+
53+
<!-- Step 3-4. Navigate to Manage Coupon Codes section to generate 1 coupon code -->
54+
<conditionalClick selector="{{AdminCartPriceRulesFormSection.manageCouponCodesHeader}}"
55+
dependentSelector="{{AdminCartPriceRulesFormSection.manageCouponCodesHeader}}" visible="true"
56+
stepKey="clickManageCouponCodes"/>
57+
<fillField selector="{{AdminCartPriceRulesFormSection.couponQty}}" userInput="1" stepKey="fillFieldCouponQty"/>
58+
<click selector="{{AdminCartPriceRulesFormSection.generateCouponsButton}}" stepKey="clickGenerateCoupon"/>
59+
<see selector="{{AdminCartPriceRulesFormSection.successMessage}}" userInput="1 coupon(s) have been generated."
60+
stepKey="seeSuccessMessage"/>
61+
<grabTextFrom selector="{{AdminCartPriceRulesFormSection.generatedCouponByIndex('1')}}"
62+
stepKey="couponCode"/>
63+
64+
<!-- Step: 5. Login to storefront as previously created customer -->
65+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginAsCustomer">
66+
<argument name="Customer" value="$$createCustomer$$"/>
67+
</actionGroup>
68+
69+
<!-- Step: 6-7. Open the Product Page, add the product to Cart, go to Shopping Cart and Apply the same coupon code -->
70+
<amOnPage url="{{StorefrontProductPage.url($$createSimpleProduct.name$$)}}" stepKey="openProductPage"/>
71+
<waitForPageLoad stepKey="waitForPageLoad2"/>
72+
<actionGroup ref="ApplyCartRuleOnStorefrontActionGroup" stepKey="applyCartPriceRule">
73+
<argument name="product" value="$$createSimpleProduct$$"/>
74+
<argument name="couponCode" value="{$couponCode}"/>
75+
</actionGroup>
76+
<waitForText userInput='You used coupon code "{$couponCode}"' stepKey="waitForText"/>
77+
<see selector="{{StorefrontMessagesSection.success}}" userInput='You used coupon code "{$couponCode}"'
78+
stepKey="seeSuccessMessage1"/>
79+
<waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" time="30"
80+
stepKey="waitForElementDiscountVisible"/>
81+
82+
<!-- Step 8. Go to Checkout and Click Place Order button -->
83+
<click selector="{{CheckoutCartSummarySection.proceedToCheckout}}" stepKey="clickProceedToCheckout"/>
84+
<click selector="{{CheckoutShippingMethodsSection.checkShippingMethodByName('Flat Rate')}}"
85+
stepKey="selectFlatShippingMethod"/>
86+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/>
87+
<waitForElement selector="{{CheckoutShippingMethodsSection.next}}" time="30" stepKey="waitForNextButton"/>
88+
<click selector="{{CheckoutShippingMethodsSection.next}}" stepKey="clickNext"/>
89+
<waitForElement selector="{{CheckoutPaymentSection.paymentSectionTitle}}" time="30"
90+
stepKey="waitForPaymentSectionLoaded"/>
91+
<click selector="{{CheckoutPaymentSection.placeOrder}}" stepKey="clickPlaceOrder"/>
92+
<waitForElement selector="{{CheckoutSuccessMainSection.success}}" time="30" stepKey="waitForLoadSuccessPage"/>
93+
94+
<!-- Step: 9-10. Open the Product Page, add the product to Cart, go to Shopping Cart and Apply the same coupon code -->
95+
<amOnPage url="{{StorefrontProductPage.url($$createSimpleProduct.name$$)}}" stepKey="openProductPage1"/>
96+
<waitForPageLoad stepKey="waitForPageLoad3"/>
97+
<actionGroup ref="ApplyCartRuleOnStorefrontActionGroup" stepKey="applyCartPriceRule1">
98+
<argument name="product" value="$$createSimpleProduct$$"/>
99+
<argument name="couponCode" value="{$couponCode}"/>
100+
</actionGroup>
101+
<waitForText userInput='The coupon code "{$couponCode}" is not valid.' stepKey="waitForText1"/>
102+
<see selector="{{StorefrontMessagesSection.error}}" userInput='The coupon code "{$couponCode}" is not valid.'
103+
stepKey="seeErrorMessages"/>
104+
<waitForElementNotVisible selector="{{CheckoutCartSummarySection.discountAmount}}" time="30"
105+
stepKey="waitForElementNotDiscountVisible"/>
106+
107+
<!-- Step 11. Log out from storefront -->
108+
<actionGroup ref="StorefrontSignOutActionGroup" stepKey="storefrontSignOut"/>
109+
110+
<!-- Step: 12-13. Open the Product Page, add the product to Cart, go to Shopping Cart and Apply the same coupon code -->
111+
<amOnPage url="{{StorefrontProductPage.url($$createSimpleProduct.name$$)}}" stepKey="openProductPage2"/>
112+
<waitForPageLoad stepKey="waitForPageLoad4"/>
113+
<actionGroup ref="ApplyCartRuleOnStorefrontActionGroup" stepKey="applyCartPriceRule2">
114+
<argument name="product" value="$$createSimpleProduct$$"/>
115+
<argument name="couponCode" value="{$couponCode}"/>
116+
</actionGroup>
117+
<waitForText userInput='You used coupon code "{$couponCode}"' stepKey="waitForText2"/>
118+
<see selector="{{StorefrontMessagesSection.success}}" userInput='You used coupon code "{$couponCode}"'
119+
stepKey="seeSuccessMessage2"/>
120+
<waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" time="30"
121+
stepKey="waitForElementDiscountVisible1"/>
122+
123+
<!-- Step 14. Go to Checkout and Click Place Order button -->
124+
<click selector="{{CheckoutCartSummarySection.proceedToCheckout}}" stepKey="clickProceedToCheckout1"/>
125+
<actionGroup ref="GuestCheckoutFillingShippingSectionActionGroup" stepKey="guestCheckoutFillingShippingSection">
126+
<argument name="customerVar" value="CustomerEntityOne"/>
127+
<argument name="customerAddressVar" value="CustomerAddressSimple"/>
128+
</actionGroup>
129+
<click selector="{{CheckoutPaymentSection.placeOrder}}" stepKey="clickPlaceOrder1"/>
130+
<waitForElement selector="{{CheckoutSuccessMainSection.success}}" time="30" stepKey="waitForLoadSuccessPage1"/>
131+
132+
<!-- Step; 15-16. Open the Product Page, add the product to Cart, go to Shopping Cart and Apply the same coupon code -->
133+
<amOnPage url="{{StorefrontProductPage.url($$createSimpleProduct.name$$)}}" stepKey="openProductPage3"/>
134+
<waitForPageLoad stepKey="waitForPageLoad5"/>
135+
<actionGroup ref="ApplyCartRuleOnStorefrontActionGroup" stepKey="applyCartPriceRule3">
136+
<argument name="product" value="$$createSimpleProduct$$"/>
137+
<argument name="couponCode" value="{$couponCode}"/>
138+
</actionGroup>
139+
<waitForText userInput='The coupon code "{$couponCode}" is not valid.' stepKey="waitForText3"/>
140+
<see selector="{{StorefrontMessagesSection.error}}" userInput='The coupon code "{$couponCode}" is not valid.'
141+
stepKey="seeErrorMessages1"/>
142+
<waitForElementNotVisible selector="{{CheckoutCartSummarySection.discountAmount}}" time="30"
143+
stepKey="waitForElementNotDiscountVisible1"/>
144+
145+
<!-- Step: 17. Reset Cookie -->
146+
<resetCookie userInput="PHPSESSID" stepKey="resetCookie"/>
147+
148+
<!-- Step: 18-19. Open the Product Page, add the product to Cart, go to Shopping Cart and Apply the same coupon code -->
149+
<amOnPage url="{{StorefrontProductPage.url($$createSimpleProduct.name$$)}}" stepKey="openProductPage4"/>
150+
<waitForPageLoad stepKey="waitForPageLoad6"/>
151+
<actionGroup ref="ApplyCartRuleOnStorefrontActionGroup" stepKey="applyCartPriceRule4">
152+
<argument name="product" value="$$createSimpleProduct$$"/>
153+
<argument name="couponCode" value="{$couponCode}"/>
154+
</actionGroup>
155+
<waitForText userInput='The coupon code "{$couponCode}" is not valid.' stepKey="waitForText4"/>
156+
<see selector="{{StorefrontMessagesSection.error}}" userInput='The coupon code "{$couponCode}" is not valid.'
157+
stepKey="seeErrorMessages2"/>
158+
<waitForElementNotVisible selector="{{CheckoutCartSummarySection.discountAmount}}" time="30"
159+
stepKey="waitForElementNotDiscountVisible2"/>
160+
</test>
161+
</tests>

0 commit comments

Comments
 (0)