Skip to content

Commit

Permalink
Merge pull request magento#99 from magento-pangolin/MC-4431
Browse files Browse the repository at this point in the history
  • Loading branch information
tomreece authored May 2, 2019
2 parents 7cf16a1 + f8754c2 commit 83af2be
Show file tree
Hide file tree
Showing 8 changed files with 283 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

<element name="ProductTitleByName" type="button" selector="//main//li//a[contains(text(), '{{var1}}')]" parameterized="true"/>
<element name="ProductPriceByName" type="text" selector="//main//li[.//a[contains(text(), '{{var1}}')]]//span[@class='price']" parameterized="true"/>
<element name="ProductCatalogRuleSpecialPriceTitleByName" type="text" selector="//div[descendant::*[contains(text(), '{{var1}}')]]//*[contains(@class, 'special-price')]" parameterized="true"/>
<element name="ProductCatalogRulePriceTitleByName" type="text" selector="//div[descendant::*[contains(text(), '{{var1}}')]]//*[contains(@class, 'price-label')]" parameterized="true"/>
<element name="ProductImageByName" type="text" selector="//main//li[.//a[contains(text(), '{{var1}}')]]//img[@class='product-image-photo']" parameterized="true"/>
<element name="ProductImageBySrc" type="text" selector=".products-grid img[src*='{{pattern}}']" parameterized="true"/>
<element name="ProductInfoByName" type="text" selector="//main//li[.//a[contains(text(), '{{var1}}')]]//div[@class='product-item-info']" parameterized="true"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<arguments>
<argument name="catalogRule" defaultValue="_defaultCatalogRule"/>
</arguments>

<!-- Go to the admin Catalog rule grid and add a new one -->
<amOnPage stepKey="goToPriceRulePage" url="{{CatalogRulePage.url}}"/>
<waitForPageLoad stepKey="waitForPriceRulePage"/>
Expand All @@ -36,7 +37,6 @@
<waitForPageLoad stepKey="waitForApplied"/>
</actionGroup>


<actionGroup name="createCatalogPriceRule">
<arguments>
<argument name="catalogRule" defaultValue="_defaultCatalogRule"/>
Expand All @@ -53,6 +53,26 @@
<waitForPageLoad stepKey="waitForApplied"/>
</actionGroup>

<actionGroup name="CreateCatalogPriceRuleViaTheUi">
<arguments>
<argument name="catalogRule" defaultValue="_defaultCatalogRule"/>
<argument name="customerGroup" defaultValue="General" type="string"/>
<argument name="disregardRules" defaultValue="Yes" type="string"/>
</arguments>

<fillField selector="{{AdminNewCatalogPriceRule.ruleName}}" userInput="{{catalogRule.name}}" stepKey="fillName1"/>
<fillField selector="{{AdminNewCatalogPriceRule.description}}" userInput="{{catalogRule.description}}" stepKey="fillDescription1"/>
<selectOption selector="{{AdminNewCatalogPriceRule.websites}}" userInput="{{catalogRule.website_ids[0]}}" stepKey="selectWebSite1"/>
<selectOption selector="{{AdminNewCatalogPriceRule.customerGroups}}" userInput="{{customerGroup}}" stepKey="selectCustomerGroup1"/>
<scrollTo selector="{{AdminNewCatalogPriceRule.actionsTab}}" stepKey="scrollToActionTab1"/>
<click selector="{{AdminNewCatalogPriceRule.actionsTab}}" stepKey="openActionDropdown1"/>
<selectOption selector="{{AdminNewCatalogPriceRuleActions.apply}}" userInput="{{catalogRule.simple_action}}" stepKey="discountType1"/>
<fillField selector="{{AdminNewCatalogPriceRuleActions.discountAmount}}" userInput="{{catalogRule.discount_amount}}" stepKey="fillDiscountValue1"/>
<selectOption selector="{{AdminNewCatalogPriceRuleActions.disregardRules}}" userInput="{{disregardRules}}" stepKey="discardSubsequentRules1"/>
<waitForPageLoad stepKey="waitForPageToLoad1"/>
<scrollToTopOfPage stepKey="scrollToTop1"/>
</actionGroup>

