Skip to content

Commit 6183451

Browse files
author
Oleksii Kolesnyk
committed
MTA-2480: Extend Use Advanced Search
- CR Changes
1 parent 342596a commit 6183451

File tree

8 files changed

+28
-46
lines changed

8 files changed

+28
-46
lines changed

dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.xml

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
<data name="productAttribute/data/used_in_product_listing" xsi:type="string">Yes</data>
9999
<constraint name="Magento\Catalog\Test\Constraint\AssertProductAttributeInGrid" />
100100
<constraint name="Magento\Catalog\Test\Constraint\AssertAttributeForm" />
101+
<constraint name="Magento\CatalogSearch\Test\Constraint\AssertAdvancedSearchProductByAttribute" />
101102
<constraint name="Magento\Catalog\Test\Constraint\AssertAddedProductAttributeOnProductForm" />
102103
<constraint name="Magento\Catalog\Test\Constraint\AssertProductAttributeDisplayingOnFrontend" />
103104
<constraint name="Magento\Catalog\Test\Constraint\AssertProductAttributeDisplayingOnSearchForm" />
@@ -186,34 +187,5 @@
186187
<data name="productAttribute/data/is_comparable" xsi:type="string">Yes</data>
187188
<constraint name="Magento\Catalog\Test\Constraint\AssertProductAttributeIsUnique" />
188189
</variation>
189-
<variation name="CreateProductAttributeEntityTestVariation5">
190-
<data name="productTemplate/dataset" xsi:type="string">custom_attribute_set</data>
191-
<data name="productAttribute/data/frontend_label" xsi:type="string">Multiple_Select_Admin_%isolation%</data>
192-
<data name="productAttribute/data/frontend_input" xsi:type="string">Multiple Select</data>
193-
<data name="productAttribute/data/options/dataset" xsi:type="string">default</data>
194-
<data name="productAttribute/data/is_required" xsi:type="string">No</data>
195-
<data name="productAttribute/data/attribute_code" xsi:type="string">attr_multiselect_%isolation%</data>
196-
<data name="productAttribute/data/is_global" xsi:type="string">Website</data>
197-
<data name="productAttribute/data/is_unique" xsi:type="string">Yes</data>
198-
<data name="productAttribute/data/is_searchable" xsi:type="string">Yes</data>
199-
<data name="productAttribute/data/is_visible_in_advanced_search" xsi:type="string">Yes</data>
200-
<data name="productAttribute/data/is_comparable" xsi:type="string">Yes</data>
201-
<data name="productAttribute/data/is_filterable" xsi:type="string">Filterable (with results)</data>
202-
<data name="productAttribute/data/is_filterable_in_search" xsi:type="string">Yes</data>
203-
<data name="productAttribute/data/is_html_allowed_on_front" xsi:type="string">Yes</data>
204-
<data name="productAttribute/data/is_visible_on_front" xsi:type="string">Yes</data>
205-
<data name="productAttribute/data/used_in_product_listing" xsi:type="string">Yes</data>
206-
<constraint name="Magento\Catalog\Test\Constraint\AssertProductAttributeInGrid" />
207-
<constraint name="Magento\Catalog\Test\Constraint\AssertAttributeForm" />
208-
<constraint name="Magento\CatalogSearch\Test\Constraint\AssertAdvancedSearchProductByAttribute" />
209-
<constraint name="Magento\Catalog\Test\Constraint\AssertAddedProductAttributeOnProductForm" />
210-
<constraint name="Magento\Catalog\Test\Constraint\AssertProductAttributeDisplayingOnFrontend" />
211-
<constraint name="Magento\Catalog\Test\Constraint\AssertProductAttributeDisplayingOnSearchForm" />
212-
<constraint name="Magento\Catalog\Test\Constraint\AssertProductAttributeIsComparable" />
213-
<constraint name="Magento\Catalog\Test\Constraint\AssertProductAttributeIsFilterable" />
214-
<constraint name="Magento\Catalog\Test\Constraint\AssertProductAttributeIsFilterableInSearch" />
215-
<constraint name="Magento\CatalogSearch\Test\Constraint\AssertAttributeSearchableByLabel" />
216-
<constraint name="Magento\Catalog\Test\Constraint\AssertAttributeOptionsOnProductForm" />
217-
</variation>
218190
</testCase>
219191
</config>

dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Advanced/CustomAttributeDate.php renamed to dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Advanced/CustomAttribute/Date.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
namespace Magento\CatalogSearch\Test\Block\Advanced;
7+
namespace Magento\CatalogSearch\Test\Block\Advanced\CustomAttribute;
88

