Skip to content

Commit

Permalink
Merge pull request #283 from magento-troll/functional_tests
Browse files Browse the repository at this point in the history
[Troll] Functional tests fixes
  • Loading branch information
Ganin, Roman(rganin) committed Jan 14, 2016
2 parents 1db2d56 + 2c6b03e commit b8f61e5
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
</display_mode>
<is_anchor>
<input>switcher</input>
<selector>input[name='is_anchor']]</selector>
<selector>input[name='is_anchor']</selector>
</is_anchor>
<available_product_listing_config>
<input>checkbox</input>
Expand All @@ -68,14 +68,33 @@
<selector>input[name='use_config[default_sort_by]']</selector>
</default_product_listing_config>
<default_sort_by>
<input>select[name='default_sort_by']</input>
<input>select</input>
<selector>select[name='default_sort_by']</selector>
</default_sort_by>
<use_config_price_range>
<input>checkbox</input>
<selector>input[name='use_config[filter_price_range]']</selector>
</use_config_price_range>
<layered_navigation_price_step>
<input>input</input>
<selector>input[name='filter_price_range']</selector>
</layered_navigation_price_step>
</fields>
</display_setting>
<seo>
<class>\Magento\Ui\Test\Block\Adminhtml\Section</class>
<selector>//div[contains(@class,'admin__collapsible-block-wrapper')][descendant::input[@name='meta_title']]</selector>
<strategy>xpath</strategy>
<fields>
<url_key>
<input>input</input>
<selector>input[name='url_key']</selector>
</url_key>
<meta_title>
<input>input</input>
<selector>input[name='meta_title']</selector>
</meta_title>
</fields>
</seo>
<category_products>
<class>\Magento\Catalog\Test\Block\Adminhtml\Category\Edit\Section\Product</class>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ function () use ($element, $selector) {
$addAttributeToggle->click();
if (!$addAttributeToggle->find($this->newAttributeButton)->isVisible()) {
$element->find($this->searchAttribute, Locator::SELECTOR_XPATH)->click();
$this->browser->waitUntil(
function () {
$element = $this->browser->find($this->searchAttribute, Locator::SELECTOR_XPATH);
return $element->isVisible() == true ? true : null;
}
);
}
$element->find($this->newAttributeButton)->click();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function processAssert(
foreach ($promotedProducts as $promotedProduct) {
\PHPUnit_Framework_Assert::assertFalse(
$checkoutCart->getCrosssellBlock()->getProductItem($promotedProduct)->isVisible(),
'Product \'' . $promotedProduct->getName() . '\' is exist in cross-sell section.'
'Product \'' . $promotedProduct->getName() . '\' exists in cross-sell section.'
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function processAssert(
foreach ($promotedProducts as $promotedProduct) {
\PHPUnit_Framework_Assert::assertFalse(
$catalogProductView->getRelatedProductBlock()->getProductItem($promotedProduct)->isVisible(),
'Product \'' . $promotedProduct->getName() . '\' is exist in related products.'
'Product \'' . $promotedProduct->getName() . '\' exists in related products.'
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function processAssert(
foreach ($promotedProducts as $promotedProduct) {
\PHPUnit_Framework_Assert::assertFalse(
$catalogProductView->getUpsellBlock()->getProductItem($promotedProduct)->isVisible(),
'Product \'' . $promotedProduct->getName() . '\' is exist in up-sells products.'
'Product \'' . $promotedProduct->getName() . '\' exists in up-sells products.'
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ public function processAssert(
$label = $attribute->hasData('manage_frontend_label')
? $attribute->getManageFrontendLabel()
: $attribute->getFrontendLabel();
$filters = $catalogCategoryView->getLayeredNavigationBlock()->getFilters();
\PHPUnit_Framework_Assert::assertTrue(
in_array(strtoupper($label), $catalogCategoryView->getLayeredNavigationBlock()->getFilters()),
in_array(strtoupper($label), $filters),
'Attribute is absent in layered navigation on category page.'
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function processAssert(
}
\PHPUnit_Framework_Assert::assertFalse(
$isProductVisible,
'Product is exist on category page.'
'Product exists on category page.'
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
<testCase name="Magento\Catalog\Test\TestCase\Category\UpdateCategoryEntityTest" summary="Update Category" ticketId="MAGETWO-23290">
<variation name="UpdateCategoryEntityTestVariation1">
<data name="category/data/parent_id/dataset" xsi:type="string">default_category</data>
<data name="category/data/name" xsi:type="string">Name%isolation%</data>
<data name="category/data/is_active" xsi:type="string">Yes</data>
<data name="category/data/url_key" xsi:type="string">UrlKey%isolation%</data>
<data name="category/data/include_in_menu" xsi:type="string">Yes</data>
<data name="category/data/name" xsi:type="string">Name%isolation%</data>
<data name="category/data/available_product_listing_config" xsi:type="string">Yes</data>
<data name="category/data/default_product_listing_config" xsi:type="string">No</data>
<data name="category/data/default_sort_by" xsi:type="string">Name</data>
<data name="category/data/url_key" xsi:type="string">UrlKey%isolation%</data>
<constraint name="Magento\Catalog\Test\Constraint\AssertCategorySaveMessage" />
<constraint name="Magento\Catalog\Test\Constraint\AssertCategoryForm" />
<constraint name="Magento\UrlRewrite\Test\Constraint\AssertUrlRewriteCategoryInGrid" />
Expand All @@ -24,25 +24,25 @@
</variation>
<variation name="UpdateCategoryEntityTestVariation2">
<data name="category/data/parent_id/dataset" xsi:type="string">default_category</data>
<data name="category/data/name" xsi:type="string">Name%isolation%</data>
<data name="category/data/is_active" xsi:type="string">Yes</data>
<data name="category/data/url_key" xsi:type="string">UrlKey%isolation%</data>
<data name="category/data/description" xsi:type="string">Category Description</data>
<data name="category/data/meta_title" xsi:type="string">Category Title</data>
<data name="category/data/include_in_menu" xsi:type="string">Yes</data>
<data name="category/data/name" xsi:type="string">Name%isolation%</data>
<data name="category/data/description" xsi:type="string">Category Description</data>
<data name="category/data/available_product_listing_config" xsi:type="string">No</data>
<data name="category/data/available_sort_by/sort_2" xsi:type="string">Position</data>
<data name="category/data/available_sort_by/sort_1" xsi:type="string">Price</data>
<data name="category/data/default_product_listing_config" xsi:type="string">Yes</data>
<data name="category/data/url_key" xsi:type="string">UrlKey%isolation%</data>
<data name="category/data/meta_title" xsi:type="string">Category Title</data>
<constraint name="Magento\Catalog\Test\Constraint\AssertCategorySaveMessage" />
<constraint name="Magento\Catalog\Test\Constraint\AssertCategoryForm" />
<constraint name="Magento\UrlRewrite\Test\Constraint\AssertUrlRewriteCategoryInGrid" />
<constraint name="Magento\Catalog\Test\Constraint\AssertCategoryPage" />
</variation>
<variation name="UpdateCategoryEntityTestVariation3">
<data name="category/data/parent_id/dataset" xsi:type="string">default_category</data>
<data name="category/data/name" xsi:type="string">Name%isolation%</data>
<data name="category/data/is_active" xsi:type="string">No</data>
<data name="category/data/name" xsi:type="string">Name%isolation%</data>
<constraint name="Magento\Catalog\Test\Constraint\AssertCategorySaveMessage" />
<constraint name="Magento\Catalog\Test\Constraint\AssertCategoryForm" />
</variation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<data name="attribute/data/is_global" xsi:type="string">Global</data>
<data name="attribute/data/is_filterable" xsi:type="string">Filterable (with results)</data>
<data name="attribute/data/is_filterable_in_search" xsi:type="string">Yes</data>
<data name="attributeValue" xsi:type="string">white</data>
<data name="assertProduct/data/name" xsi:type="string">Product name</data>
<data name="assertProduct/data/sku" xsi:type="string">product-sku</data>
<data name="assertProduct/data/price" xsi:type="string">35</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,30 @@ class SetDefaultAttributeValueStep implements TestStepInterface
*/
protected $catalogProductEdit;

/**
* Custom attribute value to set while product creation.
*
* @var string
*/
protected $attributeValue;

/**
* @constructor
* @param CatalogProductAttribute $attribute
* @param CatalogProductEdit $catalogProductEdit
* @param FixtureFactory $fixtureFactory
* @param string $attributeValue [optional]
*/
public function __construct(
CatalogProductAttribute $attribute,
CatalogProductEdit $catalogProductEdit,
FixtureFactory $fixtureFactory
FixtureFactory $fixtureFactory,
$attributeValue = null
) {
$this->attribute = $attribute;
$this->catalogProductEdit = $catalogProductEdit;
$this->fixtureFactory = $fixtureFactory;
$this->attributeValue = $attributeValue;
}

/**
Expand All @@ -60,9 +70,13 @@ public function __construct(
*/
public function run()
{
$customAttribute = $this->attribute;
if ($this->attributeValue !== null) {
$customAttribute = ['value' => $this->attributeValue, 'attribute' => $customAttribute];
}
$product = $this->fixtureFactory->createByCode(
'catalogProductSimple',
['data' => ['custom_attribute' => $this->attribute]]
['data' => ['custom_attribute' => $customAttribute]]
);
$this->catalogProductEdit->getProductForm()->fill($product);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function processAssert(RatingIndex $ratingIndex, Rating $productRating)
$ratingIndex->open();
\PHPUnit_Framework_Assert::assertFalse(
$ratingIndex->getRatingGrid()->isRowVisible($filter),
"Product Rating " . $productRating->getRatingCode() . " is exist on product Rating grid."
"Product Rating " . $productRating->getRatingCode() . " exists on product Rating grid."
);
}

Expand Down

0 comments on commit b8f61e5

Please sign in to comment.