<actionGroup name="CreateCatalogPriceRuleConditionWithAttribute">
<arguments>
<argument name="attributeName" type="string"/>
Expand All @@ -70,6 +90,7 @@
<click selector="{{AdminNewCatalogPriceRule.fromDateButton}}" stepKey="clickFromCalender"/>
<click selector="{{AdminNewCatalogPriceRule.todayDate}}" stepKey="clickFromToday"/>
</actionGroup>

<!-- Apply all of the saved catalog price rules -->
<actionGroup name="applyCatalogPriceRules">
<amOnPage stepKey="goToPriceRulePage" url="{{CatalogRulePage.url}}"/>
Expand Down
36 changes: 36 additions & 0 deletions app/code/Magento/CatalogRule/Test/Mftf/Data/CatalogRuleData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
<data key="simple_action">by_percent</data>
<data key="discount_amount">10</data>
</entity>

<entity name="InactiveCatalogRule" type="catalogRule">
<data key="name" unique="suffix">InactiveCatalogRule</data>
<data key="description">Inactive Catalog Price Rule Description</data>
Expand Down Expand Up @@ -121,4 +122,39 @@
<data key="simple_action">by_percent</data>
<data key="discount_amount">0</data>
</entity>

<entity name="ActiveCatalogPriceRuleWithConditions" type="catalogRule">
<data key="name" unique="suffix">Active Catalog Rule with conditions </data>
<data key="description">Rule Description</data>
<data key="is_active">1</data>
<array key="customer_group_ids">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
</array>
<array key="website_ids">
<item>1</item>
</array>
<data key="simple_action">by_percent</data>
<data key="discount_amount">10</data>
</entity>

<!-- DO NOT USE IN OTHER TESTS AS IT WILL BREAK THE EXISTING TESTS -->
<entity name="DeleteActiveCatalogPriceRuleWithConditions" type="catalogRule">
<data key="name" unique="suffix">Delete Active Catalog Rule with conditions </data>
<data key="description">Rule Description</data>
<data key="is_active">1</data>
<array key="customer_group_ids">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
</array>
<array key="website_ids">
<item>1</item>
</array>
<data key="simple_action">by_percent</data>
<data key="discount_amount">10</data>
</entity>
</entities>
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminDeleteCatalogPriceRuleEntityFromSimpleProductTest">
<annotations>
<stories value="Delete Catalog Price Rule"/>
<title value="Delete Catalog Price Rule for Simple Product"/>
<description value="Assert that Catalog Price Rule is not applied for simple product."/>
<testCaseId value="MC-14073"/>
<severity value="CRITICAL"/>
<group value="CatalogRule"/>
<group value="mtf_migrated"/>
</annotations>

<before>
<createData entity="Simple_US_Customer" stepKey="createCustomer1"/>
<createData entity="_defaultCategory" stepKey="createCategory1"/>
<createData entity="SimpleProduct" stepKey="createProduct1">
<requiredEntity createDataKey="createCategory1"/>
</createData>

<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/>

<amOnPage url="{{AdminNewCatalogPriceRulePage.url}}" stepKey="openNewCatalogPriceRulePage"/>
<waitForPageLoad stepKey="waitForPageToLoad1"/>

<actionGroup ref="CreateCatalogPriceRuleViaTheUi" stepKey="createCatalogPriceRuleViaTheUi1">
<argument name="catalogRule" value="DeleteActiveCatalogPriceRuleWithConditions"/>
<argument name="customerGroup" value="General"/>
<argument name="disregardRules" value="Yes"/>
</actionGroup>

<click selector="{{AdminNewCatalogPriceRule.save}}" stepKey="saveTheCatalogRule"/>
<waitForPageLoad stepKey="waitForPageToLoad3"/>
<see selector="{{AdminNewCatalogPriceRule.successMessage}}" userInput="You saved the rule." stepKey="seeSuccessMessage"/>
</before>
<after>
<actionGroup ref="logout" stepKey="logoutOfAdmin1"/>

