Skip to content

Commit bdb32d7

Browse files
author
sdzhepa
committed
MAGETWO-59308: Design theme dropdown does not display all themes in Widgets
- fix-rewrite test after CR
1 parent 982731a commit bdb32d7

File tree

13 files changed

+220
-102
lines changed

13 files changed

+220
-102
lines changed

dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/WidgetGrid.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,20 @@
77
namespace Magento\Widget\Test\Block\Adminhtml\Widget;
88

99
use Magento\Backend\Test\Block\Widget\Grid as AbstractGrid;
10+
use Magento\Mtf\Client\Locator;
1011

1112
/**
1213
* Widget grid on the Widget Instance Index page.
1314
*/
1415
class WidgetGrid extends AbstractGrid
1516
{
17+
/**
18+
* Selector for not empty options at select element.
19+
*
20+
* @var string
21+
*/
22+
private $notEmptyOptionsSelector = 'option:not([value=""])';
23+
1624
/**
1725
* Locator value for link in action column.
1826
*
@@ -41,4 +49,23 @@ class WidgetGrid extends AbstractGrid
4149
'input' => 'select',
4250
],
4351
];
52+
53+
/**
54+
* Returns values of theme_id filter.
55+
*
56+
* @return array
57+
*/
58+
public function getThemeIdValues()
59+
{
60+
$values = [];
61+
$themeFilter = $this->filters['theme_id'];
62+
$strategy = empty($themeFilter['strategy']) ? Locator::SELECTOR_CSS : $themeFilter['strategy'];
63+
$element = $this->_rootElement->find($themeFilter['selector'], $strategy, $themeFilter['input']);
64+
$options = $element->getElements($this->notEmptyOptionsSelector);
65+
foreach ($options as $option) {
66+
$values[] = $option->getText();
67+
}
68+
69+
return $values;
70+
}
4471
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Widget\Test\Constraint;
8+
9+
use Magento\Mtf\Constraint\AbstractConstraint;
10+
use Magento\Widget\Test\Fixture\Widget;
11+
use Magento\Widget\Test\Page\Adminhtml\WidgetInstanceIndex;
12+
13+
/**
14+
* Assert theme filter contains all possible values from created widgets.
15+
*/
16+
class AssertThemeFilterValuesOnWidgetGrid extends AbstractConstraint
17+
{
18+
/**
19+
* Assert theme filter contains all possible values from created widgets.
20+
*
21+
* @param Widget[] $widgets
22+
* @param WidgetInstanceIndex $widgetInstanceIndex
23+
* @return void
24+
*/
25+
public function processAssert(array $widgets, WidgetInstanceIndex $widgetInstanceIndex)
26+
{
27+
$expectedValues = [];
28+
foreach ($widgets as $widget) {
29+
$expectedValues[] = $widget->getThemeId();
30+
}
31+
$widgetInstanceIndex->open();
32+
$actualValues = $widgetInstanceIndex->getWidgetGrid()->getThemeIdValues();
33+
\PHPUnit_Framework_Assert::assertEmpty(
34+
array_diff($expectedValues, $actualValues),
35+
'Widget grid theme filter doesn\'t contain all possible values from created widgets.'
36+
);
37+
}
38+
39+
/**
40+
* Returns a string representation of the object.
41+
*
42+
* @return string
43+
*/
44+
public function toString()
45+
{
46+
return 'Widget grid theme filter contains all possible values from created widgets.';
47+
}
48+
}

dev/tests/functional/tests/app/Magento/Widget/Test/Constraint/AssertWidgetInGrid.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Magento\Mtf\Constraint\AbstractConstraint;
1212

1313
/**
14-
* Class AssertWidgetInGrid
14+
* Assert widget is present in widget grid.
1515
*/
1616
class AssertWidgetInGrid extends AbstractConstraint
1717
{
@@ -20,15 +20,18 @@ class AssertWidgetInGrid extends AbstractConstraint
2020
/* end tags */
2121

2222
/**
23-
* Assert widget availability in widget grid
23+
* Assert widget availability in widget grid.
24+
* Verifying such fields as:
25+
* - title
26+
* - theme_id
2427
*
2528
* @param Widget $widget
2629
* @param WidgetInstanceIndex $widgetInstanceIndex
2730
* @return void
2831
*/
2932
public function processAssert(Widget $widget, WidgetInstanceIndex $widgetInstanceIndex)
3033
{
31-
$filter = ['title' => $widget->getTitle()];
34+
$filter = ['title' => $widget->getTitle(), 'theme_id' => $widget->getThemeId()];
3235
$widgetInstanceIndex->open();
3336
\PHPUnit_Framework_Assert::assertTrue(
3437
$widgetInstanceIndex->getWidgetGrid()->isRowVisible($filter),
@@ -37,7 +40,7 @@ public function processAssert(Widget $widget, WidgetInstanceIndex $widgetInstanc
3740
}
3841

3942
/**
40-
* Returns a string representation of the object
43+
* Returns a string representation of the object.
4144
*
4245
* @return string
4346
*/

dev/tests/functional/tests/app/Magento/Widget/Test/Constraint/AssertWidgetWithDifferentThemesArePresentedInGrid.php

Lines changed: 0 additions & 63 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Widget\Test\Constraint;
8+
9+
use Magento\Mtf\Constraint\AbstractConstraint;
10+
use Magento\Widget\Test\Fixture\Widget;
11+
use Magento\Widget\Test\Page\Adminhtml\WidgetInstanceIndex;
12+
13+
/**
14+
* Assert widgets are present in widget grid.
15+
*/
16+
class AssertWidgetsInGrid extends AbstractConstraint
17+
{
18+
/**
19+
* Assert widgets are present in widget grid.
20+
* Verifying such fields as:
21+
* - title
22+
* - theme_id
23+
*
24+
* @param Widget[] $widgets
25+
* @param WidgetInstanceIndex $widgetInstanceIndex
26+
* @param AssertWidgetInGrid $assertWidgetInGrid
27+
* @return void
28+
*/
29+
public function processAssert(
30+
array $widgets,
31+
WidgetInstanceIndex $widgetInstanceIndex,
32+
AssertWidgetInGrid $assertWidgetInGrid
33+
) {
34+
foreach ($widgets as $widget) {
35+
$assertWidgetInGrid->processAssert($widget, $widgetInstanceIndex);
36+
}
37+
}
38+
39+
/**
40+
* Returns a string representation of the object.
41+
*
42+
* @return string
43+
*/
44+
public function toString()
45+
{
46+
return 'Widgets are present in widget grid.';
47+
}
48+
}

dev/tests/functional/tests/app/Magento/Widget/Test/Handler/Widget/Curl.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class Curl extends AbstractCurl
2727
protected $mappingData = [
2828
'code' => [
2929
'CMS Page Link' => 'cms_page_link',
30+
'Recently Viewed Products' => 'recently_viewed',
3031
],
3132
'block' => [
3233
'Main Content Area' => 'content',

dev/tests/functional/tests/app/Magento/Widget/Test/Repository/Widget.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
<item name="dataset" xsi:type="string">cmsPageLink</item>
2626
</field>
2727
</dataset>
28-
<dataset name="simple_widget">
28+
29+
<dataset name="recently_viewed_products_on_blank_theme">
2930
<field name="code" xsi:type="string">Recently Viewed Products</field>
3031
<field name="title" xsi:type="string">Title_%isolation%</field>
3132
<field name="theme_id" xsi:type="string">Magento Blank</field>

dev/tests/functional/tests/app/Magento/Widget/Test/TestCase/AbstractCreateWidgetEntityTest.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
namespace Magento\Widget\Test\TestCase;
88

9-
use Magento\Mtf\Fixture\FixtureFactory;
109
use Magento\Widget\Test\Page\Adminhtml\WidgetInstanceEdit;
1110
use Magento\Widget\Test\Page\Adminhtml\WidgetInstanceIndex;
1211
use Magento\Widget\Test\Page\Adminhtml\WidgetInstanceNew;
@@ -54,11 +53,6 @@ abstract class AbstractCreateWidgetEntityTest extends Injectable
5453
*/
5554
protected $cache;
5655

57-
/**
58-
* @var FixtureFactory
59-
*/
60-
protected $fixtureFactory;
61-
6256
/**
6357
* Injection data.
6458
*
@@ -67,22 +61,20 @@ abstract class AbstractCreateWidgetEntityTest extends Injectable
6761
* @param WidgetInstanceEdit $widgetInstanceEdit
6862
* @param CmsIndex $cmsIndex
6963
* @param Cache $cache
70-
* @param FixtureFactory $fixtureFactory
64+
* @return void
7165
*/
7266
public function __inject(
7367
WidgetInstanceIndex $widgetInstanceIndex,
7468
WidgetInstanceNew $widgetInstanceNew,
7569
WidgetInstanceEdit $widgetInstanceEdit,
7670
CmsIndex $cmsIndex,
77-
Cache $cache,
78-
FixtureFactory $fixtureFactory
71+
Cache $cache
7972
) {
8073
$this->widgetInstanceIndex = $widgetInstanceIndex;
8174
$this->widgetInstanceNew = $widgetInstanceNew;
8275
$this->widgetInstanceEdit = $widgetInstanceEdit;
8376
$this->cmsIndex = $cmsIndex;
8477
$this->cache = $cache;
85-
$this->fixtureFactory = $fixtureFactory;
8678
}
8779

8880
/**

dev/tests/functional/tests/app/Magento/Widget/Test/TestCase/CreateWidgetEntityTest.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ class CreateWidgetEntityTest extends AbstractCreateWidgetEntityTest
2525
{
2626
/* tags */
2727
const MVP = 'yes';
28-
const SEVERITY = 'S3';
28+
const TEST_TYPE = 'extended_acceptance_test';
29+
const SEVERITY = 'S1';
2930
/* end tags */
3031

3132
/**
@@ -39,11 +40,10 @@ class CreateWidgetEntityTest extends AbstractCreateWidgetEntityTest
3940
* Create for New Widget.
4041
*
4142
* @param Widget $widget
42-
* @param array $additionalWidgets
4343
* @param array $caches [optional]
44-
* @return array
44+
* @return void
4545
*/
46-
public function test(Widget $widget, array $additionalWidgets = [], array $caches = [])
46+
public function test(Widget $widget, array $caches = [])
4747
{
4848
// Preconditions
4949
$this->caches = $caches;
@@ -54,14 +54,6 @@ public function test(Widget $widget, array $additionalWidgets = [], array $cache
5454
$this->widgetInstanceIndex->getPageActionsBlock()->addNew();
5555
$this->widgetInstanceNew->getWidgetForm()->fill($widget);
5656
$this->widgetInstanceEdit->getPageActionsBlock()->save();
57-
58-
foreach ($additionalWidgets as $key => $additionalWidget) {
59-
$additionalWidget = $this->fixtureFactory->createByCode('widget', ['dataset' => $additionalWidget]);
60-
$additionalWidget->persist();
61-
$additionalWidgets[$key] = $additionalWidget;
62-
}
63-
64-
return ['additionalWidgets' => $additionalWidgets];
6557
}
6658

6759
/**

dev/tests/functional/tests/app/Magento/Widget/Test/TestCase/CreateWidgetEntityTest.xml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,5 @@
118118
<constraint name="Magento\Widget\Test\Constraint\AssertWidgetSuccessSaveMessage" />
119119
<constraint name="Magento\Widget\Test\Constraint\AssertWidgetCatalogNewProductsList" />
120120
</variation>
121-
<variation name="CreateWidgetEntityTestWithDifferentThemes">
122-
<data name="tag" xsi:type="string">severity:S3</data>
123-
<data name="widget/data/code" xsi:type="string">Recently Viewed Products</data>
124-
<data name="widget/data/theme_id" xsi:type="string">Magento Blank</data>
125-
<data name="widget/data/title" xsi:type="string">Title_%isolation%</data>
126-
<data name="widget/data/store_ids/dataset" xsi:type="string">all_store_views</data>
127-
<data name="widget/data/widget_instance/dataset" xsi:type="string">for_viewed_products</data>
128-
<data name="widget/data/parameters/dataset" xsi:type="string">recentlyViewedProducts</data>
129-
<data name="additionalWidgets/0" xsi:type="string">simple_widget</data>
130-
<constraint name="Magento\Widget\Test\Constraint\AssertWidgetWithDifferentThemesArePresentedInGrid" />
131-
</variation>
132121
</testCase>
133122
</config>

0 commit comments

Comments
 (0)