Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.

Commit 83af2be

Browse files
authored
Merge pull request #99 from magento-pangolin/MC-4431
2 parents 7cf16a1 + f8754c2 commit 83af2be

File tree

8 files changed

+283
-1
lines changed

8 files changed

+283
-1
lines changed

app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategoryProductSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
<element name="ProductTitleByName" type="button" selector="//main//li//a[contains(text(), '{{var1}}')]" parameterized="true"/>
2323
<element name="ProductPriceByName" type="text" selector="//main//li[.//a[contains(text(), '{{var1}}')]]//span[@class='price']" parameterized="true"/>
24+
<element name="ProductCatalogRuleSpecialPriceTitleByName" type="text" selector="//div[descendant::*[contains(text(), '{{var1}}')]]//*[contains(@class, 'special-price')]" parameterized="true"/>
25+
<element name="ProductCatalogRulePriceTitleByName" type="text" selector="//div[descendant::*[contains(text(), '{{var1}}')]]//*[contains(@class, 'price-label')]" parameterized="true"/>
2426
<element name="ProductImageByName" type="text" selector="//main//li[.//a[contains(text(), '{{var1}}')]]//img[@class='product-image-photo']" parameterized="true"/>
2527
<element name="ProductImageBySrc" type="text" selector=".products-grid img[src*='{{pattern}}']" parameterized="true"/>
2628
<element name="ProductInfoByName" type="text" selector="//main//li[.//a[contains(text(), '{{var1}}')]]//div[@class='product-item-info']" parameterized="true"/>

app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<arguments>
1414
<argument name="catalogRule" defaultValue="_defaultCatalogRule"/>
1515
</arguments>
16+
1617
<!-- Go to the admin Catalog rule grid and add a new one -->
1718
<amOnPage stepKey="goToPriceRulePage" url="{{CatalogRulePage.url}}"/>
1819
<waitForPageLoad stepKey="waitForPriceRulePage"/>
@@ -36,7 +37,6 @@
3637
<waitForPageLoad stepKey="waitForApplied"/>
3738
</actionGroup>
3839

39-
4040
<actionGroup name="createCatalogPriceRule">
4141
<arguments>
4242
<argument name="catalogRule" defaultValue="_defaultCatalogRule"/>
@@ -53,6 +53,26 @@
5353
<waitForPageLoad stepKey="waitForApplied"/>
5454
</actionGroup>
5555

56+
<actionGroup name="CreateCatalogPriceRuleViaTheUi">
57+
<arguments>
58+
<argument name="catalogRule" defaultValue="_defaultCatalogRule"/>
59+
<argument name="customerGroup" defaultValue="General" type="string"/>
60+
<argument name="disregardRules" defaultValue="Yes" type="string"/>
61+
</arguments>
62+
63+
<fillField selector="{{AdminNewCatalogPriceRule.ruleName}}" userInput="{{catalogRule.name}}" stepKey="fillName1"/>
64+
<fillField selector="{{AdminNewCatalogPriceRule.description}}" userInput="{{catalogRule.description}}" stepKey="fillDescription1"/>
65+
<selectOption selector="{{AdminNewCatalogPriceRule.websites}}" userInput="{{catalogRule.website_ids[0]}}" stepKey="selectWebSite1"/>
66+
<selectOption selector="{{AdminNewCatalogPriceRule.customerGroups}}" userInput="{{customerGroup}}" stepKey="selectCustomerGroup1"/>
67+
<scrollTo selector="{{AdminNewCatalogPriceRule.actionsTab}}" stepKey="scrollToActionTab1"/>
68+
<click selector="{{AdminNewCatalogPriceRule.actionsTab}}" stepKey="openActionDropdown1"/>
69+
<selectOption selector="{{AdminNewCatalogPriceRuleActions.apply}}" userInput="{{catalogRule.simple_action}}" stepKey="discountType1"/>
70+
<fillField selector="{{AdminNewCatalogPriceRuleActions.discountAmount}}" userInput="{{catalogRule.discount_amount}}" stepKey="fillDiscountValue1"/>
71+
<selectOption selector="{{AdminNewCatalogPriceRuleActions.disregardRules}}" userInput="{{disregardRules}}" stepKey="discardSubsequentRules1"/>
72+
<waitForPageLoad stepKey="waitForPageToLoad1"/>
73+
<scrollToTopOfPage stepKey="scrollToTop1"/>
74+
</actionGroup>
75+
5676
<actionGroup name="CreateCatalogPriceRuleConditionWithAttribute">
5777
<arguments>
5878
<argument name="attributeName" type="string"/>
@@ -70,6 +90,7 @@
7090
<click selector="{{AdminNewCatalogPriceRule.fromDateButton}}" stepKey="clickFromCalender"/>
7191
<click selector="{{AdminNewCatalogPriceRule.todayDate}}" stepKey="clickFromToday"/>
7292
</actionGroup>
93+
7394
<!-- Apply all of the saved catalog price rules -->
7495
<actionGroup name="applyCatalogPriceRules">
7596
<amOnPage stepKey="goToPriceRulePage" url="{{CatalogRulePage.url}}"/>