99
use Magento\Mtf\Block\Form as BaseForm;
1010
use Magento\Mtf\Fixture\FixtureInterface;
@@ -13,7 +13,7 @@
1313
/**
1414
* Advanced search form with custom Date attribute.
1515
*/
16-
class CustomAttributeDate extends BaseForm
16+
class Date extends BaseForm
1717
{
1818
/**
1919
* Selector for date from input.

dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Advanced/CustomAttributeSelect.php renamed to dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Advanced/CustomAttribute/Select.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
namespace Magento\CatalogSearch\Test\Block\Advanced;
7+
namespace Magento\CatalogSearch\Test\Block\Advanced\CustomAttribute;
88

99
use Magento\Mtf\Block\Form as BaseForm;
1010
use Magento\Mtf\Fixture\FixtureInterface;
@@ -13,7 +13,7 @@
1313
/**
1414
* Advanced search form with custom Select attribute.
1515
*/
16-
class CustomAttributeSelect extends BaseForm
16+
class Select extends BaseForm
1717
{
1818
/**
1919
* Selector for select.

dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Advanced/CustomAttributeText.php renamed to dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Advanced/CustomAttribute/Text.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
namespace Magento\CatalogSearch\Test\Block\Advanced;
7+
namespace Magento\CatalogSearch\Test\Block\Advanced\CustomAttribute;
88

99
use Magento\Mtf\Block\Form as BaseForm;
1010
use Magento\Mtf\Fixture\FixtureInterface;
1111
use Magento\Mtf\Client\Element\SimpleElement;
1212

1313
/**
14-
* Advanced search form with custom Select attribute.
14+
* Advanced search form with custom Text attribute.
1515
*/
16-
class CustomAttributeText extends BaseForm
16+
class Text extends BaseForm
1717
{
1818
/**
1919
* Selector for text input.

dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Advanced/Form.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ class Form extends ParentForm
4646
*/
4747
protected $labelSelector = 'label';
4848

49+
/**
50+
* Selector for custom attribute.
51+
*
52+
* @var string
53+
*/
54+
protected $customAttributeSelector = 'div[class*="%s"]';
55+
4956
/**
5057
* Submit search form.
5158
*
@@ -74,10 +81,15 @@ public function fill(FixtureInterface $fixture, SimpleElement $element = null)
7481

7582
// Mapping
7683
$mapping = $this->dataMapping($data);
84+
$attributeType = $attributeCode = '';
7785
if ($fixture->hasData('custom_attribute')) {
86+
/** @var CatalogProductAttribute $attribute */
7887
$attribute = $fixture->getDataFieldConfig('custom_attribute')['source']->getAttribute();
7988
$attributeType = $attribute->getFrontendInput();
80-
$element = $this->_rootElement->find('div[class*="' . $attribute->getAttributeCode() . '"]');
89+
$attributeCode = $attribute->getAttributeCode();
90+
}
91+
if ($this->hasRender($attributeType)) {
92+
$element = $this->_rootElement->find(sprintf($this->customAttributeSelector, $attributeCode));
8193
$arguments = ['fixture' => $fixture, 'element' => $element, 'mapping' => $mapping];
8294
$this->callRender($attributeType, 'fill', $arguments);
8395
} else {

dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Constraint/AssertAdvancedSearchProductByAttribute.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function processAssert(
4545
) {
4646
$this->fixtureFactory = $fixtureFactory;
4747
$cmsIndex->open();
48-
$cmsIndex->getSearchBlock()->clickAdvancedSearchButton();
48+
$cmsIndex->getFooterBlock()->openAdvancedSearch();
4949
$searchForm = $searchPage->getForm();
5050
$productSearch = $this->prepareFixture($product);
5151

@@ -60,7 +60,7 @@ public function processAssert(
6060
}
6161

6262
/**
63-
* Preparation of fixture data before comparing
63+
* Preparation of fixture data before comparing.
6464
*
6565
* @param InjectableFixture $productSearch
6666
* @return CatalogProductSimple

dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/AdvancedSearch.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/pages.xsd">
99
<page name="AdvancedSearch" mca="catalogsearch/advanced" module="Magento_CatalogSearch">
1010
<block name="form" class="Magento\CatalogSearch\Test\Block\Advanced\Form" locator=".form.search.advanced" strategy="css selector">
11-
<render name="Date" class="Magento\CatalogSearch\Test\Block\Advanced\CustomAttributeDate" />
12-
<render name="Multiple Select" class="Magento\CatalogSearch\Test\Block\Advanced\CustomAttributeSelect" />
13-
<render name="Yes/No" class="Magento\CatalogSearch\Test\Block\Advanced\CustomAttributeSelect" />
14-
<render name="Text Field" class="Magento\CatalogSearch\Test\Block\Advanced\CustomAttributeText" />
15-
<render name="Dropdown" class="Magento\CatalogSearch\Test\Block\Advanced\CustomAttributeSelect" />
11+
<render name="Date" class="Magento\CatalogSearch\Test\Block\Advanced\CustomAttribute\Date" />
12+
<render name="Multiple Select" class="Magento\CatalogSearch\Test\Block\Advanced\CustomAttribute\Select" />
13+
<render name="Yes/No" class="Magento\CatalogSearch\Test\Block\Advanced\CustomAttribute\Select" />
14+
<render name="Text Field" class="Magento\CatalogSearch\Test\Block\Advanced\CustomAttribute\Text" />
15+
<render name="Dropdown" class="Magento\CatalogSearch\Test\Block\Advanced\CustomAttribute\Select" />
1616
</block>
1717
<block name="widgetView" class="Magento\Widget\Test\Block\WidgetView" locator=".widget" strategy="css selector" />
1818
</page>

dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchEntityTest.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@
120120
</variation>
121121
<variation name="AdvancedSearchEntityTestVariation15">
122122
<data name="description" xsi:type="string">Negative product search</data>
123-
<data name="products/simple_1" xsi:type="string">Yes</data>
124-
<data name="products/simple_2" xsi:type="string">-</data>
125123
<data name="productSearch/data/name" xsi:type="string">Negative_product_search</data>
126124
<constraint name="Magento\CatalogSearch\Test\Constraint\AssertAdvancedSearchNoResult" />
127125
</variation>

0 commit comments

Comments
 (0)