|
| 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="AdminApplyCatalogPriceRuleByProductAttributeTest"> |
| 12 | + <annotations> |
| 13 | + <features value="CatalogRule"/> |
| 14 | + <stories value="Catalog price rule"/> |
| 15 | + <title value="Admin should be able to apply the catalog price rule by product attribute"/> |
| 16 | + <description value="Admin should be able to apply the catalog price rule by product attribute"/> |
| 17 | + <severity value="CRITICAL"/> |
| 18 | + <testCaseId value="MC-25351"/> |
| 19 | + <group value="catalogRule"/> |
| 20 | + </annotations> |
| 21 | + <before> |
| 22 | + <createData entity="productDropDownAttribute" stepKey="createDropdownAttribute"/> |
| 23 | + <!--Create attribute options--> |
| 24 | + <createData entity="ProductAttributeOption7" stepKey="createProductAttributeOptionGreen"> |
| 25 | + <requiredEntity createDataKey="createDropdownAttribute"/> |
| 26 | + </createData> |
| 27 | + <createData entity="ProductAttributeOption8" stepKey="createProductAttributeOptionRed"> |
| 28 | + <requiredEntity createDataKey="createDropdownAttribute"/> |
| 29 | + </createData> |
| 30 | + <!--Add attribute to default attribute set--> |
| 31 | + <createData entity="AddToDefaultSet" stepKey="addAttributeToDefaultSet"> |
| 32 | + <requiredEntity createDataKey="createDropdownAttribute"/> |
| 33 | + </createData> |
| 34 | + |
| 35 | + <createData entity="ApiCategory" stepKey="createCategory"/> |
| 36 | + <createData entity="ApiSimpleProduct" stepKey="createFirstProduct"> |
| 37 | + <field key="price">40.00</field> |
| 38 | + <requiredEntity createDataKey="createCategory"/> |
| 39 | + </createData> |
| 40 | + <createData entity="ApiSimpleProduct" stepKey="createSecondProduct"> |
| 41 | + <field key="price">40.00</field> |
| 42 | + <requiredEntity createDataKey="createCategory"/> |
| 43 | + </createData> |
| 44 | + |
| 45 | + <!-- Create the configurable product based on the data in the /data folder --> |
| 46 | + <createData entity="ApiConfigurableProduct" stepKey="createConfigProduct"> |
| 47 | + <requiredEntity createDataKey="createCategory"/> |
| 48 | + </createData> |
| 49 | + |
| 50 | + <!-- Make the configurable product have two options, that are children of the default attribute set --> |
| 51 | + <createData entity="productAttributeWithTwoOptionsNotVisible" stepKey="createConfigProductAttribute"/> |
| 52 | + <createData entity="productAttributeOption1" stepKey="createFirstConfigProductAttributeOption"> |
| 53 | + <requiredEntity createDataKey="createConfigProductAttribute"/> |
| 54 | + </createData> |
| 55 | + <createData entity="productAttributeOption2" stepKey="createSecondConfigProductAttributeOption"> |
| 56 | + <requiredEntity createDataKey="createConfigProductAttribute"/> |
| 57 | + </createData> |
| 58 | + <createData entity="AddToDefaultSet" stepKey="createConfigAddToAttributeSet"> |
| 59 | + <requiredEntity createDataKey="createConfigProductAttribute"/> |
| 60 | + </createData> |
| 61 | + <getData entity="ProductAttributeOptionGetter" index="1" stepKey="getFirstConfigAttributeOption"> |
| 62 | + <requiredEntity createDataKey="createConfigProductAttribute"/> |
| 63 | + </getData> |
| 64 | + <getData entity="ProductAttributeOptionGetter" index="2" stepKey="getSecondConfigAttributeOption"> |
| 65 | + <requiredEntity createDataKey="createConfigProductAttribute"/> |
| 66 | + </getData> |
| 67 | + |
| 68 | + <!-- Create the 2 children that will be a part of the configurable product --> |
| 69 | + <createData entity="ApiSimpleOne" stepKey="createConfigFirstChildProduct"> |
| 70 | + <field key="price">60.00</field> |
| 71 | + <requiredEntity createDataKey="createConfigProductAttribute"/> |
| 72 | + <requiredEntity createDataKey="getFirstConfigAttributeOption"/> |
| 73 | + </createData> |
| 74 | + <createData entity="ApiSimpleTwo" stepKey="createConfigSecondChildProduct"> |
| 75 | + <field key="price">60.00</field> |
| 76 | + <requiredEntity createDataKey="createConfigProductAttribute"/> |
| 77 | + <requiredEntity createDataKey="getSecondConfigAttributeOption"/> |
| 78 | + </createData> |
| 79 | + |
| 80 | + <!-- Assign the two products to the configurable product --> |
| 81 | + <createData entity="ConfigurableProductTwoOptions" stepKey="createConfigProductOption"> |
| 82 | + <requiredEntity createDataKey="createConfigProduct"/> |
| 83 | + <requiredEntity createDataKey="createConfigProductAttribute"/> |
| 84 | + <requiredEntity createDataKey="getFirstConfigAttributeOption"/> |
| 85 | + <requiredEntity createDataKey="getSecondConfigAttributeOption"/> |
| 86 | + </createData> |
| 87 | + <createData entity="ConfigurableProductAddChild" stepKey="createFirstConfigProductAddChild"> |
| 88 | + <requiredEntity createDataKey="createConfigProduct"/> |
| 89 | + <requiredEntity createDataKey="createConfigFirstChildProduct"/> |
| 90 | + </createData> |
| 91 | + <createData entity="ConfigurableProductAddChild" stepKey="createSecondConfigProductAddChild"> |
| 92 | + <requiredEntity createDataKey="createConfigProduct"/> |
| 93 | + <requiredEntity createDataKey="createConfigSecondChildProduct"/> |
| 94 | + </createData> |
| 95 | + |
| 96 | + <actionGroup ref="AdminLoginActionGroup" stepKey="loginToAdmin"/> |
| 97 | + <!-- Update first simple product --> |
| 98 | + <actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="openFirstSimpleProductForEdit"> |
| 99 | + <argument name="productId" value="$createFirstProduct.id$"/> |
| 100 | + </actionGroup> |
| 101 | + <selectOption selector="{{AdminProductFormSection.customSelectField($createDropdownAttribute.attribute[attribute_code]$)}}" |
| 102 | + userInput="$createProductAttributeOptionGreen.option[store_labels][0][label]$" stepKey="setAttributeValueForFirstSimple"/> |
| 103 | + <actionGroup ref="SaveProductFormActionGroup" stepKey="saveFirstSimpleProduct"/> |
| 104 | + <!-- Update second simple product --> |
| 105 | + <actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="openSecondSimpleProductForEdit"> |
| 106 | + <argument name="productId" value="$createSecondProduct.id$"/> |
| 107 | + </actionGroup> |
| 108 | + <selectOption selector="{{AdminProductFormSection.customSelectField($createDropdownAttribute.attribute[attribute_code]$)}}" |
| 109 | + userInput="$createProductAttributeOptionRed.option[store_labels][0][label]$" stepKey="setAttributeValueForSecondSimple"/> |
| 110 | + <actionGroup ref="SaveProductFormActionGroup" stepKey="saveSecondSimpleProduct"/> |
| 111 | + <!-- Update first child of configurable product --> |
| 112 | + <actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="openFirstChildProductForEdit"> |
| 113 | + <argument name="productId" value="$createConfigFirstChildProduct.id$"/> |
| 114 | + </actionGroup> |
| 115 | + <selectOption selector="{{AdminProductFormSection.customSelectField($createDropdownAttribute.attribute[attribute_code]$)}}" |
| 116 | + userInput="$createProductAttributeOptionGreen.option[store_labels][0][label]$" stepKey="setAttributeValueForFirstChildProduct"/> |
| 117 | + <actionGroup ref="SaveProductFormActionGroup" stepKey="saveFirstChildProduct"/> |
| 118 | + <!-- Update second child of configurable product --> |
| 119 | + <actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="openSecondChildProductForEdit"> |
| 120 | + <argument name="productId" value="$createConfigSecondChildProduct.id$"/> |
| 121 | + </actionGroup> |
| 122 | + <selectOption selector="{{AdminProductFormSection.customSelectField($createDropdownAttribute.attribute[attribute_code]$)}}" |
| 123 | + userInput="$createProductAttributeOptionGreen.option[store_labels][0][label]$" stepKey="setAttributeValueForSecondChildProduct"/> |
| 124 | + <actionGroup ref="SaveProductFormActionGroup" stepKey="saveSecondChildProduct"/> |
| 125 | + <actionGroup ref="AdminCatalogPriceRuleDeleteAllActionGroup" stepKey="deleteAllCatalogPriceRule"/> |
| 126 | + <magentoCron groups="index" stepKey="reindexInvalidatedIndices"/> |
| 127 | + </before> |
| 128 | + <after> |
| 129 | + <!-- Delete created data --> |
| 130 | + <deleteData createDataKey="createDropdownAttribute" stepKey="deleteDropdownAttribute"/> |
| 131 | + <deleteData createDataKey="createFirstProduct" stepKey="deleteFirstProduct"/> |
| 132 | + <deleteData createDataKey="createSecondProduct" stepKey="deleteSecondProduct"/> |
| 133 | + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> |
| 134 | + <deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/> |
| 135 | + <deleteData createDataKey="createConfigFirstChildProduct" stepKey="deleteConfigFirstChildProduct"/> |
| 136 | + <deleteData createDataKey="createConfigSecondChildProduct" stepKey="deleteConfigSecondChildProduct"/> |
| 137 | + <deleteData createDataKey="createConfigProductAttribute" stepKey="deleteConfigProductAttribute"/> |
| 138 | + <actionGroup ref="AdminCatalogPriceRuleDeleteAllActionGroup" stepKey="deleteAllCatalogPriceRule"/> |
| 139 | + <actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="resetCatalogRulesGridFilter"/> |
| 140 | + <actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/> |
| 141 | + <!-- Reindex invalidated indices after product attribute has been created/deleted --> |
| 142 | + <magentoCron groups="index" stepKey="reindexInvalidatedIndices"/> |
| 143 | + </after> |
| 144 | + <!-- Create Catalog Price Rule --> |
| 145 | + <actionGroup ref="AdminOpenNewCatalogPriceRuleFormPageActionGroup" stepKey="startCreatingFirstPriceRule"/> |
| 146 | + <actionGroup ref="AdminCatalogPriceRuleFillMainInfoActionGroup" stepKey="fillMainInfoForFirstPriceRule"> |
| 147 | + <argument name="groups" value="'NOT LOGGED IN'"/> |
| 148 | + </actionGroup> |
| 149 | + <actionGroup ref="AdminFillCatalogRuleConditionWithSelectAttributeActionGroup" stepKey="createCatalogPriceRule"> |
| 150 | + <argument name="condition" value="$createDropdownAttribute.default_frontend_label$"/> |
| 151 | + <argument name="conditionValue" value="$createProductAttributeOptionGreen.option[store_labels][0][label]$"/> |
| 152 | + </actionGroup> |
| 153 | + <actionGroup ref="AdminCatalogPriceRuleFillActionsActionGroup" stepKey="fillActionsForCatalogPriceRule"> |
| 154 | + <argument name="discountAmount" value="{{SimpleCatalogPriceRule.discount_amount}}"/> |
| 155 | + </actionGroup> |
| 156 | + <actionGroup ref="AdminCatalogPriceRuleSaveAndApplyActionGroup" stepKey="saveAndApplyCatalogPriceRule"/> |
| 157 | + <!-- Run cron --> |
| 158 | + <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> |
| 159 | + <argument name="indices" value="catalogrule_rule"/> |
| 160 | + </actionGroup> |
| 161 | + <!-- Open first simple product page on storefront --> |
| 162 | + <actionGroup ref="OpenStoreFrontProductPageActionGroup" stepKey="openFirstSimpleProductPage"> |
| 163 | + <argument name="productUrlKey" value="$createFirstProduct.custom_attributes[url_key]$"/> |
| 164 | + </actionGroup> |
| 165 | + <!-- Verify price for simple product with attribute option green=$20 --> |
| 166 | + <actionGroup ref="AssertStorefrontProductPricesActionGroup" stepKey="assertFirstSimpleProductPrices"> |
| 167 | + <argument name="productPrice" value="$createFirstProduct.price$"/> |
| 168 | + <argument name="productFinalPrice" value="$20.00"/> |
| 169 | + </actionGroup> |
| 170 | + |
| 171 | + <!-- Open the configurable product page on storefront --> |
| 172 | + <actionGroup ref="OpenStoreFrontProductPageActionGroup" stepKey="openConfigurableProductPage"> |
| 173 | + <argument name="productUrlKey" value="$createConfigProduct.custom_attributes[url_key]$"/> |
| 174 | + </actionGroup> |
| 175 | + <!-- Verify price for configurable product with attribute option green=$30 --> |
| 176 | + <selectOption selector="{{AdminCustomerActivitiesConfigureSection.addAttribute}}" userInput="option1" stepKey="selectFirstOptionOfConfigProduct"/> |
| 177 | + <actionGroup ref="AssertStorefrontProductPricesActionGroup" stepKey="assertConfigProductWithFirstOptionPrices"> |
| 178 | + <argument name="productPrice" value="$createConfigFirstChildProduct.price$"/> |
| 179 | + <argument name="productFinalPrice" value="$30.00"/> |
| 180 | + </actionGroup> |
| 181 | + <!-- Verify price for configurable product with attribute option green=$30 --> |
| 182 | + <selectOption selector="{{AdminCustomerActivitiesConfigureSection.addAttribute}}" userInput="option2" stepKey="selectSecondOptionOfConfigProduct"/> |
| 183 | + <actionGroup ref="AssertStorefrontProductPricesActionGroup" stepKey="assertConfigProductWithSecondOptionPrices"> |
| 184 | + <argument name="productPrice" value="$createConfigSecondChildProduct.price$"/> |
| 185 | + <argument name="productFinalPrice" value="$30.00"/> |
| 186 | + </actionGroup> |
| 187 | + |
| 188 | + <!-- Open the second simple product page on storefront --> |
| 189 | + <actionGroup ref="OpenStoreFrontProductPageActionGroup" stepKey="openSecondSimpleProductPage"> |
| 190 | + <argument name="productUrlKey" value="$createSecondProduct.custom_attributes[url_key]$"/> |
| 191 | + </actionGroup> |
| 192 | + <!-- Verify Price for second simple product with specialColor red=$40 --> |
| 193 | + <actionGroup ref="AssertStorefrontProductPricesActionGroup" stepKey="assertSecondSimpleProductPrices"> |
| 194 | + <argument name="productPrice" value="$createSecondProduct.price$"/> |
| 195 | + <argument name="productFinalPrice" value="$createSecondProduct.price$"/> |
| 196 | + </actionGroup> |
| 197 | + </test> |
| 198 | +</tests> |
0 commit comments