Skip to content

Grid search selectall issue #29968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<section name="AdminCustomerGridMainActionsSection">
<element name="addNewCustomer" type="button" selector="#add" timeout="30"/>
<element name="multicheck" type="checkbox" selector="#container>div>div.admin__data-grid-wrap>table>thead>tr>th.data-grid-multicheck-cell>div>label"/>
<element name="multicheckTick" type="checkbox" selector="#container>div>div.admin__data-grid-wrap>table>thead>tr>th.data-grid-multicheck-cell>div>input"/>
<element name="delete" type="button" selector="//*[contains(@class, 'admin__data-grid-header')]//span[contains(@class,'action-menu-item') and text()='Delete']"/>
<element name="actions" type="text" selector=".action-select"/>
<element name="customerCheckbox" type="button" selector="//*[contains(text(),'{{arg}}')]/parent::td/preceding-sibling::td/label[@class='data-grid-checkbox-cell-inner']//input" parameterized="true"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminGridSearchSelectAllTest">
<annotations>
<stories value="Selection should be removed during search."/>
<title value="Selection should be removed during search."/>
<description value="Empty selected before and after search, like it works for filter"/>
<testCaseId value="MC-37659"/>
<severity value="CRITICAL"/>
<group value="uI"/>
</annotations>
<before>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
<!--Create three customers-->
<createData entity="Simple_US_Customer" stepKey="firstCustomer"/>
<createData entity="Simple_US_Customer" stepKey="secondCustomer"/>
<createData entity="Simple_US_Customer" stepKey="thirdCustomer"/>
</before>
<after>
<!--Remove two created customers, third already deleted-->
<deleteData createDataKey="firstCustomer" stepKey="deleteFirstCustomer"/>
<deleteData createDataKey="secondCustomer" stepKey="deleteSecondCustomer"/>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
</after>
<amOnPage url="{{AdminCustomerPage.url}}" stepKey="openCustomerPage"/>
<!-- search Admin Data Grid By Keyword -->
<conditionalClick selector="{{AdminDataGridHeaderSection.clearFilters}}" dependentSelector="{{AdminDataGridHeaderSection.clearFilters}}" visible="true" stepKey="clickClearFilters"/>
<fillField selector="{{AdminDataGridHeaderSection.search}}" userInput="$$secondCustomer.email$$" stepKey="fillKeywordSearchFieldWithSecondCustomerEmail"/>
<click selector="{{AdminDataGridHeaderSection.submitSearch}}" stepKey="clickKeywordSearch"/>
<waitForPageLoad stepKey="waitForPageLoad"/>
<!-- Select all from dropdown -->
<actionGroup ref="AdminGridSelectAllActionGroup" stepKey="selectAllCustomers"/>
<!-- Clear searching By Keyword-->
<conditionalClick selector="{{AdminDataGridHeaderSection.clearFilters}}" dependentSelector="{{AdminDataGridHeaderSection.clearFilters}}" visible="true" stepKey="clickClearFiltersAfterSearch"/>
<waitForPageLoad stepKey="waitForPageLoadAfterSearchRemoved"/>
<!-- Check if selection has bee removed -->
<dontSeeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.customerCheckbox($$secondCustomer.email$$)}}" stepKey="checkSecondCustomerCheckboxIsUnchecked"/>
<!-- Check delete action -->
<click selector="{{AdminCustomerGridMainActionsSection.customerCheckbox(($$thirdCustomer.email$$)}}" stepKey="selectThirdCustomer"/>
<seeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.customerCheckbox($$thirdCustomer.email$$)}}" stepKey="checkThirdCustomerIsChecked"/>
<!-- Use delete action for selected -->
<click selector="{{AdminCustomerGridMainActionsSection.actions}}" stepKey="clickActions"/>
<click selector="{{AdminCustomerGridMainActionsSection.delete}}" stepKey="clickDelete"/>
<waitForAjaxLoad stepKey="waitForLoadConfirmation"/>
<click selector="{{AdminConfirmationModalSection.ok}}" stepKey="confirmDelete"/>
<!-- Check if only one record record has been deleted -->
<see selector="{{AdminMessagesSection.success}}" userInput="A total of 1 record(s) were deleted" stepKey="seeSuccess"/>
</test>
</tests>
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminGridSelectAllOnPageTest">
<annotations>
<stories value="Toggle select page."/>
<title value="Toggle select page."/>
<description value="Empty selected before and after search, like it works for filter"/>
<testCaseId value="MC-37660"/>
<severity value="CRITICAL"/>
<group value="uI"/>
</annotations>
<before>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
<!--Create three customers-->
<createData entity="Simple_US_Customer" stepKey="firstCustomer"/>
<createData entity="Simple_US_Customer" stepKey="secondCustomer"/>
<createData entity="Simple_US_Customer" stepKey="thirdCustomer"/>
</before>
<after>
<!--Remove created customers -->
<deleteData createDataKey="firstCustomer" stepKey="deleteFirstCustomer"/>
<deleteData createDataKey="secondCustomer" stepKey="deleteSecondCustomer"/>
<deleteData createDataKey="thirdCustomer" stepKey="deleteThirdCustomer"/>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
</after>
<amOnPage url="{{AdminCustomerPage.url}}" stepKey="openCustomerPage"/>
<!-- Select all from dropdown -->
<actionGroup ref="AdminGridSelectAllActionGroup" stepKey="selectAllCustomers"/>
<!-- Deselect third customer -->
<click selector="{{AdminCustomerGridMainActionsSection.customerCheckbox(($$thirdCustomer.email$$)}}" stepKey="selectThirdCustomer"/>
<dontSeeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.customerCheckbox($$thirdCustomer.email$$)}}" stepKey="checkThirdCustomerCheckboxIsUnchecked"/>
<!-- Click select all on page checkbox -->
<actionGroup ref="AdminSelectAllCustomers" stepKey="selectAllCustomersOnPage"/>
<seeElement selector="{{AdminCustomerGridMainActionsSection.multicheckTick}}" stepKey="waitForElement"/>
<seeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.multicheckTick}}" stepKey="checkAllSelectedCheckBoxIsChecked"/>
<!-- Check all created records selected -->
<seeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.customerCheckbox($$firstCustomer.email$$)}}" stepKey="checkFirstCustomerIsCheckedAfterSelectPage"/>
<seeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.customerCheckbox($$secondCustomer.email$$)}}" stepKey="checkSecondCustomerIsCheckedAfterSelectPage"/>
<seeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.customerCheckbox($$thirdCustomer.email$$)}}" stepKey="checkThirdCustomerIsCheckedAfterSelectPage"/>
<!-- Click deselect all on page checkbox -->
<actionGroup ref="AdminSelectAllCustomers" stepKey="deselectAllCustomersCheckbox"/>
<dontSeeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.multicheckTick}}" stepKey="checkAllSelectedCheckBoxUnchecked"/>
<!-- Check all created records unselected -->
<dontSeeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.customerCheckbox($$firstCustomer.email$$)}}" stepKey="checkFirstCustomerIsUncheckedAfterSelectPage"/>
<dontSeeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.customerCheckbox($$secondCustomer.email$$)}}" stepKey="checkSecondCustomerIsUncheckedAfterSelectPage"/>
<dontSeeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.customerCheckbox($$thirdCustomer.email$$)}}" stepKey="checkThirdCustomerIsUncheckedAfterSelectPage"/>
</test>
</tests>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AdminGridSelectAllActionGroup">
<annotations>
<description>Click on select all option on the grid</description>
</annotations>

