Skip to content

Commit c770e46

Browse files
committed
ACP2E-464: Remove wildcard and LIKE operator and replace with equal operator in customer grid filter search
1 parent fc2f50a commit c770e46

File tree

5 files changed

+162
-15
lines changed

5 files changed

+162
-15
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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="AdminCustomerGridApplyInputFilterActionGroup">
12+
<annotations>
13+
<description>Filters the Admin Customers grid by attribute.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="name" type="string"/>
17+
<argument name="value" type="string"/>
18+
</arguments>
19+
20+
<click selector="{{AdminCustomerFiltersSection.filtersButton}}" stepKey="openFilters"/>
21+
<conditionalClick selector="{{AdminCustomerFiltersSection.clearAll}}" dependentSelector="{{AdminCustomerFiltersSection.clearAll}}" visible="true" stepKey="clickClearFilters"/>
22+
<waitForPageLoad stepKey="waitForClearFilters"/>
23+
<fillField selector="{{AdminCustomerFiltersSection.genericInput(name)}}" userInput="{{value}}" stepKey="fillInValue"/>
24+
<click selector="{{AdminCustomerFiltersSection.apply}}" stepKey="clickApplyFilters"/>
25+
<waitForPageLoad stepKey="waitForPageToLoad"/>
26+
</actionGroup>
27+
</actionGroups>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@
2020
<element name="viewBookmark" type="button" selector="//div[contains(@class, 'admin__data-grid-action-bookmarks')]/ul/li/div/a[text() = '{{label}}']" parameterized="true" timeout="30"/>
2121
<element name="countryOptions" type="button" selector=".admin__data-grid-filters select[name=billing_country_id] option"/>
2222
<element name="websiteOptions" type="button" selector=".admin__data-grid-filters select[name=website_id] option"/>
23+
<element name="genericInput" type="input" selector="input[name={{name}}]" parameterized="true"/>
2324
</section>
2425
</sections>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Customer\Test\Unit\Ui\Component\Listing\Filter;
9+
10+
use Magento\Customer\Ui\Component\Listing\Filter\TextFilterConfigProvider;
11+
use PHPUnit\Framework\TestCase;
12+
13+
class TextFilterConfigProviderTest extends TestCase
14+
{
15+
/**
16+
* @dataProvider getConfigDataProvider
17+
*/
18+
public function testGetConfig(array $input, array $output): void
19+
{
20+
$model = new TextFilterConfigProvider();
21+
$this->assertEquals($output, $model->getConfig($input));
22+
}
23+
24+
/**
25+
* @return array[]
26+
*/
27+
public function getConfigDataProvider(): array
28+
{
29+
return [
30+
[
31+
[],
32+
[
33+
'conditionType' => 'like'
34+
]
35+
],
36+
[
37+
[
38+
'grid_filter_condition_type' => 0
39+
],
40+
[
41+
'conditionType' => 'like'
42+
]
43+
],
44+
[
45+
[
46+
'grid_filter_condition_type' => 1
47+
],
48+
[
49+
'conditionType' => 'eq'
50+
]
51+
]
52+
];
53+
}
54+
}
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminAssertGridEmptyActionGroup">
11+
<waitForLoadingMaskToDisappear stepKey="waitForGridLoaded"/>
12+
<see selector="{{AdminDataGridTableSection.dataGridEmpty}}" userInput="We couldn't find any records." stepKey="expectEmptyGrid"/>
13+
</actionGroup>
14+
</actionGroups>

app/code/Magento/Ui/Test/Unit/Component/Filters/Type/InputTest.php

Lines changed: 66 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ public function testGetComponentName(): void
8585
/**
8686
* Run test prepare method
8787
*
88-
* @param string $name
88+
* @param array $data
8989
* @param array $filterData
9090
* @param array|null $expectedCondition
9191
* @dataProvider getPrepareDataProvider
9292
* @return void
9393
*/
94-
public function testPrepare(string $name, array $filterData, ?array $expectedCondition): void
94+
public function testPrepare(array $data, array $filterData, ?array $expectedCondition): void
9595
{
9696
$processor = $this->getMockBuilder(Processor::class)
9797
->disableOriginalConstructor()
@@ -131,23 +131,23 @@ public function testPrepare(string $name, array $filterData, ?array $expectedCon
131131

132132
$this->uiComponentFactory->expects($this->any())
133133
->method('create')
134-
->with($name, Input::COMPONENT, ['context' => $this->contextMock])
134+
->with($data['name'], Input::COMPONENT, ['context' => $this->contextMock])
135135
->willReturn($uiComponent);
136136

137137
if ($expectedCondition !== null) {
138138
$this->filterBuilderMock->expects($this->once())
139139
->method('setConditionType')
140-
->with('like')
140+
->with($expectedCondition['setConditionType'])
141141
->willReturnSelf();
142142

143143
$this->filterBuilderMock->expects($this->once())
144144
->method('setField')
145-
->with($name)
145+
->with($data['name'])
146146
->willReturnSelf();
147147

148148
$this->filterBuilderMock->expects($this->once())
149149
->method('setValue')
150-
->with($expectedCondition['like'])
150+
->with($expectedCondition['setValue'])
151151
->willReturnSelf();
152152

153153
$filterMock = $this->getMockBuilder(Filter::class)
@@ -165,7 +165,7 @@ public function testPrepare(string $name, array $filterData, ?array $expectedCon
165165
$this->filterBuilderMock,
166166
$this->filterModifierMock,
167167
[],
168-
['name' => $name]
168+
$data
169169
);
170170

171171
$date->prepare();
@@ -178,29 +178,80 @@ public function getPrepareDataProvider(): array
178178
{
179179
return [
180180
[
181-
'test_date',
181+
[
182+
'name' => 'test_date',
183+
],
182184
['test_date' => ''],
183185
null,
184186
],
185187
[
186-
'test_date',
188+
[
189+
'name' => 'test_date',
190+
],
187191
['test_date' => null],
188192
null,
189193
],
190194
[
191-
'test_date',
195+
[
196+
'name' => 'test_date',
197+
],
192198
['test_date' => '0'],
193-
['like' => '%0%'],
199+
[
200+
'setConditionType' => 'like',
201+
'setValue' => '%0%',
202+
],
194203
],
195204
[
196-
'test_date',
205+
[
206+
'name' => 'test_date',
207+
],
197208
['test_date' => 'some_value'],
198-
['like' => '%some\_value%'],
209+
[
210+
'setConditionType' => 'like',
211+
'setValue' => '%some\_value%',
212+
],
199213
],
200214
[
201-
'test_date',
215+
[
216+
'name' => 'test_date',
217+
],
202218
['test_date' => '%'],
203-
['like' => '%\%%'],
219+
[
220+
'setConditionType' => 'like',
221+
'setValue' => '%\%%',
222+
],
223+
],
224+
[
225+
[
226+
'name' => 'text_attr',
227+
'config' => [
228+
'filter' => [
229+
'filterType' => 'text',
230+
'conditionType' => 'eq',
231+
]
232+
]
233+
],
234+
['text_attr' => 'something'],
235+
[
236+
'setConditionType' => 'eq',
237+
'setValue' => 'something',
238+
],
239+
],
240+
[
241+
[
242+
'name' => 'text_attr',
243+
'config' => [
244+
'filter' => [
245+
'filterType' => 'text',
246+
'conditionType' => 'like',
247+
]
248+
]
249+
],
250+
['text_attr' => 'something'],
251+
[
252+
'setConditionType' => 'like',
253+
'setValue' => '%something%',
254+
],
204255
],
205256
];
206257
}

0 commit comments

Comments
 (0)