Skip to content

Commit 616e04f

Browse files
committed
Merge remote-tracking branch 'l3/ACP2E-657' into PR_L3_05_04_2022
2 parents 4367ee8 + eb49e8a commit 616e04f

File tree

4 files changed

+104
-0
lines changed

4 files changed

+104
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="StorefrontDontSeeNoProductsFoundActionGroup">
11+
<dontSee userInput="We can't find products matching the selection." stepKey="dontSeeEmptyNotice"/>
12+
</actionGroup>
13+
</actionGroups>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="StorefrontSwitchCategoryViewToGridModeActionGroup">
12+
<annotations>
13+
<description>Switch the Storefront Category view to Grid.</description>
14+
</annotations>
15+
16+
<click selector="{{StorefrontCategoryTopToolbarSection.gridMode}}" stepKey="switchCategoryViewToGridMode"/>
17+
<waitForElement selector="{{StorefrontCategoryMainSection.CategoryTitle}}" time="30" stepKey="waitForCategoryReload"/>
18+
</actionGroup>
19+
</actionGroups>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="StorefrontPaginationResetOnViewModeChange">
11+
<annotations>
12+
<features value="Catalog"/>
13+
<stories value="Product grid"/>
14+
<title value="Pagination should reset on storefront upon view mode switching"/>
15+
<description value="Pagination should reset on storefront upon view mode switching"/>
16+
<severity value="AVERAGE"/>
17+
<testCaseId value="AC-2652"/>
18+
<useCaseId value="ACP2E-657"/>
19+
<group value="catalog"/>
20+
</annotations>
21+
<before>
22+
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
23+
<createData entity="SimpleProduct" stepKey="createSimpleProductOne">
24+
<requiredEntity createDataKey="createCategory"/>
25+
</createData>
26+
<createData entity="SimpleProduct" stepKey="createSimpleProductTwo">
27+
<requiredEntity createDataKey="createCategory"/>
28+
</createData>
29+
<magentoCLI command="config:set {{CustomGridPerPageValuesConfigData.path}} {{CustomGridPerPageValuesConfigData.value}}" stepKey="setCustomGridPerPageValues"/>
30+
<magentoCLI command="config:set {{CustomGridPerPageDefaultConfigData.path}} {{CustomGridPerPageDefaultConfigData.value}}" stepKey="setCustomGridPerPageDefaults"/>
31+
</before>
32+
<after>
33+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
34+
<deleteData createDataKey="createSimpleProductOne" stepKey="deleteProductOne"/>
35+
<deleteData createDataKey="createSimpleProductTwo" stepKey="deleteProductTwo"/>
36+
<magentoCLI command="config:set {{DefaultGridPerPageValuesConfigData.path}} {{DefaultGridPerPageValuesConfigData.value}}" stepKey="setDefaultGridPerPageValues"/>
37+
<magentoCLI command="config:set {{DefaultGridPerPageDefaultConfigData.path}} {{DefaultGridPerPageDefaultConfigData.value}}" stepKey="setDefaultGridPerPageDefaults"/>
38+
</after>
39+
40+
<!-- Go to category page with the default grid mode view, 1 product per page -->
41+
<amOnPage url="{{StorefrontCategoryPage.url($$createCategory.custom_attributes[url_key]$$)}}" stepKey="goToStorefrontCreatedCategoryPage"/>
42+
<!-- Go to second page of the product list and validate that Prod1 is not visible and Prod2 is visible -->
43+
<actionGroup ref="StorefrontNavigateCategoryNextPageActionGroup" stepKey="goToNextPage"/>
44+
<actionGroup ref="AssertStorefrontProductIsPresentOnCategoryPageActionGroup" stepKey="seeProdTwoOnGrid">
45+
<argument name="productName" value="$$createSimpleProductTwo.name$$"/>
46+
</actionGroup>
47+
<actionGroup ref="AssertStorefrontProductNameIsNotOnProductMainPageActionGroup" stepKey="dontSeeProdOneOnGrid">
48+
<argument name="productName" value="$$createSimpleProductOne.name$$"/>
49+
</actionGroup>
50+
51+
<!-- Switch to list view with 10 products per page and only one page of products available -->
52+
<actionGroup ref="StorefrontSwitchCategoryViewToListModeActionGroup" stepKey="switchViewToList"/>
53+
<!-- Validate that "no products found" error message is not present -->
54+
<actionGroup ref="StorefrontDontSeeNoProductsFoundActionGroup" stepKey="dontSeeNoProdsFoundMessage"/>
55+
<!-- Validate that there is no pagination control visible as we only have one page of products -->
56+
<dontSeeElement selector="{{StorefrontCategoryBottomToolbarSection.currentPage}}" stepKey="dontSeePaginationControl"/>
57+
<!-- Validate both products are present on the page -->
58+
<actionGroup ref="AssertStorefrontProductIsPresentOnCategoryPageActionGroup" stepKey="seeProdOneOnList">
59+
<argument name="productName" value="$$createSimpleProductOne.name$$"/>
60+
</actionGroup>
61+
<actionGroup ref="AssertStorefrontProductIsPresentOnCategoryPageActionGroup" stepKey="seeProdTwoOnList">
62+
<argument name="productName" value="$$createSimpleProductTwo.name$$"/>
63+
</actionGroup>
64+
65+
<!-- Rollback the view mode to the default grid -->
66+
<actionGroup ref="StorefrontSwitchCategoryViewToGridModeActionGroup" stepKey="switchToGridMode"/>
67+
</test>
68+
</tests>

app/code/Magento/Catalog/view/frontend/web/js/product/list/toolbar.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ define([
145145
currentPage = this.getCurrentPage(),
146146
form, params, key, input, formKey, newPage;
147147

148+
if (currentPage > 1 && paramName === this.options.mode) {
149+
delete paramData[this.options.page];
150+
}
151+
148152
if (currentPage > 1 && paramName === this.options.limit) {
149153
newPage = Math.floor(this.getCurrentLimit() * (currentPage - 1) / paramValue) + 1;
150154

0 commit comments

Comments
 (0)