Skip to content

Commit 9e70968

Browse files
committed
MTA-552: Re-factor Test for Create Product with New Category
- Fixed fill category on product page
1 parent 25568d3 commit 9e70968

File tree

5 files changed

+19
-22
lines changed

5 files changed

+19
-22
lines changed

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/AttributeForm.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function __construct(
5252
BrowserInterface $browser,
5353
XmlConverter $xmlConverter,
5454
array $config = []
55-
){
55+
) {
5656
parent::__construct($element, $mapper, $blockFactory, $browser, $xmlConverter, $config);
5757
$this->browser->switchToFrame(new Locator($this->iFrame));
5858
}

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/ProductDetails.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ class ProductDetails extends ProductTab
3030
*/
3131
protected $categoryFollowingSibling = '//*[@id="attribute-category_ids-container"]/following-sibling::div[%d]';
3232

33+
/**
34+
* Locator for following sibling of category element.
35+
*
36+
* @var string
37+
*/
38+
protected $newCategoryRootElement = 'body';
39+
3340
/**
3441
* Fill data to fields on tab.
3542
*
@@ -48,7 +55,7 @@ public function fillFormTab(array $fields, SimpleElement $element = null)
4855
) {
4956
$this->blockFactory->create(
5057
'Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\ProductDetails\NewCategoryIds',
51-
['element' => $this->browser->find('body')]
58+
['element' => $this->browser->find($this->newCategoryRootElement)]
5259
)->addNewCategory($fields['category_ids']['source']->getCategories()[0]);
5360
} else {
5461
$this->_fill([$data['category_ids']], $element);

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/ProductDetails/NewCategoryIds.php

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

77
namespace Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\ProductDetails;
88

9-
use Magento\Mtf\Client\Locator;
109
use Magento\Catalog\Test\Fixture\Category;
1110
use Magento\Backend\Test\Block\Widget\Form;
1211

@@ -51,32 +50,18 @@ class NewCategoryIds extends Form
5150
*/
5251
public function addNewCategory(Category $category)
5352
{
54-
$parentCategory = $category->getDataFieldConfig('parent_id')['source']->getParentCategory()->getName();
53+
$data = [
54+
'name' => $category->getName(),
55+
'parent_category' => $category->getDataFieldConfig('parent_id')['source']->getParentCategory()->getName()
56+
];
5557

5658
$this->openNewCategoryDialog();
57-
$this->fill($category);
58-
59-
$this->selectParentCategory($parentCategory);
59+
$this->_fill($this->dataMapping($data));
6060

6161
$this->_rootElement->find($this->createCategoryButton)->click();
6262
$this->waitForElementNotVisible($this->createCategoryButton);
6363
}
6464

65-
/**
66-
* Select parent category for new one.
67-
*
68-
* @param string $categoryName
69-
* @return void
70-
*/
71-
protected function selectParentCategory($categoryName)
72-
{
73-
$this->_rootElement->find(
74-
$this->parentCategoryBlock,
75-
Locator::SELECTOR_CSS,
76-
'\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\ProductDetails\ParentCategoryIds'
77-
)->setValue($categoryName);
78-
}
79-
8065
/**
8166
* Open new category dialog.
8267
*

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/ProductDetails/NewCategoryIds.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,9 @@
1010
<name>
1111
<selector>[name="new_category_name"]</selector>
1212
</name>
13+
<parent_category>
14+
<selector>.field-new_category_parent</selector>
15+
<class>Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\ProductDetails\ParentCategoryIds</class>
16+
</parent_category>
1317
</fields>
1418
</mapping>

dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class CreateConfigurableProductEntityTest extends Injectable
4040
{
4141
/* tags */
4242
const TEST_TYPE = 'acceptance_test';
43+
const STABLE = 'no';
4344
const MVP = 'yes';
4445
const DOMAIN = 'MX';
4546
/* end tags */

0 commit comments

Comments
 (0)