Skip to content

Commit 0346db0

Browse files
author
OlgaVasyltsun
committed
MAGETWO-93755: Catalog grid page number resets after Save and Close action.
1 parent 364645d commit 0346db0

File tree

6 files changed

+161
-5
lines changed

6 files changed

+161
-5
lines changed

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductGridActionGroup.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,14 @@
103103
<conditionalClick selector="{{AdminProductGridTableHeaderSection.id('ascend')}}" dependentSelector="{{AdminProductGridTableHeaderSection.id('descend')}}" visible="false" stepKey="sortById"/>
104104
<waitForPageLoad stepKey="waitForPageLoad"/>
105105
</actionGroup>
106+
107+
<actionGroup name="DeleteProductsIfTheyExist">
108+
<conditionalClick selector="{{AdminProductGridSection.multicheckDropdown}}" dependentSelector="{{AdminDataGridTableSection.firstRow}}" visible="true" stepKey="openMulticheckDropdown"/>
109+
<conditionalClick selector="{{AdminProductGridSection.multicheckOption('Select All')}}" dependentSelector="{{AdminDataGridTableSection.firstRow}}" visible="true" stepKey="selectAllProductInFilteredGrid"/>
110+
<click selector="{{AdminProductGridSection.bulkActionDropdown}}" stepKey="clickActionDropdown"/>
111+
<click selector="{{AdminProductGridSection.bulkActionOption('Delete')}}" stepKey="clickDeleteAction"/>
112+
<waitForElementVisible selector="{{AdminConfirmationModalSection.ok}}" stepKey="waitForModalPopUp"/>
113+
<click selector="{{AdminConfirmationModalSection.ok}}" stepKey="confirmProductDelete"/>
114+
</actionGroup>
115+
106116
</actionGroups>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<entity name="ProductPerPage">
12+
<data key="productCount">1</data>
13+
</entity>
14+
</entities>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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="AdminGridPageNumberAfterSaveAndCloseActionTest">
12+
<annotations>
13+
<features value="Catalog"/>
14+
<title value="Checking Catalog grid page number after Save and Close action"/>
15+
<description value="Checking Catalog grid page number after Save and Close action"/>
16+
<stories value="Verify Catalog Grid"/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="MC-17278"/>
19+
<useCaseId value="MAGETWO-93755"/>
20+
<group value="Catalog"/>
21+
</annotations>
22+
<before>
23+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
24+
<!--Clear product grid-->
25+
<comment userInput="Clear product grid" stepKey="commentClearProductsGrid"/>
26+
<amOnPage url="{{AdminCatalogProductPage.url}}" stepKey="goToProductsGridPage"/>
27+
<actionGroup ref="clearFiltersAdminDataGrid" stepKey="clearProductsFilters"/>
28+
<actionGroup ref="DeleteProductsIfTheyExist" stepKey="deleteProductIfTheyExist"/>
29+
<!--Create products-->
30+
<createData entity="SimpleSubCategory" stepKey="createCategory1"/>
31+
<createData entity="SimpleProduct" stepKey="createProduct1">
32+
<requiredEntity createDataKey="createCategory1"/>
33+
</createData>
34+
<createData entity="SimpleSubCategory" stepKey="createCategory2"/>
35+
<createData entity="SimpleProduct" stepKey="createProduct2">
36+
<requiredEntity createDataKey="createCategory2"/>
37+
</createData>
38+
<!--Update product count per page-->
39+
<actionGroup ref="AdminDataGridSelectCustomPerPage" stepKey="select1OrderPerPage"/>
40+
</before>
41+
<after>
42+
<!--Delete created data-->
43+
<deleteData stepKey="deleteCategory1" createDataKey="createCategory1"/>
44+
<deleteData stepKey="deleteProduct1" createDataKey="createProduct1"/>
45+
<deleteData stepKey="deleteCategory2" createDataKey="createCategory2"/>
46+
<deleteData stepKey="deleteProduct2" createDataKey="createProduct2"/>
47+
<!--Revert products count per page -->
48+
<amOnPage url="{{AdminCatalogProductPage.url}}" stepKey="goToProductsGridPage"/>
49+
<actionGroup ref="AdminDataGridDeleteCustomPerPage" stepKey="deleteCustomAddedPerPage"/>
50+
<actionGroup ref="logout" stepKey="logout"/>
51+
</after>
52+
53+
<amOnPage url="{{AdminCatalogProductPage.url}}" stepKey="goToProductsGridPage"/>
54+
<!--Go to the next page and edit the product-->
55+
<comment userInput="Go to the next page and edit the product" stepKey="commentEdiProduct"/>
56+
<click selector="{{AdminDataGridPaginationSection.nextPage}}" stepKey="clickNextPageOrderGrid"/>
57+
<seeInField selector="{{AdminDataGridPaginationSection.currentPage}}" userInput="2" stepKey="seeOnSecondPageOrderGrid"/>
58+
<waitForPageLoad stepKey="waitForPageLoad"/>
59+
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="openEditProduct2">
60+
<argument name="product" value="$$createProduct2$$"/>
61+
</actionGroup>
62+
<actionGroup ref="AdminFormSaveAndClose" stepKey="saveAndCloseProduct"/>
63+
<waitForPageLoad stepKey="waitForPageLoad1"/>
64+
<seeInField selector="{{AdminDataGridPaginationSection.currentPage}}" userInput="2" stepKey="seeOnSecondPageOrderGridAfterProductSaved"/>
65+
</test>
66+
</tests>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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="AdminDataGridSelectCustomPerPage">
12+
<arguments>
13+
<argument name="perPage" defaultValue="{{ProductPerPage.productCount}}" type="string"/>
14+
</arguments>
15+
<click selector="{{AdminDataGridPaginationSection.perPageDropdown}}" stepKey="clickPerPageDropdown"/>
16+
<click selector="{{AdminDataGridPaginationSection.perPageOption('Custom')}}" stepKey="selectCustomPerPage"/>
17+
<waitForElementVisible selector="{{AdminDataGridPaginationSection.perPageInput}}" stepKey="waitForInputVisible"/>
18+
<fillField selector="{{AdminDataGridPaginationSection.perPageInput}}" userInput="{{perPage}}" stepKey="fillCustomPerPage"/>
19+
<click selector="{{AdminDataGridPaginationSection.perPageApplyInput}}" stepKey="applyCustomPerPage"/>
20+
<waitForLoadingMaskToDisappear stepKey="waitForGridLoad"/>
21+
<seeInField selector="{{AdminDataGridPaginationSection.perPageDropDownValue}}" userInput="{{perPage}}" stepKey="seePerPageValueInDropDown"/>
22+
</actionGroup>
23+
24+
<actionGroup name="AdminDataGridDeleteCustomPerPage">
25+
<arguments>
26+
<argument name="perPage" defaultValue="{{ProductPerPage.productCount}}" type="string"/>
27+
</arguments>
28+
<click selector="{{AdminDataGridPaginationSection.perPageDropdown}}" stepKey="clickPerPageDropdown"/>
29+
<click selector="{{AdminDataGridPaginationSection.perPageEditCustomValue(perPage)}}" stepKey="clickToEditCustomPerPage"/>
30+
<waitForElementVisible selector="{{AdminDataGridPaginationSection.perPageDeleteCustomValue(perPage)}}" stepKey="waitForDeleteButtonVisible"/>
31+
<click selector="{{AdminDataGridPaginationSection.perPageDeleteCustomValue(perPage)}}" stepKey="clickToDeleteCustomPerPage"/>
32+
<click selector="{{AdminDataGridPaginationSection.perPageDropdown}}" stepKey="clickPerPageDropdown1"/>
33+
<dontSeeElement selector="{{AdminDataGridPaginationSection.perPageDropDownItem(perPage)}}" stepKey="dontSeeDropDownItem"/>
34+
</actionGroup>
35+
</actionGroups>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="AdminDataGridPaginationSection">
12+
<element name="perPageDropdown" type="select" selector=".admin__data-grid-pager-wrap .selectmenu"/>
13+
<element name="perPageOption" type="button" selector="//div[@class='admin__data-grid-pager-wrap']//div[@class='selectmenu-items _active']//li//button[text()='{{var1}}']" parameterized="true"/>
14+
<element name="perPageInput" type="input" selector="div.admin__data-grid-pager-wrap div.selectmenu-items._active li._edit div.selectmenu-item-edit input" timeout="30"/>
15+
<element name="perPageApplyInput" type="button" selector="div.admin__data-grid-pager-wrap div.selectmenu-items._active li._edit div.selectmenu-item-edit button"/>
16+
<element name="perPageDropDownItem" type="button" selector="//*[contains(@class, 'selectmenu-items _active')]//button[contains(@class, 'selectmenu-item-action') and text()='{{dropDownItem}}']" parameterized="true"/>
17+
<element name="perPageEditCustomValue" type="button" selector="//div[contains(@class, 'selectmenu-items _active')]//div[contains(@class, 'selectmenu-item')]//button[text()='{{perPageCustomValue}}']/following-sibling::button[contains(@class, 'action-edit')]" parameterized="true"/>
18+
<element name="perPageDeleteCustomValue" type="button" selector="//div[contains(@class, 'selectmenu-items _active')]//div[contains(@class, 'selectmenu-item')]//button[text()='{{perPageCustomValue}}']/parent::div/preceding-sibling::div/button[contains(@class, 'action-delete')]" parameterized="true" timeout="30"/>
19+
<element name="nextPage" type="button" selector="div.admin__data-grid-pager > button.action-next" timeout="30"/>
20+
<element name="currentPage" type="input" selector="div.admin__data-grid-pager > input[data-ui-id='current-page-input']"/>
21+
<element name="perPageDropDownValue" type="input" selector=".admin__data-grid-pager-wrap .selectmenu-value input" timeout="30"/>
22+
</section>
23+
</sections>