<deleteData createDataKey="createCustomer1" stepKey="deleteCustomer1"/>
<deleteData createDataKey="createProduct1" stepKey="deleteSimpleProduct1"/>
<deleteData createDataKey="createCategory1" stepKey="deleteCategoryFirst1"/>
</after>

<!-- Delete the simple product and catalog price rule -->
<amOnPage url="{{CatalogRulePage.url}}" stepKey="goToPriceRulePage1"/>
<waitForPageLoad stepKey="waitForPriceRulePage"/>
<actionGroup ref="deleteEntitySecondaryGrid" stepKey="deletePriceRule1">
<argument name="name" value="{{DeleteActiveCatalogPriceRuleWithConditions.name}}"/>
<argument name="searchInput" value="{{AdminSecondaryGridSection.catalogRuleIdentifierSearch}}"/>
</actionGroup>
<waitForPageLoad time="30" stepKey="waitForPageLoad1"/>

<!-- Assert that the Success message is present after the delete -->
<see selector="{{AdminMessagesSection.successMessage}}" userInput="You deleted the rule." stepKey="seeDeletedRuleMessage1"/>

<!-- Reindex -->
<magentoCLI command="cache:flush" stepKey="flushCache1"/>
<magentoCLI command="indexer:reindex" stepKey="reindex1"/>

<!-- Assert that the rule isn't present on the Category page -->
<amOnPage url="$$createCategory1.name$$.html" stepKey="goToStorefrontCategoryPage1"/>
<waitForPageLoad stepKey="waitForPageLoad3"/>
<dontSee selector="{{StorefrontCategoryProductSection.ProductCatalogRulePriceTitleByName($$createProduct1.name$$)}}" userInput="Regular Price" stepKey="dontSeeRegularPriceText1"/>
<dontSeeElement selector="{{StorefrontCategoryProductSection.ProductCatalogRuleSpecialPriceTitleByName($$createProduct1.name$$)}}" stepKey="dontSeeSpecialPrice1"/>

<!-- Assert that the rule isn't present on the Product page -->
<amOnPage url="$$createProduct1.name$$.html" stepKey="goToStorefrontProductPage1"/>
<waitForPageLoad stepKey="waitForPageLoad4"/>
<dontSee selector="{{StorefrontProductInfoMainSection.oldPriceTag}}" userInput="Regular Price" stepKey="dontSeeRegularPRiceText2"/>
<see selector="{{StorefrontProductInfoMainSection.productPrice}}" userInput="$$createProduct1.price$$" stepKey="seeTrueProductPrice1"/>

<!-- Assert that the rule isn't present in the Shopping Cart -->
<actionGroup ref="addToCartFromStorefrontProductPage" stepKey="addProductToShoppingCart1">
<argument name="productName" value="$$createProduct1.name$$"/>
</actionGroup>
<click selector="{{StorefrontMinicartSection.showCart}}" stepKey="openMiniShoppingCart1"/>
<see selector="{{StorefrontMinicartSection.productPriceByName($$createProduct1.name$$)}}" userInput="$$createProduct1.price$$" stepKey="seeCorrectProductPrice1"/>

<!-- Assert that the rule isn't present on the Checkout page -->
<click selector="{{StorefrontMiniCartSection.goToCheckout}}" stepKey="goToCheckout1"/>
<conditionalClick selector="{{CheckoutCartSummarySection.expandShoppingCartSummary}}" dependentSelector="{{CheckoutCartSummarySection.expandShoppingCartSummary}}" visible="true" stepKey="expandShoppingCartSummary1"/>
<see selector="{{CheckoutCartProductSection.ProductRegularPriceByName($$createProduct1.name$$)}}" userInput="$$createProduct1.price$$" stepKey="seeCorrectProductPriceOnCheckout1"/>
</test>

