Skip to content

Commit 13db0b1

Browse files
author
Alexander Akimov
authored
Merge pull request #608 from magento-qmt/FT-PR-1
[Epam] Extend functional test coverage
2 parents 78ef991 + 762fbd4 commit 13db0b1

File tree

66 files changed

+2413
-110
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2413
-110
lines changed

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/CategoryForm.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@
9090
<input>input</input>
9191
<selector>input[name='url_key']</selector>
9292
</url_key>
93+
<use_default_url_key>
94+
<input>checkbox</input>
95+
<selector>input[name='use_default[url_key]']</selector>
96+
</use_default_url_key>
9397
<meta_title>
9498
<input>input</input>
9599
<selector>input[name='meta_title']</selector>

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/PageActions.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,39 @@
77
namespace Magento\Catalog\Test\Block\Adminhtml\Category\Edit;
88

99
use Magento\Backend\Test\Block\FormPageActions;
10+
use Magento\Mtf\Client\Locator;
1011

1112
/**
1213
* Category page actions.
1314
*/
1415
class PageActions extends FormPageActions
1516
{
17+
/**
18+
* Top page element to implement a scrolling in case of floating blocks overlay.
19+
*/
20+
const TOP_ELEMENT_TO_SCROLL = '.page-title';
21+
1622
/**
1723
* Locator for "OK" button in warning block
1824
*
1925
* @var string
2026
*/
2127
protected $warningBlock = '.ui-widget-content .ui-dialog-buttonset button:first-child';
2228

29+
/**
30+
* Change Store View selector.
31+
*
32+
* @var string
33+
*/
34+
protected $storeChangeButton = '#store-change-button';
35+
36+
/**
37+
* Selector for confirm.
38+
*
39+
* @var string
40+
*/
41+
protected $confirmModal = '.confirm._show[data-role=modal]';
42+
2343
/**
2444
* Click on "Save" button
2545
*
@@ -33,4 +53,23 @@ public function save()
3353
$warningBlock->click();
3454
}
3555
}
56+
57+
/**
58+
* Select Store View.
59+
*
60+
* @param string $name
61+
* @return void
62+
*/
63+
public function selectStoreView($name)
64+
{
65+
$this->browser->find(self::TOP_ELEMENT_TO_SCROLL)->click();
66+
$this->_rootElement->find($this->storeChangeButton)->click();
67+
$this->waitForElementVisible($name, Locator::SELECTOR_LINK_TEXT);
68+
$this->_rootElement->find($name, Locator::SELECTOR_LINK_TEXT)->click();
69+
$element = $this->browser->find($this->confirmModal);
70+
/** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */
71+
$modal = $this->blockFactory->create(\Magento\Ui\Test\Block\Adminhtml\Modal::class, ['element' => $element]);
72+
$modal->acceptAlert();
73+
$this->waitForElementVisible($this->storeChangeButton);
74+
}
3675
}

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Tree.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ class Tree extends Block
6060
*/
6161
protected $header = 'header';
6262

