diff --git a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGridMainActionsSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGridMainActionsSection.xml index d644b581088bc..8277cdd64928a 100644 --- a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGridMainActionsSection.xml +++ b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGridMainActionsSection.xml @@ -11,6 +11,7 @@
+ diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminGridSearchSelectAllTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminGridSearchSelectAllTest.xml new file mode 100644 index 0000000000000..64e9f6d10bdb3 --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/Test/AdminGridSearchSelectAllTest.xml @@ -0,0 +1,56 @@ + + + + + + + + + <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> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminGridSelectAllOnPageTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminGridSelectAllOnPageTest.xml new file mode 100644 index 0000000000000..bfc49fd476dd0 --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/Test/AdminGridSelectAllOnPageTest.xml @@ -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> diff --git a/app/code/Magento/Ui/Test/Mftf/ActionGroup/AdminGridSelectAllActionGroup.xml b/app/code/Magento/Ui/Test/Mftf/ActionGroup/AdminGridSelectAllActionGroup.xml new file mode 100644 index 0000000000000..bbfb7e46d89ec --- /dev/null +++ b/app/code/Magento/Ui/Test/Mftf/ActionGroup/AdminGridSelectAllActionGroup.xml @@ -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> diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/multiselect.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/multiselect.js index ba0f4d25c25a4..828bbccee0478 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/columns/multiselect.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/multiselect.js @@ -52,6 +52,7 @@ define([ listens: { '${ $.provider }:params.filters': 'onFilter', + '${ $.provider }:params.search': 'onSearch', selected: 'onSelectedChange', rows: 'onRowsChange' }, @@ -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(); }, /** @@ -496,6 +497,13 @@ define([ if (!this.preserveSelectionsOnFilter) { this.deselectAll(); } + }, + + /** + * Is invoked when search is applied or removed + */ + onSearch: function () { + this.onFilter(); } }); }); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/multiselect.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/multiselect.test.js index de3387e31af88..5975f21e08070 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/multiselect.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/multiselect.test.js @@ -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([{