Skip to content

Commit

Permalink
Fix for multiselect with search on grid.
Browse files Browse the repository at this point in the history
  • Loading branch information
engcom-Hotel committed Sep 9, 2020
1 parent 1c9ba3e commit 1f6e82f
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?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=""/>
<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"/>
<!-- Check select all action -->
<actionGroup ref="AdminSelectAllCustomers" stepKey="selectAllCustomers"/>
<seeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.customerCheckbox($$secondCustomer.email$$)}}" stepKey="checkSecondCustomerIsCheckedAfterSelectAll"/>
<!-- 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
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();
}
});
});

0 comments on commit 1f6e82f

Please sign in to comment.