Skip to content

Commit 7630cb0

Browse files
committed
Static and functional tests fix, apply changes after review, extract navigation to next category page to action group
1 parent 475be33 commit 7630cb0

File tree

3 files changed

+56
-11
lines changed

3 files changed

+56
-11
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
9+
<!-- Navigates storefront category next page from toolbar -->
10+
<actionGroup name="StorefrontNavigateCategoryNextPageActionGroup">
11+
<scrollTo selector="{{StorefrontCategoryBottomToolbarSection.nextPage}}" stepKey="scrollToNextButton"/>
12+
<click selector="{{StorefrontCategoryBottomToolbarSection.nextPage}}" stepKey="clickOnNextPage"/>
13+
<waitForPageLoad stepKey="waitForNextCategoryPageLoad"/>
14+
</actionGroup>
15+
</actionGroups>

app/code/Magento/Swatches/Block/LayeredNavigation/RenderLayered.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ public function __construct(
9595
}
9696

9797
/**
98+
* Set filter and attribute objects
99+
*
98100
* @param \Magento\Catalog\Model\Layer\Filter\AbstractFilter $filter
101+
*
99102
* @return $this
100103
* @throws \Magento\Framework\Exception\LocalizedException
101104
*/
@@ -108,6 +111,8 @@ public function setSwatchFilter(\Magento\Catalog\Model\Layer\Filter\AbstractFilt
108111
}
109112

110113
/**
114+
* Get attribute swatch data
115+
*
111116
* @return array
112117
*/
113118
public function getSwatchData()
@@ -138,8 +143,11 @@ public function getSwatchData()
138143
}
139144

140145
/**
146+
* Build filter option url
147+
*
141148
* @param string $attributeCode
142149
* @param int $optionId
150+
*
143151
* @return string
144152
*/
145153
public function buildUrl($attributeCode, $optionId)
@@ -161,7 +169,10 @@ public function buildUrl($attributeCode, $optionId)
161169
}
162170

163171
/**
172+
* Get view data for option with no results
173+
*
164174
* @param Option $swatchOption
175+
*
165176
* @return array
166177
*/
167178
protected function getUnusedOption(Option $swatchOption)
@@ -174,8 +185,11 @@ protected function getUnusedOption(Option $swatchOption)
174185
}
175186

176187
/**
188+
* Get option data if visible
189+
*
177190
* @param FilterItem[] $filterItems
178191
* @param Option $swatchOption
192+
*
179193
* @return array
180194
*/
181195
protected function getFilterOption(array $filterItems, Option $swatchOption)
@@ -190,8 +204,11 @@ protected function getFilterOption(array $filterItems, Option $swatchOption)
190204
}
191205

192206
/**
207+
* Get view data for option
208+
*
193209
* @param FilterItem $filterItem
194210
* @param Option $swatchOption
211+
*
195212
* @return array
196213
*/
197214
protected function getOptionViewData(FilterItem $filterItem, Option $swatchOption)
@@ -211,7 +228,10 @@ protected function getOptionViewData(FilterItem $filterItem, Option $swatchOptio
211228
}
212229

213230
/**
231+
* Check if option should be visible
232+
*
214233
* @param FilterItem $filterItem
234+
*
215235
* @return bool
216236
*/
217237
protected function isOptionVisible(FilterItem $filterItem)
@@ -220,6 +240,8 @@ protected function isOptionVisible(FilterItem $filterItem)
220240
}
221241

222242
/**
243+
* Check if attribute values should be visible with no results
244+
*
223245
* @return bool
224246
*/
225247
protected function isShowEmptyResults()
@@ -228,7 +250,10 @@ protected function isShowEmptyResults()
228250
}
229251

230252
/**
253+
* Check if option should be disabled
254+
*
231255
* @param FilterItem $filterItem
256+
*
232257
* @return bool
233258
*/
234259
protected function isOptionDisabled(FilterItem $filterItem)
@@ -237,8 +262,11 @@ protected function isOptionDisabled(FilterItem $filterItem)
237262
}
238263

239264
/**
265+
* Retrieve filter item by id
266+
*
240267
* @param FilterItem[] $filterItems
241268
* @param integer $id
269+
*
242270
* @return bool|FilterItem
243271
*/
244272
protected function getFilterItemById(array $filterItems, $id)
@@ -252,8 +280,11 @@ protected function getFilterItemById(array $filterItems, $id)
252280
}
253281