63+
/**
64+
* Xpath locator for category in tree.
65+
*
66+
* @var string
67+
*/
68+
protected $categoryInTree = '//*[@class="x-tree-node-ct"]/li/div/a/span[contains(text(), "%s")]/..';
69+
6370
/**
6471
* Get backend abstract block.
6572
*
@@ -153,6 +160,26 @@ public function isCategoryVisible(Category $category)
153160
->isElementVisible($categoryPath);
154161
}
155162

163+
/**
164+
* Assign child category to the parent.
165+
*
166+
* @param string $parentCategoryName
167+
* @param string $childCategoryName
168+
*
169+
* @return void
170+
*/
171+
public function assignCategory($parentCategoryName, $childCategoryName)
172+
{
173+
$this->_rootElement->find(sprintf($this->categoryInTree, $childCategoryName), Locator::SELECTOR_XPATH)->click();
174+
$this->getTemplateBlock()->waitLoader();
175+
$targetElement = $this->_rootElement->find(
176+
sprintf($this->categoryInTree, $parentCategoryName),
177+
Locator::SELECTOR_XPATH
178+
);
179+
$this->_rootElement->find(sprintf($this->categoryInTree, $childCategoryName), Locator::SELECTOR_XPATH)
180+
->dragAndDrop($targetElement);
181+
}
182+
156183
/**
157184
* Expand all categories tree.
158185
*

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

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414
use Magento\Mtf\Client\Locator;
1515
use Magento\Mtf\Fixture\FixtureInterface;
1616
use Magento\Ui\Test\Block\Adminhtml\DataGrid;
17+
use Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\ProductDetails\NewCategoryIds;
1718

1819
/**
1920
* Product form on backend product page.
21+
*
22+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2023
*/
2124
class ProductForm extends FormSections
2225
{
@@ -48,6 +51,13 @@ class ProductForm extends FormSections
4851
*/
4952
protected $attributeBlock = '[data-index="%s"]';
5053

54+
/**
55+
* NewCategoryIds block selector.
56+
*
57+
* @var string
58+
*/
59+
protected $newCategoryModalForm = '.product_form_product_form_create_category_modal';
60+
5161
/**
5262
* Magento form loader.
5363
*
@@ -70,8 +80,6 @@ class ProductForm extends FormSections
7080
* @param FixtureInterface|null $category
7181
* @return $this
7282
* @throws \Exception
73-
*
74-
* @SuppressWarnings(PHPMD.NPathComplexity)
7583
*/
7684
public function fill(FixtureInterface $product, SimpleElement $element = null, FixtureInterface $category = null)
7785
{
@@ -88,9 +96,14 @@ public function fill(FixtureInterface $product, SimpleElement $element = null, F
8896
$this->callRender($typeId, 'fill', $renderArguments);
8997
} else {
9098
$sections = $this->getFixtureFieldsByContainers($product);
91-
99+
$category = $product->hasData('category_ids')
100+
? $product->getDataFieldConfig('category_ids')['source']->getCategories()[0] : $category;
92101
if ($category) {
93-
$sections['product-details']['category_ids']['value'] = $category->getName();
102+
if ((int)$category->getId()) {
103+
$sections['product-details']['category_ids']['value'] = $category->getName();
104+
} else {
105+
$this->getNewCategoryModalForm()->addNewCategory($category);
106+
}
94107
}
95108
$this->fillContainers($sections, $element);
96109
}
@@ -193,6 +206,19 @@ public function getAttributeForm()
193206
);
194207
}
195208

209+
/**
210+
* Get New Category Modal Form.
211+
*
212+
* @return NewCategoryIds
213+
*/
214+
public function getNewCategoryModalForm()
215+
{
216+
return $this->blockFactory->create(
217+
\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\ProductDetails\NewCategoryIds::class,
218+
['element' => $this->browser->find($this->newCategoryModalForm)]
219+
);
220+
}
221+
196222
/**
197223
* Get attribute element.
198224
*

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ProductList/TopToolbar.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,11 @@ public function getSelectSortType()
3636
/**
3737
* Get all available method of sorting product
3838
*
39-
* @return array|string
39+
* @return array
4040
*/
4141
public function getSortType()
4242
{
4343
$content = $this->_rootElement->find($this->sorter)->getText();
44-
preg_match_all('/\w+\s?\w+/', $content, $matches);
45-
return $matches[0];
44+
return explode("\n", $content);
4645
}
4746
}

dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<field name="use_config_price_range" is_required="0" group="display_setting" />
4242
<field name="layered_navigation_price_step" is_required="0" group="display_setting" />
4343
<field name="url_key" group="seo" />
44+
<field name="use_default_url_key" group="seo" />
4445
<field name="meta_title" is_required="" group="seo" />
4546
<field name="meta_keywords" is_required="" group="seo" />
4647
<field name="meta_description" is_required="" group="seo" />

0 commit comments

Comments
 (0)