Skip to content

Commit b9d09c6

Browse files
glo74186mohit-adobe
authored andcommitted
ACQE-7335 : Catalog rule should apply for product on multiple websites
created test file and some data
1 parent 08a83c0 commit b9d09c6

File tree

4 files changed

+156
-1
lines changed

4 files changed

+156
-1
lines changed

app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,5 +475,16 @@
475475
<data key="is_filterable_in_grid">true</data>
476476
<requiredEntity type="FrontendLabel">ProductAttributeFrontendLabel</requiredEntity>
477477
</entity>
478+
<entity name="productAttributeAgeGroupDropdown" type="ProductAttribute">
479+
<data key="default_frontend_label" unique="suffix">testattribute</data>
480+
<data key="attribute_code" unique="suffix">testattribute</data>
481+
<data key="frontend_input">select</data>
482+
<data key="scope">website</data>
483+
<data key="is_required">false</data>
484+
<data key="is_unique">false</data>
485+
<data key="is_searchable">false</data>
486+
<data key="is_used_for_promo_rules">true</data>
487+
<requiredEntity type="FrontendLabel">ProductAttributeFrontendLabel</requiredEntity>
488+
</entity>
478489
</entities>
479490

app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeOptionData.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,16 @@
125125
<data key="sort_order">3</data>
126126
<requiredEntity type="StoreLabel">Option14Store1</requiredEntity>
127127
</entity>
128+
<entity name="productAttributeOptionAdult" type="ProductAttributeOption">
129+
<var key="attribute_code" entityKey="attribute_code" entityType="ProductAttribute"/>
130+
<data key="label">Adult</data>
131+
<data key="is_default">false</data>
132+
<data key="sort_order">0</data>
133+
</entity>
134+
<entity name="productAttributeOptionChildren" type="ProductAttributeOption">
135+
<var key="attribute_code" entityKey="attribute_code" entityType="ProductAttribute"/>
136+
<data key="label">children</data>
137+
<data key="is_default">false</data>
138+
<data key="sort_order">0</data>
139+
</entity>
128140
</entities>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,6 @@
9191
<element name="customTextAttribute" type="input" selector="//input[@name='product[{{attribute_code}}]']" parameterized="true"/>
9292
<element name="customSelectAttribute" type="select" selector="//select[@name='product[{{attribute_code}}]']" parameterized="true"/>
9393
<element name="customSwitcherAttribute" type="checkbox" selector="//input[@name='product[{{attribute_code}}]' and @value='{{checked_value}}']/parent::div[@data-role='switcher']" parameterized="true"/>
94-
94+
<element name="attributeOptionUncheckDefaultValue" type="checkbox" selector="input[name='use_default[{{attribute_code}}]']" parameterized="true"/>
9595
</section>
9696
</sections>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright 2024 Adobe
5+
* All Rights Reserved.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="StorefrontCheckProductPricesAcrossWebsitesBasedOnCatalogPriceRuleTest">
11+
<annotations>
12+
<features value="CatalogRule"/>
13+
<stories value="Apply catalog price rule"/>
14+
<title value="Catalog rule should apply for product on multiple websites"/>
15+
<description value="Testcase verifies On storefront catalog price rule applied for product on multiple websites"/>
16+
<severity value="CRITICAL"/>
17+
<testCaseId value="AC-7409"/>
18+
</annotations>
19+
<before>
20+
<!-- Create Simple Product -->
21+
<createData entity="SimpleProduct" stepKey="createProduct">
22+
<field key="price">100.00</field>
23+
</createData>
24+
<!-- Login as Admin -->
25+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
26+
<!--Create custom website -->
27+
<actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="createCustomWebsite">
28+
<argument name="newWebsiteName" value="{{NewWebSiteData.name}}"/>
29+
<argument name="websiteCode" value="{{NewWebSiteData.code}}"/>
30+
</actionGroup>
31+
<!-- Create custom store-->
32+
<actionGroup ref="AdminCreateNewStoreGroupActionGroup" stepKey="createCustomStore">
33+
<argument name="website" value="{{NewWebSiteData.name}}"/>
34+
<argument name="storeGroupName" value="{{NewWebSiteData.name}}"/>
35+
<argument name="storeGroupCode" value="{{NewWebSiteData.code}}"/>
36+
</actionGroup>
37+
<!-- Create custom store view-->
38+
<actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createCustomStoreView">
39+
<argument name="StoreGroup" value="NewWebSiteData"/>
40+
<argument name="customStore" value="NewWebSiteData"/>
41+
</actionGroup>
42+
<!--Create dropdown product attribute-->
43+
<createData entity="productAttributeAgeGroupDropdown" stepKey="createDropdownAttribute"/>
44+
<!--Create attribute options-->
45+
<createData entity="productAttributeOptionAdult" stepKey="createFirstAttributeOption">
46+
<requiredEntity createDataKey="createDropdownAttribute"/>
47+
</createData>
48+
<createData entity="productAttributeOptionChildren" stepKey="createSecondAttributeOption">
49+
<requiredEntity createDataKey="createDropdownAttribute"/>
50+
</createData>
51+
<!--Add attribute to default attribute set-->
52+
<createData entity="AddToDefaultSet" stepKey="addAttributeToDefaultSet">
53+
<requiredEntity createDataKey="createDropdownAttribute"/>
54+
</createData>
55+
</before>
56+
<after>
57+
<!--set main website as default-->
58+
<actionGroup ref="AdminSetDefaultWebsiteActionGroup" stepKey="setMainWebsiteAsDefault">
59+
<argument name="websiteName" value="Main Website"/>
60+
</actionGroup>
61+
<!-- Delete product -->
62+
<deleteData createDataKey="createProduct" stepKey="deleteFirstProduct"/>
63+
<deleteData createDataKey="createDropdownAttribute" stepKey="deleteDropdownAttribute"/>
64+
<actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteCustomWebsite">
65+
<argument name="websiteName" value="{{NewWebSiteData.name}}"/>
66+
</actionGroup>
67+
<!-- Delete created price rules -->
68+
<actionGroup ref="RemoveCatalogPriceRuleActionGroup" stepKey="deleteCatalogPriceRule">
69+
<argument name="ruleName" value="{{_defaultCatalogRule.name}}"/>
70+
</actionGroup>
71+
<!-- Logout -->
72+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/>
73+
</after>
74+
<!--Assign product to custom website-->
75+
<actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="goToProductEditPage">
76+
<argument name="productId" value="$$createProduct.id$$"/>
77+
</actionGroup>
78+
<waitForPageLoad stepKey="waitForProductPageLoad"/>
79+
<actionGroup ref="SelectProductInWebsitesActionGroup" stepKey="selectWebsiteInProduct">
80+
<argument name="website" value="{{NewWebSiteData.name}}"/>
81+
</actionGroup>
82+
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct"/>
83+
<!--Switch scope to Default store view-->
84+
<actionGroup ref="SwitchToTheNewStoreViewActionGroup" stepKey="SwitchDefaultStoreView">
85+
<argument name="storeViewName" value="'Default Store View'"/>
86+
</actionGroup>
87+
<uncheckOption selector="{{AdminProductFormSection.attributeOptionUncheckDefaultValue('$$createDropdownAttribute.attribute_code$$')}}" stepKey="unCheckDefaultValueInDefaultStoreview"/>
88+
<selectOption selector="{{AdminProductFormSection.customSelectAttribute('$$createDropdownAttribute.attribute_code$$')}}" userInput="Adult" stepKey="selectValueForAttributeInDefaultStoreview"/>
89+
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProductInDefaultStoreView"/>
90+
<!--Switch scope to custom store view-->
91+
<actionGroup ref="SwitchToTheNewStoreViewActionGroup" stepKey="switchScopeToCustomStoreView">
92+
<argument name="storeViewName" value="{{NewWebSiteData.name}}"/>
93+
</actionGroup>
94+
<uncheckOption selector="{{AdminProductFormSection.attributeOptionUncheckDefaultValue('$$createDropdownAttribute.attribute_code$$')}}" stepKey="unCheckDefaultValueInCustomStoreview"/>
95+
<selectOption selector="{{AdminProductFormSection.customSelectAttribute('$$createDropdownAttribute.attribute_code$$')}}" userInput="children" stepKey="selectValueForAttributeInCustomStoreview"/>
96+
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProductInCustomStoreView"/>
97+
<!-- create catalog price with 50% discount and condition -->
98+
<actionGroup ref="AdminOpenNewCatalogPriceRuleFormPageActionGroup" stepKey="openNewCatalogPriceRulePage"/>
99+
<actionGroup ref="AdminCatalogPriceRuleFillMainInfoActionGroup" stepKey="fillMainInfoForSecondCatalogPriceRule">
100+
<argument name="websites" value="'Main Website',{{NewWebSiteData.name}}"/>
101+
</actionGroup>
102+
<actionGroup ref="AdminFillCatalogRuleConditionWithSelectAttributeActionGroup" stepKey="fillConditionsForCatalogPriceRule">
103+
<argument name="condition" value="$$createDropdownAttribute.default_frontend_label$$"/>
104+
<argument name="conditionValue" value="Adult"/>
105+
</actionGroup>
106+
<actionGroup ref="AdminCatalogPriceRuleFillActionsActionGroup" stepKey="fillActionsForCatalogPriceRule">
107+
<argument name="discountAmount" value="50"/>
108+
</actionGroup>
109+
<actionGroup ref="AdminCatalogPriceRuleSaveAndApplyActionGroup" stepKey="saveAndApplyCatalogPriceRule"/>
110+
<actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex">
111+
<argument name="indices" value=""/>
112+
</actionGroup>
113+
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanCache">
114+
<argument name="tags" value="config full_page"/>
115+
</actionGroup>
116+
<actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="goToProductOnStorefront">
117+
<argument name="product" value="$$createProduct$$"/>
118+
</actionGroup>
119+
<waitForText selector="{{StorefrontProductInfoMainSection.updatedPrice}}" userInput="$50.00" stepKey="assertProductPriceAmountOnMainWebsite"/>
120+
<actionGroup ref="AdminSetDefaultWebsiteActionGroup" stepKey="setSecondaryWebsiteAsDefault">
121+
<argument name="websiteName" value="{{NewWebSiteData.name}}"/>
122+
</actionGroup>
123+
<!-- Clean config and full page cache-->
124+
<actionGroup ref="CliCacheCleanActionGroup" stepKey="flushCache">
125+
<argument name="tags" value="config full_page"/>
126+
</actionGroup>
127+
<actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="openProductOnStorefront">
128+
<argument name="product" value="$$createProduct$$"/>
129+
</actionGroup>
130+
<waitForText selector="{{StorefrontProductInfoMainSection.updatedPrice}}" userInput="$100.00" stepKey="assertProductPriceAmountOnCustomWebsite"/>
131+
</test>
132+
</tests>

0 commit comments

Comments
 (0)