254282
/**
283+
* Get swatch image path
284+
*
255285
* @param string $type
256286
* @param string $filename
287+
*
257288
* @return string
258289
*/
259290
public function getSwatchPath($type, $filename)

app/code/Magento/Swatches/Test/Mftf/Test/StorefrontRedirectToFirstPageOnFilteringBySwatchTest.xml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232

3333
<magentoCLI command="config:set catalog/frontend/grid_per_page 1" stepKey="setOneProductPerPage"/>
3434
<magentoCLI command="config:set catalog/frontend/grid_per_page_values 1" stepKey="setGridPerPage"/>
35-
<magentoCLI command="cache:clean config full_page" stepKey="cleanInvalidatedCaches"/>
3635

3736
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
3837
<actionGroup ref="AddTextSwatchToProductActionGroup" stepKey="addSwatchAttribute">
3938
<argument name="usedInLayeredNavigation" value="1"/>
4039
</actionGroup>
40+
<magentoCLI command="cache:clean block_html collections config full_page" stepKey="cleanInvalidatedCaches"/>
4141
</before>
4242

4343
<after>
@@ -48,7 +48,7 @@
4848

4949
<magentoCLI command="config:set catalog/frontend/grid_per_page 12" stepKey="setDefaultProductsPerPage"/>
5050
<magentoCLI command="config:set catalog/frontend/grid_per_page_values 12,24,36" stepKey="setDefaultGridPerPage"/>
51-
<magentoCLI command="cache:clean config full_page" stepKey="cleanInvalidatedCaches"/>
51+
<magentoCLI command="cache:clean block_html collections config full_page" stepKey="cleanInvalidatedCaches"/>
5252

5353
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
5454
<deleteData createDataKey="createSimpleProduct1" stepKey="deleteSimpleProduct1"/>
@@ -63,7 +63,8 @@
6363
</actionGroup>
6464
<actionGroup ref="SaveAttributeSetActionGroup" stepKey="SaveAttributeSet"/>
6565

66-
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="goToProductsGridPage"/>
66+
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="goToProductIndexPage"/>
67+
<actionGroup ref="ClearFiltersAdminProductGridActionGroup" stepKey="clearFiltersOnProductIndexPage"/>
6768

6869
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="goToProduct1EditPage">
6970
<argument name="product" value="$$createSimpleProduct1$$"/>
@@ -85,18 +86,16 @@
8586
<selectOption selector="{{AdminProductAttributesSection.attributeDropdownByCode(textSwatchAttribute.attribute_code)}}" userInput="textSwatchOption2" stepKey="selectProduct3AttributeOption"/>
8687
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct3"/>
8788

88-
<magentoCLI command="cron:run --group=index" stepKey="runCronIndexer"/>
89+
<magentoCron groups="index" stepKey="runCronIndexer"/>
8990

90-
<amOnPage url="$$createCategory.name$$.html" stepKey="amOnCategoryPage"/>
91-
<waitForPageLoad stepKey="waitForPageToLoad"/>
92-
93-
<scrollTo selector="{{StorefrontCategoryBottomToolbarSection.nextPage}}" stepKey="scrollToNextButton"/>
94-
<click selector="{{StorefrontCategoryBottomToolbarSection.nextPage}}" stepKey="clickOnNextPage"/>
95-
<waitForPageLoad stepKey="waitForPageToLoad2"/>
91+
<actionGroup ref="StorefrontNavigateCategoryPageActionGroup" stepKey="navigateToCategoryPage">
92+
<argument name="category" value="$$createCategory$$"/>
93+
</actionGroup>
94+
<actionGroup ref="StorefrontNavigateCategoryNextPageActionGroup" stepKey="navigateToCategoryNextPage"/>
9695

9796
<click selector="{{StorefrontCategorySidebarSection.filterOptionTitle(textSwatchAttribute.default_label)}}" stepKey="expandAttribute"/>
9897
<click selector="{{StorefrontCategorySidebarSection.attributeNthOption(textSwatchAttribute.attribute_code, '1')}}" stepKey="filterBySwatch1"/>
99-
<waitForPageLoad stepKey="waitForPageToLoad3"/>
98+
<waitForPageLoad stepKey="waitForPageToLoad2"/>
10099

101100
<actionGroup ref="AssertStorefrontCategoryCurrentPageIsFirstActionGroup" stepKey="assertCurrentPageIsFirst"/>
102101
</test>

0 commit comments

Comments
 (0)