app/code/Magento/CatalogRule/Test/Mftf/Data/CatalogRuleData.xml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
<data key="simple_action">by_percent</data>
9595
<data key="discount_amount">10</data>
9696
</entity>
97+
9798
<entity name="InactiveCatalogRule" type="catalogRule">
9899
<data key="name" unique="suffix">InactiveCatalogRule</data>
99100
<data key="description">Inactive Catalog Price Rule Description</data>
@@ -121,4 +122,39 @@
121122
<data key="simple_action">by_percent</data>
122123
<data key="discount_amount">0</data>
123124
</entity>
125+
126+
<entity name="ActiveCatalogPriceRuleWithConditions" type="catalogRule">
127+
<data key="name" unique="suffix">Active Catalog Rule with conditions </data>
128+
<data key="description">Rule Description</data>
129+
<data key="is_active">1</data>
130+
<array key="customer_group_ids">
131+
<item>0</item>
132+
<item>1</item>
133+
<item>2</item>
134+
<item>3</item>
135+
</array>
136+
<array key="website_ids">
137+
<item>1</item>
138+
</array>
139+
<data key="simple_action">by_percent</data>
140+
<data key="discount_amount">10</data>
141+
</entity>
142+
143+
<!-- DO NOT USE IN OTHER TESTS AS IT WILL BREAK THE EXISTING TESTS -->
144+
<entity name="DeleteActiveCatalogPriceRuleWithConditions" type="catalogRule">
145+
<data key="name" unique="suffix">Delete Active Catalog Rule with conditions </data>
146+
<data key="description">Rule Description</data>
147+
<data key="is_active">1</data>
148+
<array key="customer_group_ids">
149+
<item>0</item>
150+
<item>1</item>
151+
<item>2</item>
152+
<item>3</item>
153+
</array>
154+
<array key="website_ids">
155+
<item>1</item>
156+
</array>
157+
<data key="simple_action">by_percent</data>
158+
<data key="discount_amount">10</data>
159+
</entity>
124160
</entities>
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
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="AdminDeleteCatalogPriceRuleEntityFromSimpleProductTest">
12+
<annotations>
13+
<stories value="Delete Catalog Price Rule"/>
14+
<title value="Delete Catalog Price Rule for Simple Product"/>
15+
<description value="Assert that Catalog Price Rule is not applied for simple product."/>
16+
<testCaseId value="MC-14073"/>
17+
<severity value="CRITICAL"/>
18+
<group value="CatalogRule"/>
19+
<group value="mtf_migrated"/>
20+
</annotations>
21+
22+
<before>
23+
<createData entity="Simple_US_Customer" stepKey="createCustomer1"/>
24+
<createData entity="_defaultCategory" stepKey="createCategory1"/>
25+
<createData entity="SimpleProduct" stepKey="createProduct1">
26+
<requiredEntity createDataKey="createCategory1"/>
27+
</createData>
28+
29+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/>
30+
31+
<amOnPage url="{{AdminNewCatalogPriceRulePage.url}}" stepKey="openNewCatalogPriceRulePage"/>
32+
<waitForPageLoad stepKey="waitForPageToLoad1"/>
33+
34+
<actionGroup ref="CreateCatalogPriceRuleViaTheUi" stepKey="createCatalogPriceRuleViaTheUi1">
35+
<argument name="catalogRule" value="DeleteActiveCatalogPriceRuleWithConditions"/>
36+
<argument name="customerGroup" value="General"/>
37+
<argument name="disregardRules" value="Yes"/>
38+
</actionGroup>
39+
40+
<click selector="{{AdminNewCatalogPriceRule.save}}" stepKey="saveTheCatalogRule"/>
41+
<waitForPageLoad stepKey="waitForPageToLoad3"/>
42+
<see selector="{{AdminNewCatalogPriceRule.successMessage}}" userInput="You saved the rule." stepKey="seeSuccessMessage"/>
43+
</before>
44+
<after>
45+
<actionGroup ref="logout" stepKey="logoutOfAdmin1"/>
46+
47+
<deleteData createDataKey="createCustomer1" stepKey="deleteCustomer1"/>
48+
<deleteData createDataKey="createProduct1" stepKey="deleteSimpleProduct1"/>
49+
<deleteData createDataKey="createCategory1" stepKey="deleteCategoryFirst1"/>
50+
</after>
51+
52+
<!-- Delete the simple product and catalog price rule -->
53+
<amOnPage url="{{CatalogRulePage.url}}" stepKey="goToPriceRulePage1"/>
54+
<waitForPageLoad stepKey="waitForPriceRulePage"/>
55+
<actionGroup ref="deleteEntitySecondaryGrid" stepKey="deletePriceRule1">
56+
<argument name="name" value="{{DeleteActiveCatalogPriceRuleWithConditions.name}}"/>
57+
<argument name="searchInput" value="{{AdminSecondaryGridSection.catalogRuleIdentifierSearch}}"/>
58+
</actionGroup>
59+
<waitForPageLoad time="30" stepKey="waitForPageLoad1"/>
60+
61+
<!-- Assert that the Success message is present after the delete -->
62+
<see selector="{{AdminMessagesSection.successMessage}}" userInput="You deleted the rule." stepKey="seeDeletedRuleMessage1"/>
63+
64+
<!-- Reindex -->
65+
<magentoCLI command="cache:flush" stepKey="flushCache1"/>
66+
<magentoCLI command="indexer:reindex" stepKey="reindex1"/>
67+
68+
<!-- Assert that the rule isn't present on the Category page -->
69+
<amOnPage url="$$createCategory1.name$$.html" stepKey="goToStorefrontCategoryPage1"/>
70+
<waitForPageLoad stepKey="waitForPageLoad3"/>
71+
<dontSee selector="{{StorefrontCategoryProductSection.ProductCatalogRulePriceTitleByName($$createProduct1.name$$)}}" userInput="Regular Price" stepKey="dontSeeRegularPriceText1"/>
72+
<dontSeeElement selector="{{StorefrontCategoryProductSection.ProductCatalogRuleSpecialPriceTitleByName($$createProduct1.name$$)}}" stepKey="dontSeeSpecialPrice1"/>
73+
74+
<!-- Assert that the rule isn't present on the Product page -->
75+
<amOnPage url="$$createProduct1.name$$.html" stepKey="goToStorefrontProductPage1"/>
76+
<waitForPageLoad stepKey="waitForPageLoad4"/>
77+
<dontSee selector="{{StorefrontProductInfoMainSection.oldPriceTag}}" userInput="Regular Price" stepKey="dontSeeRegularPRiceText2"/>
78+
<see selector="{{StorefrontProductInfoMainSection.productPrice}}" userInput="$$createProduct1.price$$" stepKey="seeTrueProductPrice1"/>
79+
80+
<!-- Assert that the rule isn't present in the Shopping Cart -->
81+
<actionGroup ref="addToCartFromStorefrontProductPage" stepKey="addProductToShoppingCart1">
82+
<argument name="productName" value="$$createProduct1.name$$"/>
83+
</actionGroup>
84+
<click selector="{{StorefrontMinicartSection.showCart}}" stepKey="openMiniShoppingCart1"/>
85+
<see selector="{{StorefrontMinicartSection.productPriceByName($$createProduct1.name$$)}}" userInput="$$createProduct1.price$$" stepKey="seeCorrectProductPrice1"/>
86+
87+
<!-- Assert that the rule isn't present on the Checkout page -->
88+
<click selector="{{StorefrontMiniCartSection.goToCheckout}}" stepKey="goToCheckout1"/>
89+
<conditionalClick selector="{{CheckoutCartSummarySection.expandShoppingCartSummary}}" dependentSelector="{{CheckoutCartSummarySection.expandShoppingCartSummary}}" visible="true" stepKey="expandShoppingCartSummary1"/>
90+
<see selector="{{CheckoutCartProductSection.ProductRegularPriceByName($$createProduct1.name$$)}}" userInput="$$createProduct1.price$$" stepKey="seeCorrectProductPriceOnCheckout1"/>
91+
</test>
92+
93+
<test name="AdminDeleteCatalogPriceRuleEntityFromConfigurableProductTest">
94+
<annotations>
95+
<stories value="Delete Catalog Price Rule"/>
96+
<title value="Delete Catalog Price Rule for Configurable Product"/>
97+
<description value="Assert that Catalog Price Rule is not applied for configurable product"/>
98+
<testCaseId value="MC-14074"/>
99+
<severity value="CRITICAL"/>
100+
<group value="CatalogRule"/>
101+
<group value="mtf_migrated"/>
102+
</annotations>
103+
104+
<before>
105+
<createData entity="Simple_US_Customer" stepKey="createCustomer1"/>
106+
<createData entity="SimpleSubCategory" stepKey="createCategory1"/>
107+
108+
<!-- Create the configurable product based on the data in the /data folder -->
109+
<createData entity="ApiConfigurableProduct" stepKey="createConfigProduct1">
110+
<requiredEntity createDataKey="createCategory1"/>
111+
</createData>
112+
113+
<!-- Make the configurable product have two options, that are children of the default attribute set -->
114+
<createData entity="productAttributeWithTwoOptions" stepKey="createConfigProductAttribute1"/>
115+
<createData entity="productAttributeOption1" stepKey="createConfigProductAttributeOption1">
116+
<requiredEntity createDataKey="createConfigProductAttribute1"/>
117+
</createData>
118+
<createData entity="productAttributeOption2" stepKey="createConfigProductAttributeOption2">
119+
<requiredEntity createDataKey="createConfigProductAttribute1"/>
120+
</createData>
121+
<createData entity="AddToDefaultSet" stepKey="createConfigAddToAttributeSet">
122+
<requiredEntity createDataKey="createConfigProductAttribute1"/>
123+
</createData>
124+
<getData entity="ProductAttributeOptionGetter" index="1" stepKey="getConfigAttributeOption1">
125+
<requiredEntity createDataKey="createConfigProductAttribute1"/>
126+
</getData>
127+
<getData entity="ProductAttributeOptionGetter" index="2" stepKey="getConfigAttributeOption2">
128+
<requiredEntity createDataKey="createConfigProductAttribute1"/>
129+
</getData>
130+
131+
<!-- Create the 2 children that will be a part of the configurable product -->
132+
<createData entity="ApiSimpleOne" stepKey="createConfigChildProduct1">
133+
<requiredEntity createDataKey="createConfigProductAttribute1"/>
134+
<requiredEntity createDataKey="getConfigAttributeOption1"/>
135+
</createData>
136+
<createData entity="ApiSimpleTwo" stepKey="createConfigChildProduct2">
137+
<requiredEntity createDataKey="createConfigProductAttribute1"/>
138+
<requiredEntity createDataKey="getConfigAttributeOption2"/>
139+
</createData>
140+
141+
<!-- Assign the two products to the configurable product -->
142+
<createData entity="ConfigurableProductTwoOptions" stepKey="createConfigProductOption1">
143+
<requiredEntity createDataKey="createConfigProduct1"/>
144+
<requiredEntity createDataKey="createConfigProductAttribute1"/>
145+
<requiredEntity createDataKey="getConfigAttributeOption1"/>
146+
<requiredEntity createDataKey="getConfigAttributeOption2"/>
147+
</createData>
148+
<createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddChild1">
149+
<requiredEntity createDataKey="createConfigProduct1"/>
150+
<requiredEntity createDataKey="createConfigChildProduct1"/>
151+
</createData>
152+
<createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddChild2">
153+
<requiredEntity createDataKey="createConfigProduct1"/>
154+
<requiredEntity createDataKey="createConfigChildProduct2"/>
155+
</createData>
156+
157+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/>
158+
159+
<amOnPage url="{{AdminNewCatalogPriceRulePage.url}}" stepKey="openNewCatalogPriceRulePage"/>
160+
<waitForPageLoad stepKey="waitForPageToLoad1"/>
161+
162+
<actionGroup ref="CreateCatalogPriceRuleViaTheUi" stepKey="createCatalogPriceRuleViaTheUi1">
163+
<argument name="catalogRule" value="DeleteActiveCatalogPriceRuleWithConditions"/>
164+
<argument name="customerGroup" value="General"/>
165+
<argument name="disregardRules" value="Yes"/>
166+
</actionGroup>
167+
168+
<click selector="{{AdminNewCatalogPriceRule.save}}" stepKey="saveTheCatalogRule"/>
169+
<waitForPageLoad stepKey="waitForPageToLoad3"/>
170+
<see selector="{{AdminNewCatalogPriceRule.successMessage}}" userInput="You saved the rule." stepKey="seeSuccessMessage"/>
171+
</before>
172+
<after>
173+
<actionGroup ref="logout" stepKey="logoutOfAdmin1"/>
174+
175+
<deleteData createDataKey="createCustomer1" stepKey="deleteCustomer"/>
176+
<deleteData createDataKey="createCategory1" stepKey="deleteCategory1"/>
177+
<deleteData createDataKey="createConfigProduct1" stepKey="deleteConfigProduct1"/>
178+
<deleteData createDataKey="createConfigChildProduct1" stepKey="deleteConfigChildProduct1"/>
179+
<deleteData createDataKey="createConfigChildProduct2" stepKey="deleteConfigChildProduct2"/>
180+
<deleteData createDataKey="createConfigProductAttribute1" stepKey="deleteConfigProductAttribute1"/>
181+
</after>
182+
183+
<!-- Delete the simple product and catalog price rule -->
184+
<amOnPage url="{{CatalogRulePage.url}}" stepKey="goToPriceRulePage1"/>
185+
<waitForPageLoad stepKey="waitForPriceRulePage"/>
186+
<actionGroup ref="deleteEntitySecondaryGrid" stepKey="deletePriceRule1">
187+
<argument name="name" value="{{DeleteActiveCatalogPriceRuleWithConditions.name}}"/>
188+
<argument name="searchInput" value="{{AdminSecondaryGridSection.catalogRuleIdentifierSearch}}"/>
189+
</actionGroup>
190+
<waitForPageLoad time="30" stepKey="waitForPageLoad1"/>
191+
<see selector="{{AdminMessagesSection.successMessage}}" userInput="You deleted the rule." stepKey="seeDeletedRuleMessage1"/>
192+
193+
<!-- Reindex -->
194+
<magentoCLI command="cache:flush" stepKey="flushCache1"/>
195+
<magentoCLI command="indexer:reindex" stepKey="reindex1"/>
196+
197+
<!-- Assert that the rule isn't present on the Category page -->
198+
<amOnPage url="$$createCategory1.name$$.html" stepKey="goToStorefrontCategoryPage1"/>
199+
<waitForPageLoad stepKey="waitForPageLoad2"/>
200+
<see selector="{{StorefrontCategoryProductSection.ProductPriceByName($$createConfigProduct1.name$$)}}" userInput="$$createConfigChildProduct1.price$$" stepKey="seeRegularPriceText1"/>
201+
202+
<!-- Assert that the rule isn't present on the Product page -->
203+
<amOnPage url="{{StorefrontProductPage.url($$createConfigProduct1.custom_attributes[url_key]$$)}}" stepKey="goToStorefrontProductPage1"/>
204+
<waitForPageLoad stepKey="waitForPageLoad3"/>
205+
<dontSee selector="{{StorefrontProductInfoMainSection.oldPriceTag}}" userInput="Regular Price" stepKey="dontSeeRegularPriceText2"/>
206+
<see selector="{{StorefrontProductInfoMainSection.productPrice}}" userInput="$$createConfigChildProduct1.price$$" stepKey="seeTrueProductPrice1"/>
207+
208+
<!-- Assert that the rule isn't present in the Shopping Cart -->
209+
<selectOption selector="{{StorefrontProductInfoMainSection.productAttributeOptionsSelectButton}}" userInput="option1" stepKey="selectOption1"/>
210+
<click selector="{{StorefrontProductActionSection.addToCart}}" stepKey="addToCart1"/>
211+
<waitForPageLoad time="30" stepKey="waitForPageLoad4"/>
212+
<see selector="{{StorefrontMessagesSection.success}}" userInput="You added $$createConfigProduct1.name$ to your shopping cart." stepKey="seeAddToCartSuccessMessage"/>
213+
<click selector="{{StorefrontMinicartSection.showCart}}" stepKey="openMiniShoppingCart1"/>
214+
<waitForPageLoad time="30" stepKey="waitForPageLoad5"/>
215+
<see selector="{{StorefrontMinicartSection.productPriceByName($$createConfigProduct1.name$$)}}" userInput="$$createConfigProduct1.price$$" stepKey="seeCorrectProductPrice1"/>
216+
</test>
217+
</tests>

0 commit comments

Comments
 (0)