From 03187f859b4c2a98dcc0e7ecce93fe3e02c99c63 Mon Sep 17 00:00:00 2001 From: Mila Lesechko Date: Tue, 23 Jul 2019 16:32:15 -0500 Subject: [PATCH] MC-148: Admin should be able to apply the catalog price rule by product attribute --- .../Section/AdminSecondaryGridSection.xml | 1 + .../Test/Mftf/Data/ProductAttributeData.xml | 21 ++ .../AdminCreateProductAttributeSection.xml | 2 +- .../Test/Mftf/Data/CatalogRuleData.xml | 16 ++ ...CatalogPriceRuleByProductAttributeTest.xml | 259 ++++++++++++++++++ .../AdminCartPriceRulesFormSection.xml | 2 + 6 files changed, 300 insertions(+), 1 deletion(-) create mode 100644 app/code/Magento/CatalogRule/Test/Mftf/Test/ApplyCatalogPriceRuleByProductAttributeTest.xml diff --git a/app/code/Magento/Backend/Test/Mftf/Section/AdminSecondaryGridSection.xml b/app/code/Magento/Backend/Test/Mftf/Section/AdminSecondaryGridSection.xml index 9051eb747a7a6..c8eb9ca2151a1 100644 --- a/app/code/Magento/Backend/Test/Mftf/Section/AdminSecondaryGridSection.xml +++ b/app/code/Magento/Backend/Test/Mftf/Section/AdminSecondaryGridSection.xml @@ -14,6 +14,7 @@ + diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml index 02e5ae5ae36a5..193810e465cf0 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml @@ -343,4 +343,25 @@ true ProductAttributeFrontendLabel + + testattribute + select + Global + false + false + true + true + true + true + true + true + true + true + true + true + true + true + true + ProductAttributeFrontendLabel + diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml index 9b75f7e6908a2..105e0a8b97e24 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml @@ -24,7 +24,7 @@ - + diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Data/CatalogRuleData.xml b/app/code/Magento/CatalogRule/Test/Mftf/Data/CatalogRuleData.xml index 5c6ea970d3b7a..75a7484324576 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Data/CatalogRuleData.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Data/CatalogRuleData.xml @@ -157,4 +157,20 @@ by_percent 10 + + Catalog Price Rule1 + Description for Cart Price Rule + Yes + Main Website + NOT LOGGED IN + No Coupon + Percent of product price discount + 50 + 0 + 0 + 0 + For matching items only + Free Shipping in conditions + Free Shipping in conditions + diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/ApplyCatalogPriceRuleByProductAttributeTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/ApplyCatalogPriceRuleByProductAttributeTest.xml new file mode 100644 index 0000000000000..b7a231df5045d --- /dev/null +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/ApplyCatalogPriceRuleByProductAttributeTest.xml @@ -0,0 +1,259 @@ + + + + + + + + + <description value="Admin should be able to apply the catalog price rule by product attribute"/> + <severity value="CRITICAL"/> + <testCaseId value="MC-148"/> + <group value="CatalogRule"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="login"/> + + <createData entity="ApiCategory" stepKey="createFirstCategory"/> + <createData entity="ApiSimpleProduct" stepKey="createFirstProduct"> + <field key="price">40.00</field> + <requiredEntity createDataKey="createFirstCategory"/> + </createData> + <createData entity="ApiSimpleProduct" stepKey="createSecondProduct"> + <field key="price">40.00</field> + <requiredEntity createDataKey="createFirstCategory"/> + </createData> + + <!-- Create the configurable product based on the data in the /data folder --> + <createData entity="ApiConfigurableProduct" stepKey="createConfigProduct"> + <requiredEntity createDataKey="createFirstCategory"/> + </createData> + + <!-- Make the configurable product have two options, that are children of the default attribute set --> + <createData entity="productAttributeWithTwoOptionsNotVisible" stepKey="createConfigProductAttribute"/> + <createData entity="productAttributeOption1" stepKey="createConfigProductAttributeOption1"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </createData> + <createData entity="productAttributeOption2" stepKey="createConfigProductAttributeOption2"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </createData> + <createData entity="AddToDefaultSet" stepKey="createConfigAddToAttributeSet"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </createData> + <getData entity="ProductAttributeOptionGetter" index="1" stepKey="getConfigAttributeOption1"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </getData> + <getData entity="ProductAttributeOptionGetter" index="2" stepKey="getConfigAttributeOption2"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </getData> + + <!-- Create the 2 children that will be a part of the configurable product --> + <createData entity="ApiSimpleOne" stepKey="createConfigChildProduct1"> + <field key="price">60.00</field> + <requiredEntity createDataKey="createConfigProductAttribute"/> + <requiredEntity createDataKey="getConfigAttributeOption1"/> + </createData> + <createData entity="ApiSimpleTwo" stepKey="createConfigChildProduct2"> + <field key="price">60.00</field> + <requiredEntity createDataKey="createConfigProductAttribute"/> + <requiredEntity createDataKey="getConfigAttributeOption2"/> + </createData> + + <!-- Assign the two products to the configurable product --> + <createData entity="ConfigurableProductTwoOptions" stepKey="createConfigProductOption"> + <requiredEntity createDataKey="createConfigProduct"/> + <requiredEntity createDataKey="createConfigProductAttribute"/> + <requiredEntity createDataKey="getConfigAttributeOption1"/> + <requiredEntity createDataKey="getConfigAttributeOption2"/> + </createData> + <createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddChild1"> + <requiredEntity createDataKey="createConfigProduct"/> + <requiredEntity createDataKey="createConfigChildProduct1"/> + </createData> + <createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddChild2"> + <requiredEntity createDataKey="createConfigProduct"/> + <requiredEntity createDataKey="createConfigChildProduct2"/> + </createData> + + </before> + <after> + + <!--Delete created data--> + <deleteData createDataKey="createFirstProduct" stepKey="deleteFirstProduct"/> + <deleteData createDataKey="createSecondProduct" stepKey="deleteSecondProduct"/> + <deleteData createDataKey="createFirstCategory" stepKey="deleteFirstCategory"/> + + <deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/> + <deleteData createDataKey="createConfigChildProduct1" stepKey="deleteConfigChildProduct1"/> + <deleteData createDataKey="createConfigChildProduct2" stepKey="deleteConfigChildProduct2"/> + <deleteData createDataKey="createConfigProductAttribute" stepKey="deleteConfigProductAttribute"/> + + <amOnPage url="{{CatalogRulePage.url}}" stepKey="goToCatalogPriceRulePage"/> + <actionGroup ref="deleteEntitySecondaryGrid" stepKey="deletePriceRule"> + <argument name="name" value="{{SimpleCatalogPriceRule.name}}"/> + <argument name="searchInput" value="{{AdminSecondaryGridSection.catalogRuleIdentifierSearch}}"/> + </actionGroup> + <click stepKey="resetFilters" selector="{{AdminSecondaryGridSection.resetFilters}}"/> + + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!-- Add values to your attribute ( ex: red , green) --> + + <!-- Go to Stores > Product, click "Add New Attribute" --> + <actionGroup ref="AdminOpenProductAttributePageActionGroup" stepKey="openProductAttributePage"/> + <click selector="{{AdminProductAttributeGridSection.createNewAttributeBtn}}" stepKey="createNewAttribute"/> + <waitForPageLoad stepKey="waitForNewAttributeFormLoad"/> + + <!-- Create a new product attribute. Default label : specialColor + Catalog Input Type for Store Owner = Dropdown --> + <actionGroup ref="AdminFillProductAttributePropertiesActionGroup" stepKey="fillAttributeProperties"> + <argument name="attributeName" value="{{productAttributeDropdownTwoOptions.attribute_code}}"/> + <argument name="attributeType" value="{{productAttributeDropdownTwoOptions.frontend_input}}"/> + </actionGroup> + + <!-- Add values to your attribute ( ex: red , green) --> + <waitForElementVisible selector="{{AttributePropertiesSection.dropdownAddOptions}}" stepKey="waitForManageOptions"/> + <click selector="{{AttributePropertiesSection.dropdownAddOptions}}" stepKey="addOption"/> + <fillField selector="{{NewProduct.adminFieldRed}}" userInput="red" stepKey="fillFirstOption"/> + <click selector="{{AttributePropertiesSection.dropdownAddOptions}}" stepKey="addSecondOption"/> + <fillField selector="{{NewProduct.adminFieldBlue}}" userInput="green" stepKey="fillSecondOption"/> + + <click selector="{{AdvancedAttributePropertiesSection.AdvancedAttributePropertiesSectionToggle}}" stepKey="clickAdvancedAttributeProperties"/> + <selectOption userInput="{{productAttributeDropdownTwoOptions.scope}}" selector="{{AttributePropertiesSection.Scope}}" stepKey="selectGlobal"/> + + <!-- Click on "Storefront Properties" tab on left menu --> + <scrollToTopOfPage stepKey="scrollToTopOfPage"/> + <click selector="{{StorefrontPropertiesSection.StoreFrontPropertiesTab}}" stepKey="clickStorefrontPropertiesTab"/> + <waitForPageLoad stepKey="waitForPageLoad"/> + + <!-- Set the property "Use for Promo Rule Conditions" to Yes --> + <selectOption selector="{{StorefrontPropertiesSection.useForPromoRuleConditions}}" userInput="Yes" stepKey="selectYes"/> + + <!-- Save the attribute --> + <actionGroup ref="saveProductAttribute" stepKey="saveAttribute"/> + + <!-- Add this product attribute to Default attribute set --> + <actionGroup ref="AdminOpenAttributeSetGridPageActionGroup" stepKey="openAttributeSetPage"/> + <actionGroup ref="AdminOpenAttributeSetByNameActionGroup" stepKey="openDefaultAttributeSet"/> + + <actionGroup ref="AssignAttributeToGroup" stepKey="assignAttributeToGroup"> + <argument name="group" value="Product Details"/> + <argument name="attribute" value="{{productAttributeDropdownTwoOptions.attribute_code}}"/> + </actionGroup> + <actionGroup ref="SaveAttributeSet" stepKey="saveAttributeSet"/> + + <!-- First Simple Product: choose green as attribute value --> + <actionGroup ref="filterAndSelectProduct" stepKey="openFirstSimpleProduct"> + <argument name="productSku" value="$$createFirstProduct.sku$$"/> + </actionGroup> + + <selectOption userInput="green" selector="{{AdminProductFormSection.customSelectField(productAttributeDropdownTwoOptions.attribute_code)}}" stepKey="selectGreen"/> + <actionGroup ref="saveProductForm" stepKey="saveFirstProduct"/> + + <!-- Second Simple Product: choose red as attribute value --> + <actionGroup ref="filterAndSelectProduct" stepKey="openSecondSimpleProduct"> + <argument name="productSku" value="$$createSecondProduct.sku$$"/> + </actionGroup> + + <selectOption userInput="red" selector="{{AdminProductFormSection.customSelectField(productAttributeDropdownTwoOptions.attribute_code)}}" stepKey="selectRed"/> + <actionGroup ref="saveProductForm" stepKey="saveSecondProduct"/> + + <!-- Configurable child product1: choose green as attribute value --> + <actionGroup ref="filterAndSelectProduct" stepKey="openConfigChild1Product"> + <argument name="productSku" value="$$createConfigChildProduct1.sku$$"/> + </actionGroup> + + <selectOption userInput="green" selector="{{AdminProductFormSection.customSelectField(productAttributeDropdownTwoOptions.attribute_code)}}" stepKey="selectGreenAttr"/> + <actionGroup ref="saveProductForm" stepKey="saveConfigChild1Product"/> + + <!-- Configurable child product2: choose green as attribute value --> + <actionGroup ref="filterAndSelectProduct" stepKey="openConfigChild2Product"> + <argument name="productSku" value="$$createConfigChildProduct2.sku$$"/> + </actionGroup> + + <selectOption userInput="green" selector="{{AdminProductFormSection.customSelectField(productAttributeDropdownTwoOptions.attribute_code)}}" stepKey="selectGreenAttribute"/> + <actionGroup ref="saveProductForm" stepKey="saveConfigChild2Product"/> + + <!-- Navigate to Marketing - Promotions - Catalog Price Rules --> + <amOnPage url="{{AdminCatalogPriceRuleGridPage.url}}" stepKey="amOnCatalogPriceRule"/> + <waitForPageLoad stepKey="waitForCatalogRulePageLoad"/> + + <!-- Click 'Add New Rule' button --> + <click selector="{{AdminMainActionsSection.add}}" stepKey="clickAddNewRule"/> + <waitForPageLoad stepKey="waitForNewRuleFormLoading"/> + + <!-- Fill out required fields on Rule Information: + Rule Name: Catalog Price Rule1 + Status: Active + Websites: Main Website + Customer Groups: NOT LOGGED IN --> + <fillField userInput="{{SimpleCatalogPriceRule.name}}" selector="{{AdminCartPriceRulesFormSection.ruleName}}" stepKey="fillRuleName"/> + <selectOption userInput="{{SimpleCatalogPriceRule.websites}}" selector="{{AdminCartPriceRulesFormSection.websites}}" stepKey="selectWebsite"/> + <selectOption userInput="{{SimpleCatalogPriceRule.customerGroups}}" selector="{{AdminCartPriceRulesFormSection.customerGroups}}" stepKey="selectCustomerGroups"/> + + <!-- Go to Conditions tab and click '+' sign to specify a condition --> + <scrollTo selector="{{AdminCartPriceRulesFormSection.conditionsHeaderNew}}" y="-80" stepKey="scrollTo"/> + <conditionalClick selector="{{AdminCartPriceRulesFormSection.conditionsHeaderNew}}" dependentSelector="{{AdminCartPriceRulesFormSection.conditionsHeaderOpenNew}}" visible="false" stepKey="openConditionsTab"/> + <click selector="{{AdminCartPriceRulesFormSection.addCondition('1')}}" stepKey="clickAddCondition"/> + <waitForAjaxLoad stepKey="waitForLoadingSelector"/> + + <!-- Select earlier created product attribute in condition and set a value: specialcolor: green --> + <selectOption userInput="{{productAttributeDropdownTwoOptions.attribute_code}}" selector="{{AdminCartPriceRulesFormSection.ruleCondition('1')}}" stepKey="selectAttribute"/> + <waitForAjaxLoad stepKey="waitForLoading"/> + <click selector="{{AdminCartPriceRulesFormSection.ruleParameter('...')}}" stepKey="clickRuleParameter"/> + <waitForAjaxLoad stepKey="waitForLoadingRuleParameter"/> + <selectOption userInput="green" selector="{{AdminCartPriceRulesFormSection.ruleParameterInput('1--1')}}" stepKey="selectColor"/> + + <!-- On Actions tab set Discount Amount: + Apply: By Percentage of the Original Price + Discount Amount: 50--> + <scrollTo selector="{{AdminCartPriceRulesFormSection.actionsHeader}}" y="-80" stepKey="scrollToDiscountSection"/> + <conditionalClick selector="{{AdminCartPriceRulesFormSection.actionsHeader}}" dependentSelector="{{AdminCartPriceRulesFormSection.actionsHeaderOpen}}" visible="false" stepKey="openTab"/> + <selectOption userInput="by_percent" selector="{{AdminCartPriceRulesFormSection.apply}}" stepKey="applyActions"/> + <fillField userInput="50" selector="{{AdminCartPriceRulesFormSection.discountAmount}}" stepKey="fillDiscountAmount"/> + + + <!-- CE: Click 'Save and Apply' button --> + <click selector="{{AdminNewCatalogPriceRule.saveAndApply}}" stepKey="clickSave"/> + <see userInput="You saved the rule." selector="{{ContentManagementSection.StoreConfigurationPageSuccessMessage}}" stepKey="seeMessage"/> + <see userInput="Updated rules applied." selector="{{ContentManagementSection.StoreConfigurationPageSuccessMessage}}" stepKey="seeSuccessMessage"/> + + <!-- Run cron twice --> + <magentoCLI command="cron:run" stepKey="runCron1"/> + <magentoCLI command="cron:run" stepKey="runCron2"/> + + <!-- Go to Frontend and open the simple product --> + <amOnPage url="{{StorefrontProductPage.url($$createFirstProduct.sku$$)}}" stepKey="amOnSimpleProductPage"/> + <waitForPageLoad stepKey="waitForSimpleProductPageLoad"/> + + <!-- Verify Price for simple product with specialColor green=$20 --> + <see userInput="20.00" selector="{{StorefrontProductInfoMainSection.updatedPrice}}" stepKey="seePrice20"/> + + <!-- Go to Frontend and Open the Configurable product --> + <amOnPage url="{{StorefrontProductPage.url($$createConfigProduct.sku$$)}}" stepKey="amOnConfigProductPage"/> + <waitForPageLoad stepKey="waitForConfigProductPageLoad"/> + + <!-- Verify Price for configurable product with specialColor green=$30 --> + <selectOption userInput="option1" selector="{{AdminCustomerActivitiesConfigureSection.addAttribute}}" stepKey="selectOption1"/> + <waitForPageLoad stepKey="waitForOption1Load"/> + <see userInput="30.00" selector="{{StorefrontProductInfoMainSection.updatedPrice}}" stepKey="seePrice30"/> + + <selectOption userInput="option2" selector="{{AdminCustomerActivitiesConfigureSection.addAttribute}}" stepKey="selectOption2"/> + <waitForPageLoad stepKey="waitForOption2Load"/> + <see userInput="30.00" selector="{{StorefrontProductInfoMainSection.updatedPrice}}" stepKey="seeOption2Price30"/> + + <!-- Go to Frontend and open the second simple product --> + <amOnPage url="{{StorefrontProductPage.url($$createSecondProduct.sku$$)}}" stepKey="amOnSecondProductPage"/> + <waitForPageLoad stepKey="waitForSecondProductPageLoad"/> + + <!-- Verify Price for simple product with specialColor red=$40 --> + <see userInput="40.00" selector="{{StorefrontProductInfoMainSection.updatedPrice}}" stepKey="seePrice40"/> + </test> +</tests> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml b/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml index 2f6c3e0af4dfa..0755843861247 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml @@ -33,7 +33,9 @@ <!-- Conditions sub-form --> <element name="conditionsHeader" type="button" selector="div[data-index='conditions']" timeout="30"/> + <element name="conditionsHeaderNew" type="button" selector="div[data-index='block_promo_catalog_edit_tab_conditions'] " timeout="30"/> <element name="conditionsHeaderOpen" type="button" selector="div[data-index='conditions'] div[data-state-collapsible='open']" timeout="30"/> + <element name="conditionsHeaderOpenNew" type="button" selector="div[data-index='block_promo_catalog_edit_tab_conditions'] div[data-state-collapsible='open']" timeout="30"/> <element name="conditionsValue" type="input" selector=".rule-param-edit input"/> <element name="conditionsOperator" type="select" selector=".rule-param-edit select"/> <element name="addCondition" type="button" selector="//*[@id='conditions__{{arg}}__children']//span" parameterized="true"/>