Skip to content

Commit

Permalink
Merge pull request magento#442 from magento-tango/MAGETWO-49390-2
Browse files Browse the repository at this point in the history
[Tango] Stabilize MX domain product functional tests
  • Loading branch information
magicbunneh committed Mar 18, 2016
2 parents 4b9c132 + 212c983 commit 044bada
Show file tree
Hide file tree
Showing 48 changed files with 541 additions and 372 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
}
">
<div class="admin__action-multiselect-text"
data-role="selected-option"
data-bind="text: setCaption()">
</div>
</div>
Expand Down Expand Up @@ -121,7 +122,8 @@
">
<!-- ko foreach: { data: options, as: 'option'} -->
<li class="admin__action-multiselect-menu-inner-item _root"
data-bind="css: { _parent: $data.optgroup }">
data-bind="css: { _parent: $data.optgroup }"
data-role="option-group">
<div class="action-menu-item"
data-bind="
css: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use Magento\Mtf\Client\Element\SimpleElement;
use Magento\Bundle\Test\Block\Adminhtml\Catalog\Product\Edit\Section\Bundle\Option;
use Magento\Mtf\Client\Element;
use Magento\Mtf\Client\ElementInterface;
use Magento\Mtf\Client\Locator;
use Magento\Ui\Test\Block\Adminhtml\Section;

/**
Expand All @@ -23,34 +25,47 @@ class Bundle extends Section
*/
protected $addNewOption = 'button[data-index="add_button"]';

/**
* Bundle options locator.
*
* @var string
*/
protected $bundleOptions = './/*[@data-index="bundle_options"]/tbody';

/**
* Open option section.
*
* @var string
*/
protected $openOption = '[data-index="bundle_options"] tbody tr:nth-child(%d) [data-role="collapsible-title"]';
protected $openOption = './tr[%d]//*[@data-role="collapsible-title"]';

/**
* Selector for option content.
*
* @var string
*/
protected $optionContent = '[data-index="bundle_options"] tbody tr:nth-child(%d) [data-role="collapsible-content"]';
protected $optionContent = './tr[%d]//*[@data-role="collapsible-content"]';

/**
* Locator for bundle option row.
*
* @var string
*/
protected $bundleOptionRow = './tr[%d]';

