Skip to content

Commit ba2e1ac

Browse files
committed
Fixing fucntional tests after grid updates
1 parent e45bca1 commit ba2e1ac

File tree

5 files changed

+44
-12
lines changed

5 files changed

+44
-12
lines changed

app/code/Magento/Customer/Model/ResourceModel/Group/Collection.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
*/
1313
class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
1414
{
15+
/**
16+
* @var string
17+
*/
18+
protected $_idFieldName = 'customer_group_id';
19+
1520
/**
1621
* Resource initialization
1722
*

app/code/Magento/Customer/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@
439439
<argument name="mainTable" xsi:type="string">customer_group</argument>
440440
<argument name="eventPrefix" xsi:type="string">customer_group_grid_collection</argument>
441441
<argument name="eventObject" xsi:type="string">customer_group_collection</argument>
442-
<argument name="resourceModel" xsi:type="string">Magento\Customer\Model\ResourceModel\Group\Collection</argument>
442+
<argument name="resourceModel" xsi:type="string">Magento\Customer\Model\ResourceModel\Group</argument>
443443
</arguments>
444444
</type>
445445
</config>

dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Group/CustomerGroupGrid.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,44 @@
66

77
namespace Magento\Customer\Test\Block\Adminhtml\Group;
88

9-
use Magento\Backend\Test\Block\Widget\Grid;
9+
use \Magento\Ui\Test\Block\Adminhtml\DataGrid;
10+
use Magento\Mtf\Client\Element\SimpleElement;
1011

1112
/**
1213
* Class CustomerGroupGrid
1314
* Adminhtml customer group grid
1415
*/
15-
class CustomerGroupGrid extends Grid
16+
class CustomerGroupGrid extends DataGrid
1617
{
18+
/**
19+
* Select action toggle.
20+
*
21+
* @var string
22+
*/
23+
protected $selectAction = '.action-select';
24+
1725
/**
1826
* Initialize block elements
1927
*
2028
* @var array $filters
2129
*/
2230
protected $filters = [
2331
'code' => [
24-
'selector' => '#customerGroupGrid_filter_type',
32+
'selector' => '.admin__data-grid-filters input[name*=customer_group_code]',
2533
],
2634
];
2735

2836
/**
29-
* Locator value for grid to click
37+
* Click on "Edit" link.
3038
*
31-
* @var string
39+
* @param SimpleElement $rowItem
40+
* @return void
3241
*/
33-
protected $editLink = 'td[data-column="time"]';
42+
protected function clickEditLink(SimpleElement $rowItem)
43+
{
44+
if ($rowItem->find($this->selectAction)->isVisible()) {
45+
$rowItem->find($this->selectAction)->click();
46+
}
47+
$rowItem->find($this->editLink)->click();
48+
}
3449
}

dev/tests/functional/tests/app/Magento/Customer/Test/Handler/CustomerGroup/Curl.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Backend\Test\Handler\Extractor;
1010
use Magento\Mtf\Fixture\FixtureInterface;
1111
use Magento\Mtf\Handler\Curl as AbstractCurl;
12+
use Magento\Mtf\Util\Protocol\CurlInterface;
1213
use Magento\Mtf\Util\Protocol\CurlTransport;
1314
use Magento\Mtf\Util\Protocol\CurlTransport\BackendDecorator;
1415

@@ -59,11 +60,22 @@ public function persist(FixtureInterface $fixture = null)
5960
*/
6061
public function getCustomerGroupId(array $data)
6162
{
62-
$url = 'customer/group/index/sort/time/dir/desc';
63-
$regExp = '/.*id\/(\d+)\/.*' . $data['code'] . '/siu';
64-
$extractor = new Extractor($url, $regExp);
65-
$match = $extractor->getData();
63+
$url = $_ENV['app_backend_url'] . 'mui/index/render/';
64+
$data = [
65+
'namespace' => 'customer_group_listing',
66+
'filters' => [
67+
'placeholder' => true,
68+
'customer_group_code' => $data['code']
69+
],
70+
'isAjax' => true
71+
];
72+
$curl = new BackendDecorator(new CurlTransport(), $this->_configuration);
73+
74+
$curl->write($url, $data, CurlInterface::POST);
75+
$response = $curl->read();
76+
$curl->close();
6677

78+
preg_match('/customer_group_listing_data_source.+items.+"customer_group_id":"(\d+)"/', $response, $match);
6779
return empty($match[1]) ? null : $match[1];
6880
}
6981
}

dev/tests/functional/tests/app/Magento/Customer/Test/Page/Adminhtml/CustomerGroupIndex.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
<page name="CustomerGroupIndex" area="Adminhtml" mca="customer/group/index" module="Magento_Customer">
1010
<block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages .messages" strategy="css selector"/>
1111
<block name="gridPageActions" class="Magento\Backend\Test\Block\GridPageActions" locator=".page-main-actions" strategy="css selector"/>
12-
<block name="customerGroupGrid" class="Magento\Customer\Test\Block\Adminhtml\Group\CustomerGroupGrid" locator="#customerGroupGrid" strategy="css selector"/>
12+
<block name="customerGroupGrid" class="Magento\Customer\Test\Block\Adminhtml\Group\CustomerGroupGrid" locator="//div[contains(@data-bind, 'customer_group_listing')]" strategy="xpath"/>
1313
</page>
1414
</config>

0 commit comments

Comments
 (0)