<waitForElementVisible selector="{{AdminGridSelectRows.multicheckDropdown}}" stepKey="waitForElement"/>
<click selector="{{AdminGridSelectRows.multicheckDropdown}}" stepKey="openMulticheckDropdown"/>
<click selector="{{AdminGridSelectRows.multicheckOption('Select All')}}" stepKey="clickSelectAllCustomers"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ define([

listens: {
'${ $.provider }:params.filters': 'onFilter',
'${ $.provider }:params.search': 'onSearch',
selected: 'onSelectedChange',
rows: 'onRowsChange'
},
Expand Down Expand Up @@ -235,7 +236,7 @@ define([
* @returns {Multiselect} Chainable.
*/
togglePage: function () {
return this.isPageSelected() ? this.deselectPage() : this.selectPage();
return this.isPageSelected() && !this.excluded().length ? this.deselectPage() : this.selectPage();
},

/**
Expand Down Expand Up @@ -496,6 +497,13 @@ define([
if (!this.preserveSelectionsOnFilter) {
this.deselectAll();
}
},

/**
* Is invoked when search is applied or removed
*/
onSearch: function () {
this.onFilter();
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,19 @@ define([
expect(multiSelect.selected().toString()).toEqual('3,4,1,2');
});

it('Select all rows all over the Grid and deselects all records', function () {
multiSelect.rows([{
id: 1
}, {
id: 2
}]);

multiSelect.selectAll();
multiSelect.deselectAll();
multiSelect.indetermine(2);
expect(multiSelect.togglePage().selected()).toEqual([1, 2]);
});

it('Select all rows all over the Grid without all rows on current page but with specific rows on another page',
function () {
multiSelect.rows([{
Expand Down