/**
* Get bundle options block.
*
* @param int $blockNumber
* @param int $rowNumber
* @param ElementInterface $element
* @return Option
*/
protected function getBundleOptionBlock($blockNumber)
private function getBundleOptionBlock($rowNumber, ElementInterface $element)
{
return $this->blockFactory->create(
'Magento\Bundle\Test\Block\Adminhtml\Catalog\Product\Edit\Section\Bundle\Option',
[
'element' => $this->_rootElement->find(
sprintf('[data-index="bundle_options"] tbody tr:nth-child(%d)', $blockNumber)
)
'element' => $element->find(sprintf($this->bundleOptionRow, $rowNumber), Locator::SELECTOR_XPATH)
]
);
}
Expand All @@ -68,16 +83,17 @@ public function setFieldsData(array $fields, SimpleElement $element = null)
if (!isset($fields['bundle_selections'])) {
return $this;
}
$context = $this->_rootElement->find($this->bundleOptions, Locator::SELECTOR_XPATH);
foreach ($fields['bundle_selections']['value']['bundle_options'] as $key => $bundleOption) {
$count = $key + 1;
$itemOption = $this->_rootElement->find(sprintf($this->openOption, $count));
$isContent = $this->_rootElement->find(sprintf($this->optionContent, $count))->isVisible();
$itemOption = $context->find(sprintf($this->openOption, $count), Locator::SELECTOR_XPATH);
$isContent = $context->find(sprintf($this->optionContent, $count), Locator::SELECTOR_XPATH)->isVisible();
if ($itemOption->isVisible() && !$isContent) {
$itemOption->click();
} elseif (!$itemOption->isVisible()) {
$this->_rootElement->find($this->addNewOption)->click();
}
$this->getBundleOptionBlock($count)->fillOption($bundleOption);
$this->getBundleOptionBlock($count, $context)->fillOption($bundleOption);
}
return $this;
}
Expand All @@ -96,15 +112,17 @@ public function getFieldsData($fields = null, SimpleElement $element = null)
if (!isset($fields['bundle_selections'])) {
return $this;
}
$index = 0;
$index = 1;
$context = $this->_rootElement->find($this->bundleOptions, Locator::SELECTOR_XPATH);
foreach ($fields['bundle_selections']['value']['bundle_options'] as $key => &$bundleOption) {
if (!$this->_rootElement->find(sprintf($this->optionContent, $key))->isVisible()) {
$this->_rootElement->find(sprintf($this->openOption, $index))->click();
if (!$context->find(sprintf($this->optionContent, $index), Locator::SELECTOR_XPATH)->isVisible()) {
$context->find(sprintf($this->openOption, $index), Locator::SELECTOR_XPATH)->click();
}
foreach ($bundleOption['assigned_products'] as &$product) {
$product['data']['getProductName'] = $product['search_data']['name'];
}
$newFields['bundle_selections'][$key] = $this->getBundleOptionBlock($key)->getOptionData($bundleOption);
$newFields['bundle_selections'][$key] =
$this->getBundleOptionBlock($index, $context)->getOptionData($bundleOption);
$index++;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Option extends Form
*
* @var string
*/
protected $selectionBlock = '[data-index="bundle_selections"] tbody tr:nth-child(%d)';
protected $selectionBlock = '[data-index="bundle_selections"] > tbody > tr:nth-child(%d)';

/**
* Selector for 'Add Products to Option' button.
Expand Down Expand Up @@ -106,7 +106,7 @@ public function getOptionData(array $fields)
$mapping = $this->dataMapping($fields);
$newField = $this->_getData($mapping);
foreach ($fields['assigned_products'] as $key => $field) {
$newField['assigned_products'][$key] = $this->getSelectionBlock($key + 1)->getProductRow($field['data']);
$newField['assigned_products'][$key] = $this->getSelectionBlock($key)->getProductRow($field['data']);
}
return $newField;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@
* See COPYING.txt for license details.
*/
-->
<tabs>
<sections>
<product-details>
<class>\Magento\Ui\Test\Block\Adminhtml\Section</class>
<selector>[data-index='product-details']</selector>
<strategy>css selector</strategy>
<wrapper>product</wrapper>
<fields>
<shipment_type>
<input>select</input>
Expand Down Expand Up @@ -48,4 +44,4 @@
</price_view>
</fields>
</advanced-pricing>
</tabs>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class AssertBundlePriceType extends AbstractConstraint
*
* @var string
*/
protected $productPriceType = 'Dynamic';
protected $productPriceType = 'Yes';

/**
* Assert that displayed price for bundle items on shopping cart page equals to passed from fixture.
Expand Down Expand Up @@ -79,7 +79,6 @@ protected function assertPrice(
$cartItem = $checkoutCartView->getCartBlock()->getCartItem($product);
$specialPrice = 0;


$optionPrice = [];
$fillData = $product->getCheckoutData();
foreach ($fillData['options']['bundle_options'] as $key => $data) {
Expand All @@ -91,7 +90,7 @@ protected function assertPrice(
}
}

$optionPrice[$key]['price'] = $this->productPriceType == 'Fixed'
$optionPrice[$key]['price'] = $this->productPriceType == 'No'
? number_format(
$bundleData['bundle_selections']['bundle_options'][$key]['assigned_products'][$data['value']['key']]
['data']['selection_price_value'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
<field name="description" is_required="0" group="content" />
<field name="enable_googlecheckout" is_required="0" />
<field name="gallery" is_required="0" />
<field name="gift_message_available" is_required="0" group="autosettings" />
<field name="use_config_gift_message_available" is_required="0" group="autosettings" />
<field name="gift_message_available" is_required="0" group="gift-options" />
<field name="use_config_gift_message_available" is_required="0" group="gift-options" />
<field name="has_options" is_required="0" />
<field name="image" is_required="0" />
<field name="image_label" is_required="0" />
Expand Down Expand Up @@ -80,7 +80,7 @@
<field name="updated_at" is_required="1" />
<field name="url_key" is_required="0" group="search-engine-optimization" />
<field name="url_path" is_required="0" />
<field name="visibility" is_required="0" group="autosettings" />
<field name="visibility" is_required="0" group="product-details" />
<field name="id" />
<field name="bundle_selections" is_required="1" group="bundle" source="Magento\Bundle\Test\Fixture\BundleProduct\BundleSelections" repository="Magento\Bundle\Test\Repository\BundleProduct\BundleSelection" />
<field name="checkout_data" is_required="1" group="null" repository="Magento\Bundle\Test\Repository\BundleProduct\CheckoutData" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ public function __construct(DataInterface $configuration, EventManagerInterface
'No' => 0,
],
'sku_type' => [
'Dynamic' => 0,
'Fixed' => 1,
'Yes' => 0,
'No' => 1,
],
'price_type' => [
'Dynamic' => 0,
'Fixed' => 1,
'Yes' => 0,
'No' => 1,
],
'weight_type' => [
'Dynamic' => 0,
'Fixed' => 1,
'Yes' => 0,
'No' => 1,
],
'shipment_type' => [
'Together' => 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<field name="name" xsi:type="string">Bundle dynamic product %isolation%</field>
<field name="url_key" xsi:type="string">bundle-dynamic-product-%isolation%</field>
<field name="sku" xsi:type="string">sku_bundle_dynamic_product_%isolation%</field>
<field name="sku_type" xsi:type="string">Dynamic</field>
<field name="price_type" xsi:type="string">Dynamic</field>
<field name="sku_type" xsi:type="string">Yes</field>
<field name="price_type" xsi:type="string">Yes</field>
<field name="price" xsi:type="array">
<item name="dataset" xsi:type="string">bundle_dynamic_with_category</item>
</field>
Expand All @@ -30,15 +30,15 @@
<dataset name="bundle_dynamic_product">
<field name="name" xsi:type="string">Bundle dynamic product %isolation%</field>
<field name="sku" xsi:type="string">sku_bundle_dynamic_product_%isolation%</field>
<field name="sku_type" xsi:type="string">Dynamic</field>
<field name="price_type" xsi:type="string">Dynamic</field>
<field name="sku_type" xsi:type="string">Yes</field>
<field name="price_type" xsi:type="string">Yes</field>
<field name="price" xsi:type="array">
<item name="dataset" xsi:type="string">default_dynamic</item>
</field>
<field name="quantity_and_stock_status" xsi:type="array">
<item name="is_in_stock" xsi:type="string">In Stock</item>
</field>
<field name="weight_type" xsi:type="string">Dynamic</field>
<field name="weight_type" xsi:type="string">Yes</field>
<field name="shipment_type" xsi:type="string">Separately</field>
<field name="tax_class_id" xsi:type="array">
<item name="dataset" xsi:type="string">taxable_goods</item>
Expand Down Expand Up @@ -66,8 +66,8 @@
<dataset name="bundle_fixed_product">
<field name="name" xsi:type="string">Bundle fixed product %isolation%</field>
<field name="sku" xsi:type="string">sku_bundle_fixed_product_%isolation%</field>
<field name="sku_type" xsi:type="string">Fixed</field>
<field name="price_type" xsi:type="string">Fixed</field>
<field name="sku_type" xsi:type="string">No</field>
<field name="price_type" xsi:type="string">No</field>
<field name="price" xsi:type="array">
<item name="value" xsi:type="string">750</item>
<item name="dataset" xsi:type="string">default_fixed</item>
Expand All @@ -79,8 +79,7 @@
<item name="is_in_stock" xsi:type="string">In Stock</item>
</field>
<field name="weight" xsi:type="string">1</field>
<field name="weight_type" xsi:type="string">Fixed</field>
<field name="product_has_weight" xsi:type="string">Yes</field>
<field name="weight_type" xsi:type="string">No</field>
<field name="status" xsi:type="string">Yes</field>
<field name="shipment_type" xsi:type="string">Together</field>
<field name="website_ids" xsi:type="array">
Expand All @@ -107,17 +106,16 @@
<field name="name" xsi:type="string">Bundle fixed product %isolation%</field>
<field name="url_key" xsi:type="string">bundle-fixed-product-%isolation%</field>
<field name="sku" xsi:type="string">sku_bundle_fixed_product_%isolation%</field>
<field name="sku_type" xsi:type="string">Fixed</field>
<field name="price_type" xsi:type="string">Fixed</field>
<field name="sku_type" xsi:type="string">No</field>
<field name="price_type" xsi:type="string">No</field>
<field name="price" xsi:type="array">
<item name="value" xsi:type="string">100</item>
</field>
<field name="tax_class_id" xsi:type="array">
<item name="dataset" xsi:type="string">taxable_goods</item>
</field>
<field name="weight" xsi:type="string">1</field>
<field name="weight_type" xsi:type="string">Fixed</field>
<field name="product_has_weight" xsi:type="string">Yes</field>
<field name="weight_type" xsi:type="string">No</field>
<field name="website_ids" xsi:type="array">
<item name="0" xsi:type="string">Main Website</item>
</field>
Expand All @@ -133,8 +131,8 @@
<field name="name" xsi:type="string">Bundle dynamic product %isolation%</field>
<field name="url_key" xsi:type="string">bundle-dynamic-product-%isolation%</field>
<field name="sku" xsi:type="string">sku_bundle_dynamic_product_%isolation%</field>
<field name="sku_type" xsi:type="string">Dynamic</field>
<field name="price_type" xsi:type="string">Dynamic</field>
<field name="sku_type" xsi:type="string">Yes</field>
<field name="price_type" xsi:type="string">Yes</field>
<field name="price" xsi:type="array">
<item name="dataset" xsi:type="string">bundle_dynamic_with_category</item>
</field>
Expand All @@ -153,17 +151,16 @@
<field name="name" xsi:type="string">Bundle fixed product %isolation%</field>
<field name="url_key" xsi:type="string">bundle-fixed-product-%isolation%</field>
<field name="sku" xsi:type="string">sku_bundle_fixed_product_%isolation%</field>
<field name="sku_type" xsi:type="string">Fixed</field>
<field name="price_type" xsi:type="string">Fixed</field>
<field name="sku_type" xsi:type="string">No</field>
<field name="price_type" xsi:type="string">No</field>
<field name="price" xsi:type="array">
<item name="value" xsi:type="string">100</item>
</field>
<field name="tax_class_id" xsi:type="array">
<item name="dataset" xsi:type="string">taxable_goods</item>
</field>
<field name="weight" xsi:type="string">1</field>
<field name="weight_type" xsi:type="string">Fixed</field>
<field name="product_has_weight" xsi:type="string">Yes</field>
<field name="weight_type" xsi:type="string">No</field>
<field name="website_ids" xsi:type="array">
<item name="0" xsi:type="string">Main Website</item>
</field>
Expand All @@ -179,8 +176,8 @@
<dataset name="bundle_fixed_100_dollar_product">
<field name="name" xsi:type="string">Bundle fixed product %isolation%</field>
<field name="sku" xsi:type="string">sku_bundle_fixed_product_%isolation%</field>
<field name="sku_type" xsi:type="string">Fixed</field>
<field name="price_type" xsi:type="string">Fixed</field>
<field name="sku_type" xsi:type="string">No</field>
<field name="price_type" xsi:type="string">No</field>
<field name="price" xsi:type="array">
<item name="value" xsi:type="string">100</item>
<item name="dataset" xsi:type="string">fixed_100_dollar</item>
Expand All @@ -192,8 +189,7 @@
<item name="is_in_stock" xsi:type="string">In Stock</item>
</field>
<field name="weight" xsi:type="string">1</field>
<field name="weight_type" xsi:type="string">Fixed</field>
<field name="product_has_weight" xsi:type="string">Yes</field>
<field name="weight_type" xsi:type="string">No</field>
<field name="status" xsi:type="string">Yes</field>
<field name="shipment_type" xsi:type="string">Together</field>
<field name="website_ids" xsi:type="array">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
<data name="originalProduct/dataset" xsi:type="string">bundle_dynamic_product</data>
<data name="product/data/url_key" xsi:type="string">bundle-product-%isolation%</data>
<data name="product/data/name" xsi:type="string">bundle_dynamic_%isolation%</data>
<data name="product/data/sku_type" xsi:type="string">Fixed</data>
<data name="product/data/sku_type" xsi:type="string">No</data>
<data name="product/data/sku" xsi:type="string">bundle_dynamic_%isolation%</data>
<data name="product/data/price/dataset" xsi:type="string">dynamic-100</data>
<data name="product/data/weight_type" xsi:type="string">Fixed</data>
<data name="product/data/weight_type" xsi:type="string">No</data>
<data name="product/data/weight" xsi:type="string">1</data>
<data name="product/data/description" xsi:type="string">Bundle Product Fixed Required</data>
<data name="product/data/bundle_shipment_type" xsi:type="string">Together</data>
Expand All @@ -35,10 +35,10 @@
<data name="originalProduct/dataset" xsi:type="string">bundle_fixed_product</data>
<data name="product/data/url_key" xsi:type="string">bundle-product-%isolation%</data>
<data name="product/data/name" xsi:type="string">bundle_fixed_%isolation%</data>
<data name="product/data/sku_type" xsi:type="string">Dynamic</data>
<data name="product/data/sku_type" xsi:type="string">Yes</data>
<data name="product/data/sku" xsi:type="string">bundle_sku_%isolation%</data>
<data name="product/data/price/dataset" xsi:type="string">fixed-756</data>
<data name="product/data/weight_type" xsi:type="string">Dynamic</data>
<data name="product/data/weight_type" xsi:type="string">Yes</data>
<data name="product/data/category_ids/dataset" xsi:type="string">default_subcategory</data>
<data name="product/data/bundle_shipment_type" xsi:type="string">Separately</data>
<data name="product/data/bundle_selections/dataset" xsi:type="string">default_fixed</data>
Expand Down
Loading

0 comments on commit 044bada

Please sign in to comment.