Skip to content

Commit 71c2d12

Browse files
committed
MC-8724: Verify Category Product and Product Category partial reindex
1 parent 3a5185a commit 71c2d12

File tree

3 files changed

+234
-0
lines changed

3 files changed

+234
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,7 @@
4747
<data key="name" unique="suffix">Bags</data>
4848
<data key="url_key" unique="suffix">bags</data>
4949
</entity>
50+
<entity name="SubCategoryNonAnchor" extends="SubCategoryWithParent">
51+
<requiredEntity type="custom_attribute">CustomAttributeCategoryIsAnchor</requiredEntity>
52+
</entity>
5053
</entities>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,8 @@
3636
<data key="attribute_code">news_from_date</data>
3737
<data key="value">2018-05-17 00:00:00</data>
3838
</entity>
39+
<entity name="CustomAttributeCategoryIsAnchor" type="custom_attribute">
40+
<data key="attribute_code">is_anchor</data>
41+
<data key="value">0</data>
42+
</entity>
3943
</entities>
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
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="VerifyCategoryProductAndProductCategoryPartialReindexTest">
12+
<annotations>
13+
<features value="Catalog"/>
14+
<stories value="Product Categories Indexer"/>
15+
<title value="Verify Category Product and Product Category partial reindex"/>
16+
<description value="Verify that Merchant Developer can use console commands to perform partial reindex for Category Products, Product Categories, and Catalog Search"/>
17+
<severity value="CRITICAL"/>
18+
<testCaseId value="MC-8724"/>
19+
<group value="catalog"/>
20+
<group value="indexer"/>
21+
</annotations>
22+
<before>
23+
<!-- Change "Category Products" and "Product Categories" indexers to "Update by Schedule" mode -->
24+
<magentoCLI command="indexer:set-mode" arguments="schedule catalog_category_product catalog_product_category" stepKey="setIndexerMode"/>
25+
26+
<!-- Create categories K, L, M, N with different nesting in the tree and Anchor = Yes/No-->
27+
<!-- Category K is an anchor category -->
28+
<createData entity="_defaultCategory" stepKey="categoryK"/>
29+
<!-- Category L is a non-anchor subcategory of category K -->
30+
<createData entity="SubCategoryNonAnchor" stepKey="categoryL">
31+
<requiredEntity createDataKey="categoryK"/>
32+
</createData>
33+
<!-- Category M is a subcategory of category L -->
34+
<createData entity="SubCategoryWithParent" stepKey="categoryM">
35+
<requiredEntity createDataKey="categoryL"/>
36+
</createData>
37+
<!-- Category N is a subcategory of category K -->
38+
<createData entity="SubCategoryWithParent" stepKey="categoryN">
39+
<requiredEntity createDataKey="categoryK"/>
40+
</createData>
41+
42+
<!-- Create different Products with different settings, assign to categories: -->
43+
<!-- Product A in 0 categories, i.e. not assigned to any category -->
44+
<createData entity="SimpleProduct3" stepKey="productA"/>
45+
<!-- Product B in 1 category M -->
46+
<createData entity="SimpleProduct2" stepKey="productB">
47+
<requiredEntity createDataKey="categoryM"/>
48+
</createData>
49+
<!-- Product C in 2 categories M and N -->
50+
<createData entity="SimpleProduct3" stepKey="productC"/>
51+
52+
<actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/>
53+
54+
<actionGroup ref="AdminAssignProductToCategory" stepKey="assignCategoryNAndMToProductC">
55+
<argument name="productId" value="$$productC.id$$"/>
56+
<argument name="categoryName" value="$$categoryN.name$$, $$categoryM.name$$"/>
57+
</actionGroup>
58+
59+
<magentoCLI command="indexer:reindex" stepKey="reindex"/>
60+
</before>
61+
<after>
62+
<!-- Change "Category Products" and "Product Categories" indexers to "Update on Save" mode -->
63+
<magentoCLI command="indexer:set-mode" arguments="realtime" stepKey="setRealtimeMode"/>
64+
<magentoCLI command="indexer:reindex" stepKey="reindex"/>
65+
66+
<!-- Delete data -->
67+
<deleteData createDataKey="productA" stepKey="deleteProductA"/>
68+
<deleteData createDataKey="productB" stepKey="deleteProductB"/>
69+
<deleteData createDataKey="productC" stepKey="deleteProductC"/>
70+
<deleteData createDataKey="categoryN" stepKey="deleteCategoryN"/>
71+
<deleteData createDataKey="categoryM" stepKey="deleteCategoryM"/>
72+
<deleteData createDataKey="categoryL" stepKey="deleteCategoryL"/>
73+
<deleteData createDataKey="categoryK" stepKey="deleteCategoryK"/>
74+
75+
<actionGroup ref="logout" stepKey="logout"/>
76+
</after>
77+
78+
<!-- Open categories K, L, M, N on Storefront -->
79+
<!-- Category K contains only Products B & C -->
80+
<amOnPage url="{{StorefrontCategoryPage.url($$categoryK.custom_attributes[url_key]$$)}}" stepKey="onCategoryK"/>
81+
<see userInput="$$productB.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="seeProductBOnCategoryK"/>
82+
<see userInput="$$productC.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="seeProductCOnCategoryK"/>
83+
84+
<!-- Category L contains no Products -->
85+
<amOnPage url="{{StorefrontCategoryPage.url($$categoryK.custom_attributes[url_key]$$/$$categoryL.custom_attributes[url_key]$$)}}" stepKey="onCategoryL"/>
86+
<see userInput="We can't find products matching the selection." selector="{{StorefrontCategoryMainSection.categoryEmptyMessage}}" stepKey="seeMessage"/>
87+
<dontSeeElement selector="{{StorefrontCategoryMainSection.productName}}" stepKey="dontseeProducts"/>
88+
89+
<!-- Category M contains only Products B & C -->
90+
<amOnPage url="{{StorefrontCategoryPage.url($$categoryK.custom_attributes[url_key]$$/$$categoryL.custom_attributes[url_key]$$/$$categoryM.custom_attributes[url_key]$$)}}" stepKey="onCategoryM"/>
91+
<see userInput="$$productB.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="seeProductBOnCategoryM"/>
92+
<see userInput="$$productC.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="seeProductCOnCategoryM"/>
93+
94+
<!-- Category N contains only Product C -->
95+
<amOnPage url="{{StorefrontCategoryPage.url($$categoryK.custom_attributes[url_key]$$/$$categoryN.custom_attributes[url_key]$$)}}" stepKey="onCategoryN"/>
96+
<see userInput="$$productC.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="seeProductCOnCategoryN"/>
97+
98+
<!-- Open Products A, B, C to edit. Assign/unassign categories to/from them. Save changes -->
99+
<!-- Assign category K to Product A -->
100+
<actionGroup ref="AdminAssignProductToCategory" stepKey="assignCategoryK">
101+
<argument name="productId" value="$$productA.id$$"/>
102+
<argument name="categoryName" value="$$categoryK.name$$"/>
103+
</actionGroup>
104+
105+
<!-- Unassign category M from Product B -->
106+
<amOnPage url="{{AdminProductEditPage.url($$productB.id$$)}}" stepKey="amOnEditCategoryPageB"/>
107+
<actionGroup ref="AdminUnassignCategoryOnProductAndSaveActionGroup" stepKey="unassignCategoryM">
108+
<argument name="categoryName" value="$$categoryM.name$$"/>
109+
</actionGroup>
110+
111+
<!-- Assign category L to Product C -->
112+
<actionGroup ref="AdminAssignProductToCategory" stepKey="assignCategoryNAndM">
113+
<argument name="productId" value="$$productC.id$$"/>
114+
<argument name="categoryName" value="$$categoryL.name$$"/>
115+
</actionGroup>
116+
117+
<!-- "One or more indexers are invalid. Make sure your Magento cron job is running." global warning message appears -->
118+
<click selector="{{AdminSystemMessagesSection.systemMessagesDropdown}}" stepKey="openMessageSection"/>
119+
<see userInput="One or more indexers are invalid. Make sure your Magento cron job is running." selector="{{AdminMessagesSection.warningMessage}}" stepKey="seeWarningMessage"/>
120+
121+
<!-- Open categories K, L, M, N on Storefront in order to make sure that new assigments are not applied yet -->
122+
<!-- Category K contains only Products B & C -->
123+
<amOnPage url="{{StorefrontCategoryPage.url($$categoryK.custom_attributes[url_key]$$)}}" stepKey="amOnCategoryK"/>
124+
<see userInput="$$productB.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="seeProductBCategoryK"/>
125+
<see userInput="$$productC.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="seeProductCCategoryK"/>
126+
127+
<!-- Category L contains no Products -->
128+
<amOnPage url="{{StorefrontCategoryPage.url($$categoryK.custom_attributes[url_key]$$/$$categoryL.custom_attributes[url_key]$$)}}" stepKey="amOnCategoryL"/>
129+
<see userInput="We can't find products matching the selection." selector="{{StorefrontCategoryMainSection.categoryEmptyMessage}}" stepKey="seeEmptyMessage"/>
130+
<dontSeeElement selector="{{StorefrontCategoryMainSection.productName}}" stepKey="dontseeProduct"/>
131+
132+
<!-- Category M contains only Products B & C -->
133+
<amOnPage url="{{StorefrontCategoryPage.url($$categoryK.custom_attributes[url_key]$$/$$categoryL.custom_attributes[url_key]$$/$$categoryM.custom_attributes[url_key]$$)}}" stepKey="amOnCategoryM"/>
134+
<see userInput="$$productB.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="seeProductBCategoryM"/>
135+
<see userInput="$$productC.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="seeProductCCategoryM"/>
136+
137+
<!-- Category N contains only Product C -->
138+
<amOnPage url="{{StorefrontCategoryPage.url($$categoryK.custom_attributes[url_key]$$/$$categoryN.custom_attributes[url_key]$$)}}" stepKey="amOnCategoryN"/>
139+
<see userInput="$$productC.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="seeProductInCategoryN"/>
140+
141+
<!-- Run cron twice -->
142+
<magentoCLI command="cron:run" stepKey="runCron"/>
143+
<magentoCLI command="cron:run" stepKey="runCronAgain"/>
144+
145+
<!-- Open categories K, L, M, N on Storefront in order to make sure that new assigments are applied -->
146+
<!-- Category K contains only Products A, C -->
147+
<amOnPage url="{{StorefrontCategoryPage.url($$categoryK.custom_attributes[url_key]$$)}}" stepKey="storefrontCategoryK"/>
148+
<see userInput="$$productA.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="seeProductAOnCategoryK"/>
149+
<see userInput="$$productC.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="seeCategoryKWithProductC"/>
150+
151+
<!-- Category L contains only Product C -->
152+
<amOnPage url="{{StorefrontCategoryPage.url($$categoryK.custom_attributes[url_key]$$/$$categoryL.custom_attributes[url_key]$$)}}" stepKey="storefrontCategoryL"/>
153+
<see userInput="$$productC.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="seeCategoryLWithProductC"/>
154+
155+
<!-- Category M contains only Product C -->
156+
<amOnPage url="{{StorefrontCategoryPage.url($$categoryK.custom_attributes[url_key]$$/$$categoryL.custom_attributes[url_key]$$/$$categoryM.custom_attributes[url_key]$$)}}" stepKey="storefrontCategoryM"/>
157+
<waitForPageLoad stepKey="waitForStorefrontCategoryM"/>
158+
<see userInput="$$productC.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="seeCategoryMAndProductC"/>
159+
160+
<!-- Category N contains only Product C -->
161+
<amOnPage url="{{StorefrontCategoryPage.url($$categoryK.custom_attributes[url_key]$$/$$categoryN.custom_attributes[url_key]$$)}}" stepKey="storefrontCategoryN"/>
162+
<see userInput="$$productC.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="seeProductCAndCategoryN"/>
163+
164+
<!-- Open categories K, L, N to edit. Assign/unassign Products to/from them. Save changes -->
165+
166+
<!-- Remove Product A assignment for category K -->
167+
<amOnPage url="{{AdminProductEditPage.url($$productA.id$$)}}" stepKey="amOnEditProductPageA"/>
168+
<actionGroup ref="AdminUnassignCategoryOnProductAndSaveActionGroup" stepKey="unassignCategoryK">
169+
<argument name="categoryName" value="$$categoryK.name$$"/>
170+
</actionGroup>
171+
172+
<!-- Remove Product C assignment for category L -->
173+
<amOnPage url="{{AdminProductEditPage.url($$productC.id$$)}}" stepKey="amOnEditProductPageC"/>
174+
<actionGroup ref="AdminUnassignCategoryOnProductAndSaveActionGroup" stepKey="unassignCategoryL">
175+
<argument name="categoryName" value="$$categoryL.name$$"/>
176+
</actionGroup>
177+
178+
<!-- Add Product B assignment for category N -->
179+
<actionGroup ref="AdminAssignProductToCategory" stepKey="assignCategoryN">
180+
<argument name="productId" value="$$productB.id$$"/>
181+
<argument name="categoryName" value="$$categoryN.name$$"/>
182+
</actionGroup>
183+
184+
<!-- Open categories K, L, M, N on Storefront in order to make sure that new assigments are not applied yet -->
185+
<!-- Category K contains only Products A, C -->
186+
<amOnPage url="{{StorefrontCategoryPage.url($$categoryK.custom_attributes[url_key]$$)}}" stepKey="onStorefrontCategoryK"/>
187+
<see userInput="$$productA.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="seeProductAWithCategoryK"/>
188+
<see userInput="$$productC.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="seeProductC"/>
189+
190+
<!-- Category L contains only Product C -->
191+
<amOnPage url="{{StorefrontCategoryPage.url($$categoryK.custom_attributes[url_key]$$/$$categoryL.custom_attributes[url_key]$$)}}" stepKey="onStorefrontCategoryL"/>
192+
<see userInput="$$productC.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="seeCategoryLAndProductC"/>
193+
194+
<!-- Category M contains only Product C -->
195+
<amOnPage url="{{StorefrontCategoryPage.url($$categoryK.custom_attributes[url_key]$$/$$categoryL.custom_attributes[url_key]$$/$$categoryM.custom_attributes[url_key]$$)}}" stepKey="onStorefrontCategoryM"/>
196+
<see userInput="$$productC.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="seeCategoryMWithProductC"/>
197+
198+
<!-- Category N contains only Product C -->
199+
<amOnPage url="{{StorefrontCategoryPage.url($$categoryK.custom_attributes[url_key]$$/$$categoryN.custom_attributes[url_key]$$)}}" stepKey="onStorefrontCategoryN"/>
200+
<see userInput="$$productC.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="productCOnCategoryN"/>
201+
202+
<!-- Run cron twice -->
203+
<magentoCLI command="cron:run" stepKey="firstCronRun"/>
204+
<magentoCLI command="cron:run" stepKey="secondCronRun"/>
205+
206+
<!-- Open categories K, L, M, N on Storefront in order to make sure that new assigments are applied -->
207+
208+
<!-- Category K contains only Products B & C -->
209+
<amOnPage url="{{StorefrontCategoryPage.url($$categoryK.custom_attributes[url_key]$$)}}" stepKey="onFrontendCategoryK"/>
210+
<see userInput="$$productB.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="productBOnCategoryK"/>
211+
<see userInput="$$productC.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="productCOnCategoryK"/>
212+
213+
<!-- Category L contains no Products -->
214+
<amOnPage url="{{StorefrontCategoryPage.url($$categoryK.custom_attributes[url_key]$$/$$categoryL.custom_attributes[url_key]$$)}}" stepKey="onFrontendCategoryL"/>
215+
<see userInput="We can't find products matching the selection." selector="{{StorefrontCategoryMainSection.categoryEmptyMessage}}" stepKey="noProductsMessage"/>
216+
<dontSeeElement selector="{{StorefrontCategoryMainSection.productName}}" stepKey="dontSeeProductsOnCategoryL"/>
217+
218+
<!-- Category M contains only Product C -->
219+
<amOnPage url="{{StorefrontCategoryPage.url($$categoryK.custom_attributes[url_key]$$/$$categoryL.custom_attributes[url_key]$$/$$categoryM.custom_attributes[url_key]$$)}}" stepKey="onFrontendCategoryM"/>
220+
<see userInput="$$productC.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="seeCategoryMPageAndProductC"/>
221+
222+
<!-- Category N contains only Products B and C -->
223+
<amOnPage url="{{StorefrontCategoryPage.url($$categoryK.custom_attributes[url_key]$$/$$categoryN.custom_attributes[url_key]$$)}}" stepKey="onFrontendCategoryN"/>
224+
<see userInput="$$productB.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="seeProductBAndCategoryN"/>
225+
<see userInput="$$productC.name$$" selector="{{StorefrontCategoryMainSection.productName}}" stepKey="seeProductCCategoryN"/>
226+
</test>
227+
</tests>

0 commit comments

Comments
 (0)