<test name="AdminDeleteCatalogPriceRuleEntityFromConfigurableProductTest">
<annotations>
<stories value="Delete Catalog Price Rule"/>
<title value="Delete Catalog Price Rule for Configurable Product"/>
<description value="Assert that Catalog Price Rule is not applied for configurable product"/>
<testCaseId value="MC-14074"/>
<severity value="CRITICAL"/>
<group value="CatalogRule"/>
<group value="mtf_migrated"/>
</annotations>

<before>
<createData entity="Simple_US_Customer" stepKey="createCustomer1"/>
<createData entity="SimpleSubCategory" stepKey="createCategory1"/>

<!-- Create the configurable product based on the data in the /data folder -->
<createData entity="ApiConfigurableProduct" stepKey="createConfigProduct1">
<requiredEntity createDataKey="createCategory1"/>
</createData>

<!-- Make the configurable product have two options, that are children of the default attribute set -->
<createData entity="productAttributeWithTwoOptions" stepKey="createConfigProductAttribute1"/>
<createData entity="productAttributeOption1" stepKey="createConfigProductAttributeOption1">
<requiredEntity createDataKey="createConfigProductAttribute1"/>
</createData>
<createData entity="productAttributeOption2" stepKey="createConfigProductAttributeOption2">
<requiredEntity createDataKey="createConfigProductAttribute1"/>
</createData>
<createData entity="AddToDefaultSet" stepKey="createConfigAddToAttributeSet">
<requiredEntity createDataKey="createConfigProductAttribute1"/>
</createData>
<getData entity="ProductAttributeOptionGetter" index="1" stepKey="getConfigAttributeOption1">
<requiredEntity createDataKey="createConfigProductAttribute1"/>
</getData>
<getData entity="ProductAttributeOptionGetter" index="2" stepKey="getConfigAttributeOption2">
<requiredEntity createDataKey="createConfigProductAttribute1"/>
</getData>

<!-- Create the 2 children that will be a part of the configurable product -->
<createData entity="ApiSimpleOne" stepKey="createConfigChildProduct1">
<requiredEntity createDataKey="createConfigProductAttribute1"/>
<requiredEntity createDataKey="getConfigAttributeOption1"/>
</createData>
<createData entity="ApiSimpleTwo" stepKey="createConfigChildProduct2">
<requiredEntity createDataKey="createConfigProductAttribute1"/>
<requiredEntity createDataKey="getConfigAttributeOption2"/>
</createData>

<!-- Assign the two products to the configurable product -->
<createData entity="ConfigurableProductTwoOptions" stepKey="createConfigProductOption1">
<requiredEntity createDataKey="createConfigProduct1"/>
<requiredEntity createDataKey="createConfigProductAttribute1"/>
<requiredEntity createDataKey="getConfigAttributeOption1"/>
<requiredEntity createDataKey="getConfigAttributeOption2"/>
</createData>
<createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddChild1">
<requiredEntity createDataKey="createConfigProduct1"/>
<requiredEntity createDataKey="createConfigChildProduct1"/>
</createData>
<createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddChild2">
<requiredEntity createDataKey="createConfigProduct1"/>
<requiredEntity createDataKey="createConfigChildProduct2"/>
</createData>

<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/>

<amOnPage url="{{AdminNewCatalogPriceRulePage.url}}" stepKey="openNewCatalogPriceRulePage"/>
<waitForPageLoad stepKey="waitForPageToLoad1"/>

<actionGroup ref="CreateCatalogPriceRuleViaTheUi" stepKey="createCatalogPriceRuleViaTheUi1">
<argument name="catalogRule" value="DeleteActiveCatalogPriceRuleWithConditions"/>
<argument name="customerGroup" value="General"/>
<argument name="disregardRules" value="Yes"/>
</actionGroup>

