|
| 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