|
7 | 7 | -->
|
8 | 8 |
|
9 | 9 | <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
10 |
| - xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> |
| 10 | + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> |
11 | 11 | <test name="CartPriceRuleForConfigurableProductTest">
|
12 | 12 | <annotations>
|
13 | 13 | <features value="SalesRule"/>
|
14 |
| - <stories value="MAGETWO-86098 - Cart Price Rule for configurable products"/> |
| 14 | + <stories value="Create cart price rule"/> |
15 | 15 | <title value="Checking Cart Price Rule for configurable products"/>
|
16 | 16 | <description value="Checking Cart Price Rule for configurable products"/>
|
17 | 17 | <severity value="BLOCKER"/>
|
18 | 18 | <testCaseId value="MAGETWO-95121"/>
|
| 19 | + <useCaseId value="MAGETWO-86098"/> |
19 | 20 | <group value="sales_rule"/>
|
20 | 21 | </annotations>
|
21 | 22 |
|
22 | 23 | <before>
|
23 |
| - <!--Login to Admin--> |
24 |
| - <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> |
25 |
| - <!-- Create the category --> |
26 |
| - <createData entity="ApiCategory" stepKey="createCategory"/> |
27 |
| - <!-- Create the configurable product and add it to the category --> |
28 |
| - <createData entity="ApiConfigurableProduct" stepKey="createConfigProduct"> |
29 |
| - <requiredEntity createDataKey="createCategory"/> |
30 |
| - </createData> |
| 24 | + <!-- Create the configurable product --> |
| 25 | + <createData entity="ApiConfigurableProductWithOutCategory" stepKey="createConfigProduct"/> |
31 | 26 | <!-- Create an attribute with two options to be used in the first child product -->
|
32 | 27 | <createData entity="productAttributeWithDropdownTwoOptions" stepKey="createConfigProductAttribute"/>
|
33 | 28 | <createData entity="productAttributeOption1" stepKey="createConfigProductAttributeOption1">
|
|
74 | 69 | <requiredEntity createDataKey="createConfigChildProduct2"/>
|
75 | 70 | </createData>
|
76 | 71 |
|
| 72 | + <!--Login to Admin--> |
| 73 | + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> |
| 74 | + |
| 75 | + <actionGroup ref="deleteAllCartPriceRule" stepKey="deleteAllCartPriceRules"/> |
| 76 | + |
| 77 | + <!--Create cart price rule--> |
| 78 | + <createData entity="SaleRule50PercentDiscountNoCoupon" stepKey="createCartPriceRule"> |
| 79 | + <field key="discount_amount">70</field> |
| 80 | + <field key="coupon_type">SPECIFIC_COUPON</field> |
| 81 | + </createData> |
| 82 | + <createData entity="SimpleSalesRuleCoupon" stepKey="createCouponForCartPriceRule"> |
| 83 | + <requiredEntity createDataKey="createCartPriceRule"/> |
| 84 | + </createData> |
| 85 | + |
77 | 86 | <!--Set attribute sku property Use for Promo Rule Conditions = Yes and save attribute-->
|
78 | 87 | <actionGroup ref="navigateToProductAttribute" stepKey="goToProductAttributeSkuPage">
|
79 | 88 | <argument name="attributeCode" value="sku"/>
|
80 | 89 | </actionGroup>
|
81 |
| - <click selector="{{AdminEditAttributeStorefrontPropertiesSection.storeFrontPropertiesTab}}" stepKey="clickStorefrontPropertiesTab"/> |
82 |
| - <scrollTo selector="{{AdminEditAttributeStorefrontPropertiesSection.storeFrontPropertiesTab}}" stepKey="scrollToUseForPromoRuleConditions"/> |
83 |
| - <selectOption selector="{{AdminEditAttributeStorefrontPropertiesSection.useForPromoRuleConditions}}" userInput="Yes" stepKey="changeAttributeProperty"/> |
84 |
| - <click selector="{{AdminMainActionsSection.save}}" stepKey="saveAttribute"/> |
85 |
| - <waitForPageLoad stepKey="waitForAttributeIsSaved"/> |
| 90 | + <actionGroup ref="changeUseForPromoRuleConditionsProductAttribute" stepKey="changeUseForPromoRuleConditions"/> |
86 | 91 |
|
87 |
| - <!-- Create cart price rule --> |
88 |
| - <amOnPage url="{{AdminCartPriceRulesPage.url}}" stepKey="amOnCartPriceList"/> |
89 |
| - <waitForPageLoad stepKey="waitForRulesPage"/> |
90 |
| - <click selector="{{AdminCartPriceRulesSection.addNewRuleButton}}" stepKey="clickAddNewRule"/> |
91 |
| - <fillField selector="{{AdminCartPriceRulesFormSection.ruleName}}" userInput="{{SalesRuleWithSkuInActions.name}}" stepKey="fillRuleName"/> |
92 |
| - <selectOption selector="{{AdminCartPriceRulesFormSection.websites}}" userInput="{{SalesRuleWithSkuInActions.websites}}" stepKey="selectWebsites"/> |
93 |
| - <actionGroup ref="selectNotLoggedInCustomerGroup" stepKey="selectNotLoggedInCustomerGroup"/> |
94 |
| - <selectOption selector="{{AdminCartPriceRulesFormSection.coupon}}" userInput="{{SalesRuleWithSkuInActions.coupon_type}}" stepKey="selectCouponType"/> |
95 |
| - <fillField selector="{{AdminCartPriceRulesFormSection.couponCode}}" userInput="{{SalesRuleWithSkuInActions.coupon_code}}" stepKey="fillCouponCOde"/> |
96 |
| - <click selector="{{AdminCartPriceRulesFormSection.actionsHeader}}" stepKey="clickToExpandActions"/> |
97 |
| - <fillField selector="{{AdminCartPriceRulesFormSection.discountAmount}}" userInput="{{SalesRuleWithSkuInActions.discount_amount}}" stepKey="fillDiscountAmount"/> |
98 |
| - <scrollTo selector="{{AdminCartPriceRulesFormSection.conditions}}" stepKey="scrollToApplyRuleForConditions"/> |
99 |
| - <click selector="{{AdminCartPriceRulesFormSection.conditions}}" stepKey="addConditionForRule"/> |
100 |
| - <waitForPageLoad stepKey="waitForDropDownOpened"/> |
101 |
| - <selectOption selector="{{AdminCartPriceRulesFormSection.childAttribute}}" userInput="SKU(Children Only)" stepKey="selectAttribute"/> |
102 |
| - <waitForPageLoad stepKey="waitForOperatorOpened"/> |
103 |
| - <click selector="{{AdminCartPriceRulesFormSection.condition('is')}}" stepKey="clickToChooseCondition"/> |
104 |
| - <selectOption selector="{{AdminCartPriceRulesFormSection.operator}}" userInput="is not one of" stepKey="selectOperator"/> |
105 |
| - <waitForPageLoad stepKey="waitForOperatorOpened1"/> |
106 |
| - <click selector="{{AdminCartPriceRulesFormSection.condition('...')}}" stepKey="clickToChooseOption"/> |
107 |
| - <waitForPageLoad stepKey="waitForConditionOpened2"/> |
108 |
| - <fillField selector="{{AdminCartPriceRulesFormSection.optionInput}}" userInput="$$createConfigChildProduct1.sku$$" stepKey="selectOption"/> |
109 |
| - <waitForPageLoad stepKey="waitForPageLoaded"/> |
110 |
| - <click selector="{{AdminCartPriceRulesFormSection.save}}" stepKey="clickSaveButton"/> |
111 |
| - <see selector="{{AdminCartPriceRulesSection.messages}}" userInput="You saved the rule." stepKey="seeSuccessMessage"/> |
| 92 | + <!-- Set condition for actions in cart price rule --> |
| 93 | + <amOnPage url="{{AdminCartPriceRuleEditPage.url($$createCartPriceRule.rule_id$$)}}" stepKey="goToCartPriceRuleEditPage"/> |
| 94 | + <actionGroup ref="SetConditionForActionsInCartPriceRuleActionGroup" stepKey="setConditionForActionsInCartPriceRule"> |
| 95 | + <argument name="actionsAggregator" value="ANY"/> |
| 96 | + <argument name="actionsValue" value="TRUE"/> |
| 97 | + <argument name="childAttribute" value="SKU(Children Only)"/> |
| 98 | + <argument name="actionOperator" value="is not one of"/> |
| 99 | + <argument name="actionValue" value="$$createConfigChildProduct1.sku$$"/> |
| 100 | + </actionGroup> |
112 | 101 | </before>
|
113 | 102 |
|
114 | 103 | <after>
|
115 |
| - <!--Remove SalesRule--> |
116 |
| - <actionGroup ref="DeleteCartPriceRuleByName" stepKey="deleteSalesRule"> |
117 |
| - <argument name="ruleName" value="{{SalesRuleWithSkuInActions.name}}"/> |
118 |
| - </actionGroup> |
119 |
| - <!--Return default value to attribute sku--> |
120 |
| - <actionGroup ref="navigateToProductAttribute" stepKey="goToProductAttributeSkuPage"> |
121 |
| - <argument name="attributeCode" value="sku"/> |
122 |
| - </actionGroup> |
123 |
| - <click selector="{{AdminEditAttributeStorefrontPropertiesSection.storeFrontPropertiesTab}}" stepKey="clickStorefrontPropertiesTab1"/> |
124 |
| - <scrollTo selector="{{AdminEditAttributeStorefrontPropertiesSection.storeFrontPropertiesTab}}" stepKey="scrollToUseForPromoRuleConditions"/> |
125 |
| - <selectOption selector="{{AdminEditAttributeStorefrontPropertiesSection.useForPromoRuleConditions}}" userInput="No" stepKey="changeAttributeProperty"/> |
126 |
| - <click selector="{{AdminMainActionsSection.save}}" stepKey="saveAttribute"/> |
127 |
| - <waitForPageLoad stepKey="waitForAttributeIsSaved"/> |
128 |
| - |
129 | 104 | <!--Remove configurable product and it's children-->
|
130 | 105 | <deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/>
|
131 | 106 | <deleteData createDataKey="createConfigChildProduct1" stepKey="deleteConfigChildProduct1"/>
|
132 | 107 | <deleteData createDataKey="createConfigChildProduct2" stepKey="deleteConfigChildProduct2"/>
|
133 | 108 | <deleteData createDataKey="createConfigProductAttribute" stepKey="deleteConfigProductAttribute"/>
|
134 |
| - <deleteData createDataKey="createCategory" stepKey="deleteApiCategory"/> |
| 109 | + <!--Remove SalesRule--> |
| 110 | + <deleteData createDataKey="createCartPriceRule" stepKey="deleteCartPriceRule"/> |
| 111 | + <!--Return default value to attribute sku--> |
| 112 | + <actionGroup ref="navigateToProductAttribute" stepKey="goToProductAttributeSkuPage"> |
| 113 | + <argument name="attributeCode" value="sku"/> |
| 114 | + </actionGroup> |
| 115 | + <actionGroup ref="changeUseForPromoRuleConditionsProductAttribute" stepKey="changeUseForPromoRuleConditions"> |
| 116 | + <argument name="useForPromoRule" value="No"/> |
| 117 | + </actionGroup> |
135 | 118 | <!--Logout from Admin-->
|
136 | 119 | <actionGroup ref="logout" stepKey="logout"/>
|
137 | 120 | </after>
|
138 | 121 |
|
139 |
| - <!--Add the configureble product with first option to the cart --> |
140 |
| - <amOnPage url="{{StorefrontProductPage.url($$createConfigProduct.sku$$)}}" stepKey="goToProductPage"/> |
141 |
| - <waitForPageLoad stepKey="waitForProductPageLoad"/> |
142 |
| - <selectOption selector="{{StorefrontProductInfoMainSection.productAttributeOptionsSelectButton}}" |
143 |
| - userInput="$$getConfigAttributeOption1.label$$" stepKey="selectOption1"/> |
144 |
| - <click selector="{{StorefrontProductActionSection.addToCart}}" stepKey="addProductToCart"/> |
145 |
| - <waitForPageLoad stepKey="waitForAddToCart"/> |
146 |
| - <!--Add the configureble product with second option to the cart --> |
147 |
| - <amOnPage url="{{StorefrontProductPage.url($$createConfigProduct.sku$$)}}" stepKey="goToProductPage1"/> |
148 |
| - <waitForPageLoad stepKey="waitForProductPageLoad1"/> |
149 |
| - <selectOption selector="{{StorefrontProductInfoMainSection.productAttributeOptionsSelectButton}}" |
150 |
| - userInput="$$getConfigAttributeOption2.label$$" stepKey="selectOption2"/> |
151 |
| - <click selector="{{StorefrontProductActionSection.addToCart}}" stepKey="addProductToCart1"/> |
152 |
| - <waitForPageLoad stepKey="waitForAddToCart1"/> |
| 122 | + <actionGroup ref="CustomerLogoutStorefrontActionGroup" stepKey="customerLogout"/> |
| 123 | + <!--Go to product page--> |
| 124 | + <amOnPage url="{{StorefrontProductPage.url($$createConfigProduct.custom_attributes[url_key]$$)}}" stepKey="goToProductPage"/> |
| 125 | + |
| 126 | + <!--Add the configurable product with first option to the cart --> |
| 127 | + <actionGroup ref="StorefrontSelectConfigurableAttributeOptionActionGroup" stepKey="selectFirstOptionOfConfigProduct"> |
| 128 | + <argument name="attributeLabel" value="$$createConfigProductAttribute.default_label$$"/> |
| 129 | + <argument name="optionValue" value="$$getConfigAttributeOption1.value$$"/> |
| 130 | + </actionGroup> |
| 131 | + <actionGroup ref="addToCartFromStorefrontProductPage" stepKey="addToCartFirstOptionOfConfigProduct"> |
| 132 | + <argument name="productName" value="$$createConfigProduct.name$$"/> |
| 133 | + </actionGroup> |
| 134 | + |
| 135 | + <!--Add the configurable product with second option to the cart --> |
| 136 | + <actionGroup ref="StorefrontSelectConfigurableAttributeOptionActionGroup" stepKey="selectSecondOptionOfConfigProduct"> |
| 137 | + <argument name="attributeLabel" value="$$createConfigProductAttribute.default_label$$"/> |
| 138 | + <argument name="optionValue" value="$$getConfigAttributeOption2.value$$"/> |
| 139 | + </actionGroup> |
| 140 | + <actionGroup ref="addToCartFromStorefrontProductPage" stepKey="addToCartSecondOptionOfConfigProduct"> |
| 141 | + <argument name="productName" value="$$createConfigProduct.name$$"/> |
| 142 | + </actionGroup> |
153 | 143 |
|
154 | 144 | <!--View and edit cart-->
|
155 |
| - <actionGroup ref="StorefrontOpenCartFromMinicartActionGroup" stepKey="storefrontOpenCartFromMinicart"/> |
156 |
| - <scrollTo selector="{{StorefrontDiscountSection.discountTab}}" stepKey="scrollToDiscountTab"/> |
157 |
| - <click selector="{{StorefrontDiscountSection.discountTab}}" stepKey="openDiscountTab" /> |
158 |
| - <fillField selector="{{StorefrontDiscountSection.couponInput}}" userInput="{{SalesRuleWithSkuInActions.coupon_code}}" stepKey="fillCouponCode" /> |
159 |
| - <click selector="{{StorefrontDiscountSection.applyCodeBtn}}" stepKey="applyCode"/> |
160 |
| - <waitForPageLoad stepKey="waitForPageLoaded1"/> |
161 |
| - <see userInput="You used coupon code" stepKey="assertText"/> |
| 145 | + <actionGroup ref="clickViewAndEditCartFromMiniCart" stepKey="storefrontOpenCartFromMinicart"/> |
| 146 | + |
| 147 | + <!-- Apply Cart Rule On Storefront --> |
| 148 | + <actionGroup ref="StorefrontApplyCouponActionGroup" stepKey="applyCartRule"> |
| 149 | + <argument name="couponCode" value="$$createCouponForCartPriceRule.code$$"/> |
| 150 | + </actionGroup> |
| 151 | + <waitForElementVisible selector="{{StorefrontCheckoutCartSummarySection.discountAmount}}" stepKey="waitForDiscountAmountVisible"/> |
| 152 | + |
162 | 153 | <!--Verify values-->
|
163 | 154 | <grabTextFrom selector="{{StorefrontCheckoutCartSummarySection.itemDiscount}}" stepKey="getDiscount"/>
|
164 | 155 | <grabTextFrom selector="{{StorefrontCheckoutCartSummarySection.subtotal}}" stepKey="getSubtotal"/>
|
165 |
| - <assertEquals stepKey="checkDescount"> |
| 156 | + <assertEquals stepKey="checkDiscount"> |
166 | 157 | <expectedResult type="string">-$7.00</expectedResult>
|
167 | 158 | <actualResult type="variable">$getDiscount</actualResult>
|
168 | 159 | </assertEquals>
|
|
0 commit comments