<click selector="{{AdminNewCatalogPriceRule.save}}" stepKey="saveTheCatalogRule"/>
<waitForPageLoad stepKey="waitForPageToLoad3"/>
<see selector="{{AdminNewCatalogPriceRule.successMessage}}" userInput="You saved the rule." stepKey="seeSuccessMessage"/>
</before>
<after>
<actionGroup ref="logout" stepKey="logoutOfAdmin1"/>

<deleteData createDataKey="createCustomer1" stepKey="deleteCustomer"/>
<deleteData createDataKey="createCategory1" stepKey="deleteCategory1"/>
<deleteData createDataKey="createConfigProduct1" stepKey="deleteConfigProduct1"/>
<deleteData createDataKey="createConfigChildProduct1" stepKey="deleteConfigChildProduct1"/>
<deleteData createDataKey="createConfigChildProduct2" stepKey="deleteConfigChildProduct2"/>
<deleteData createDataKey="createConfigProductAttribute1" stepKey="deleteConfigProductAttribute1"/>
</after>

<!-- Delete the simple product and catalog price rule -->
<amOnPage url="{{CatalogRulePage.url}}" stepKey="goToPriceRulePage1"/>
<waitForPageLoad stepKey="waitForPriceRulePage"/>
<actionGroup ref="deleteEntitySecondaryGrid" stepKey="deletePriceRule1">
<argument name="name" value="{{DeleteActiveCatalogPriceRuleWithConditions.name}}"/>
<argument name="searchInput" value="{{AdminSecondaryGridSection.catalogRuleIdentifierSearch}}"/>
</actionGroup>
<waitForPageLoad time="30" stepKey="waitForPageLoad1"/>
<see selector="{{AdminMessagesSection.successMessage}}" userInput="You deleted the rule." stepKey="seeDeletedRuleMessage1"/>

<!-- Reindex -->
<magentoCLI command="cache:flush" stepKey="flushCache1"/>
<magentoCLI command="indexer:reindex" stepKey="reindex1"/>

<!-- Assert that the rule isn't present on the Category page -->
<amOnPage url="$$createCategory1.name$$.html" stepKey="goToStorefrontCategoryPage1"/>
<waitForPageLoad stepKey="waitForPageLoad2"/>
<see selector="{{StorefrontCategoryProductSection.ProductPriceByName($$createConfigProduct1.name$$)}}" userInput="$$createConfigChildProduct1.price$$" stepKey="seeRegularPriceText1"/>

<!-- Assert that the rule isn't present on the Product page -->
<amOnPage url="{{StorefrontProductPage.url($$createConfigProduct1.custom_attributes[url_key]$$)}}" stepKey="goToStorefrontProductPage1"/>
<waitForPageLoad stepKey="waitForPageLoad3"/>
<dontSee selector="{{StorefrontProductInfoMainSection.oldPriceTag}}" userInput="Regular Price" stepKey="dontSeeRegularPriceText2"/>
<see selector="{{StorefrontProductInfoMainSection.productPrice}}" userInput="$$createConfigChildProduct1.price$$" stepKey="seeTrueProductPrice1"/>

<!-- Assert that the rule isn't present in the Shopping Cart -->
<selectOption selector="{{StorefrontProductInfoMainSection.productAttributeOptionsSelectButton}}" userInput="option1" stepKey="selectOption1"/>
<click selector="{{StorefrontProductActionSection.addToCart}}" stepKey="addToCart1"/>
<waitForPageLoad time="30" stepKey="waitForPageLoad4"/>
<see selector="{{StorefrontMessagesSection.success}}" userInput="You added $$createConfigProduct1.name$ to your shopping cart." stepKey="seeAddToCartSuccessMessage"/>
<click selector="{{StorefrontMinicartSection.showCart}}" stepKey="openMiniShoppingCart1"/>
<waitForPageLoad time="30" stepKey="waitForPageLoad5"/>
<see selector="{{StorefrontMinicartSection.productPriceByName($$createConfigProduct1.name$$)}}" userInput="$$createConfigProduct1.price$$" stepKey="seeCorrectProductPrice1"/>
</test>
</tests>
Loading

0 comments on commit 83af2be

Please sign in to comment.