Skip to content

Commit 2bda9c1

Browse files
ENGCOM-8175: Grid search selectall issue #29968
- Merge Pull Request #29968 from engcom-Hotel/magento2:grid_search_selectall_issue - Merged commits: 1. 1f6e82f 2. e837bdc 3. 591e04e 4. 8a9546f 5. f019712 6. 4a20d6e 7. 70df4f0 8. a85a63b 9. 462f123
2 parents 28020ae + 462f123 commit 2bda9c1

File tree

6 files changed

+154
-1
lines changed

6 files changed

+154
-1
lines changed

app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGridMainActionsSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<section name="AdminCustomerGridMainActionsSection">
1212
<element name="addNewCustomer" type="button" selector="#add" timeout="30"/>
1313
<element name="multicheck" type="checkbox" selector="#container>div>div.admin__data-grid-wrap>table>thead>tr>th.data-grid-multicheck-cell>div>label"/>
14+
<element name="multicheckTick" type="checkbox" selector="#container>div>div.admin__data-grid-wrap>table>thead>tr>th.data-grid-multicheck-cell>div>input"/>
1415
<element name="delete" type="button" selector="//*[contains(@class, 'admin__data-grid-header')]//span[contains(@class,'action-menu-item') and text()='Delete']"/>
1516
<element name="actions" type="text" selector=".action-select"/>
1617
<element name="customerCheckbox" type="button" selector="//*[contains(text(),'{{arg}}')]/parent::td/preceding-sibling::td/label[@class='data-grid-checkbox-cell-inner']//input" parameterized="true"/>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminGridSearchSelectAllTest">
11+
<annotations>
12+
<stories value="Selection should be removed during search."/>
13+
<title value="Selection should be removed during search."/>
14+
<description value="Empty selected before and after search, like it works for filter"/>
15+
<testCaseId value="MC-37659"/>
16+
<severity value="CRITICAL"/>
17+
<group value="uI"/>
18+
</annotations>
19+
<before>
20+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
21+
<!--Create three customers-->
22+
<createData entity="Simple_US_Customer" stepKey="firstCustomer"/>
23+
<createData entity="Simple_US_Customer" stepKey="secondCustomer"/>
24+
<createData entity="Simple_US_Customer" stepKey="thirdCustomer"/>
25+
</before>
26+
<after>
27+
<!--Remove two created customers, third already deleted-->
28+
<deleteData createDataKey="firstCustomer" stepKey="deleteFirstCustomer"/>
29+
<deleteData createDataKey="secondCustomer" stepKey="deleteSecondCustomer"/>
30+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
31+
</after>
32+
<amOnPage url="{{AdminCustomerPage.url}}" stepKey="openCustomerPage"/>
33+
<!-- search Admin Data Grid By Keyword -->
34+
<conditionalClick selector="{{AdminDataGridHeaderSection.clearFilters}}" dependentSelector="{{AdminDataGridHeaderSection.clearFilters}}" visible="true" stepKey="clickClearFilters"/>
35+
<fillField selector="{{AdminDataGridHeaderSection.search}}" userInput="$$secondCustomer.email$$" stepKey="fillKeywordSearchFieldWithSecondCustomerEmail"/>
36+
<click selector="{{AdminDataGridHeaderSection.submitSearch}}" stepKey="clickKeywordSearch"/>
37+
<waitForPageLoad stepKey="waitForPageLoad"/>
38+
<!-- Select all from dropdown -->
39+
<actionGroup ref="AdminGridSelectAllActionGroup" stepKey="selectAllCustomers"/>
40+
<!-- Clear searching By Keyword-->
41+
<conditionalClick selector="{{AdminDataGridHeaderSection.clearFilters}}" dependentSelector="{{AdminDataGridHeaderSection.clearFilters}}" visible="true" stepKey="clickClearFiltersAfterSearch"/>
42+
<waitForPageLoad stepKey="waitForPageLoadAfterSearchRemoved"/>
43+
<!-- Check if selection has bee removed -->
44+
<dontSeeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.customerCheckbox($$secondCustomer.email$$)}}" stepKey="checkSecondCustomerCheckboxIsUnchecked"/>
45+
<!-- Check delete action -->
46+
<click selector="{{AdminCustomerGridMainActionsSection.customerCheckbox(($$thirdCustomer.email$$)}}" stepKey="selectThirdCustomer"/>
47+
<seeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.customerCheckbox($$thirdCustomer.email$$)}}" stepKey="checkThirdCustomerIsChecked"/>
48+
<!-- Use delete action for selected -->
49+
<click selector="{{AdminCustomerGridMainActionsSection.actions}}" stepKey="clickActions"/>
50+
<click selector="{{AdminCustomerGridMainActionsSection.delete}}" stepKey="clickDelete"/>
51+
<waitForAjaxLoad stepKey="waitForLoadConfirmation"/>
52+
<click selector="{{AdminConfirmationModalSection.ok}}" stepKey="confirmDelete"/>
53+
<!-- Check if only one record record has been deleted -->
54+
<see selector="{{AdminMessagesSection.success}}" userInput="A total of 1 record(s) were deleted" stepKey="seeSuccess"/>
55+
</test>
56+
</tests>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminGridSelectAllOnPageTest">
11+
<annotations>
12+
<stories value="Toggle select page."/>
13+
<title value="Toggle select page."/>
14+
<description value="Empty selected before and after search, like it works for filter"/>
15+
<testCaseId value="MC-37660"/>
16+
<severity value="CRITICAL"/>
17+
<group value="uI"/>
18+
</annotations>
19+
<before>
20+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
21+
<!--Create three customers-->
22+
<createData entity="Simple_US_Customer" stepKey="firstCustomer"/>
23+
<createData entity="Simple_US_Customer" stepKey="secondCustomer"/>
24+
<createData entity="Simple_US_Customer" stepKey="thirdCustomer"/>
25+
</before>
26+
<after>
27+
<!--Remove created customers -->
28+
<deleteData createDataKey="firstCustomer" stepKey="deleteFirstCustomer"/>
29+
<deleteData createDataKey="secondCustomer" stepKey="deleteSecondCustomer"/>
30+
<deleteData createDataKey="thirdCustomer" stepKey="deleteThirdCustomer"/>
31+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
32+
</after>
33+
<amOnPage url="{{AdminCustomerPage.url}}" stepKey="openCustomerPage"/>
34+
<!-- Select all from dropdown -->
35+
<actionGroup ref="AdminGridSelectAllActionGroup" stepKey="selectAllCustomers"/>
36+
<!-- Deselect third customer -->
37+
<click selector="{{AdminCustomerGridMainActionsSection.customerCheckbox(($$thirdCustomer.email$$)}}" stepKey="selectThirdCustomer"/>
38+
<dontSeeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.customerCheckbox($$thirdCustomer.email$$)}}" stepKey="checkThirdCustomerCheckboxIsUnchecked"/>
39+
<!-- Click select all on page checkbox -->
40+
<actionGroup ref="AdminSelectAllCustomers" stepKey="selectAllCustomersOnPage"/>
41+
<seeElement selector="{{AdminCustomerGridMainActionsSection.multicheckTick}}" stepKey="waitForElement"/>
42+
<seeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.multicheckTick}}" stepKey="checkAllSelectedCheckBoxIsChecked"/>
43+
<!-- Check all created records selected -->
44+
<seeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.customerCheckbox($$firstCustomer.email$$)}}" stepKey="checkFirstCustomerIsCheckedAfterSelectPage"/>
45+
<seeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.customerCheckbox($$secondCustomer.email$$)}}" stepKey="checkSecondCustomerIsCheckedAfterSelectPage"/>
46+
<seeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.customerCheckbox($$thirdCustomer.email$$)}}" stepKey="checkThirdCustomerIsCheckedAfterSelectPage"/>
47+
<!-- Click deselect all on page checkbox -->
48+
<actionGroup ref="AdminSelectAllCustomers" stepKey="deselectAllCustomersCheckbox"/>
49+
<dontSeeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.multicheckTick}}" stepKey="checkAllSelectedCheckBoxUnchecked"/>
50+
<!-- Check all created records unselected -->
51+
<dontSeeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.customerCheckbox($$firstCustomer.email$$)}}" stepKey="checkFirstCustomerIsUncheckedAfterSelectPage"/>
52+
<dontSeeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.customerCheckbox($$secondCustomer.email$$)}}" stepKey="checkSecondCustomerIsUncheckedAfterSelectPage"/>
53+
<dontSeeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.customerCheckbox($$thirdCustomer.email$$)}}" stepKey="checkThirdCustomerIsUncheckedAfterSelectPage"/>
54+
</test>
55+
</tests>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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="AdminGridSelectAllActionGroup">
12+
<annotations>
13+
<description>Click on select all option on the grid</description>
14+
</annotations>
15+
16+
<waitForElementVisible selector="{{AdminGridSelectRows.multicheckDropdown}}" stepKey="waitForElement"/>
17+
<click selector="{{AdminGridSelectRows.multicheckDropdown}}" stepKey="openMulticheckDropdown"/>
18+
<click selector="{{AdminGridSelectRows.multicheckOption('Select All')}}" stepKey="clickSelectAllCustomers"/>
19+
</actionGroup>
20+
</actionGroups>