app/code/Magento/Ui/view/base/web/js/grid/paging/paging.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ define([
1919
defaults: {
2020
template: 'ui/grid/paging/paging',
2121
totalTmpl: 'ui/grid/paging-total',
22+
totalRecords: 0,
2223
pageSize: 20,
24+
pages: 1,
2325
current: 1,
2426
selectProvider: 'ns = ${ $.ns }, index = ids',
2527

@@ -35,14 +37,20 @@ define([
3537
imports: {
3638
pageSize: '${ $.sizesConfig.name }:value',
3739
totalSelected: '${ $.selectProvider }:totalSelected',
38-
totalRecords: '${ $.provider }:data.totalRecords'
40+
totalRecords: '${ $.provider }:data.totalRecords',
41+
filters: '${ $.provider }:params.filters'
3942
},
4043

4144
exports: {
4245
pageSize: '${ $.provider }:params.paging.pageSize',
4346
current: '${ $.provider }:params.paging.current'
4447
},
4548

49+
statefull: {
50+
pageSize: true,
51+
current: true
52+
},
53+
4654
listens: {
4755
'pages': 'onPagesChange',
4856
'pageSize': 'onPageSizeChange',
@@ -173,7 +181,9 @@ define([
173181
* @returns {Paging} Chainable.
174182
*/
175183
goFirst: function () {
176-
this.current = 1;
184+
if (!_.isUndefined(this.filters)) {
185+
this.current = 1;
186+
}
177187

178188
return this;
179189
},
@@ -219,13 +229,11 @@ define([
219229
/**
220230
* Calculates new page cursor based on the
221231
* previous and current page size values.
222-
*
223-
* @returns {Number} Updated cursor value.
224232
*/
225233
updateCursor: function () {
226234
var cursor = this.current - 1,
227235
size = this.pageSize,
228-
oldSize = this.previousSize,
236+
oldSize = _.isUndefined(this.previousSize) ? this.pageSize : this.previousSize,
229237
delta = cursor * (oldSize - size) / size;
230238

231239
delta = size > oldSize ?

0 commit comments

Comments
 (0)