app/code/Magento/Ui/view/base/web/js/grid/columns/multiselect.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ define([
5252

5353
listens: {
5454
'${ $.provider }:params.filters': 'onFilter',
55+
'${ $.provider }:params.search': 'onSearch',
5556
selected: 'onSelectedChange',
5657
rows: 'onRowsChange'
5758
},
@@ -235,7 +236,7 @@ define([
235236
* @returns {Multiselect} Chainable.
236237
*/
237238
togglePage: function () {
238-
return this.isPageSelected() ? this.deselectPage() : this.selectPage();
239+
return this.isPageSelected() && !this.excluded().length ? this.deselectPage() : this.selectPage();
239240
},
240241

241242
/**
@@ -496,6 +497,13 @@ define([
496497
if (!this.preserveSelectionsOnFilter) {
497498
this.deselectAll();
498499
}
500+
},
501+
502+
/**
503+
* Is invoked when search is applied or removed
504+
*/
505+
onSearch: function () {
506+
this.onFilter();
499507
}
500508
});
501509
});

dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/multiselect.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,19 @@ define([
135135
expect(multiSelect.selected().toString()).toEqual('3,4,1,2');
136136
});
137137

138+
it('Select all rows all over the Grid and deselects all records', function () {
139+
multiSelect.rows([{
140+
id: 1
141+
}, {
142+
id: 2
143+
}]);
144+
145+
multiSelect.selectAll();
146+
multiSelect.deselectAll();
147+
multiSelect.indetermine(2);
148+
expect(multiSelect.togglePage().selected()).toEqual([1, 2]);
149+
});
150+
138151
it('Select all rows all over the Grid without all rows on current page but with specific rows on another page',
139152
function () {
140153
multiSelect.rows([{

0 commit comments

Comments
 (0)