diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/filters/elements/ui-select.html b/app/code/Magento/Ui/view/base/web/templates/grid/filters/elements/ui-select.html index b8a5b8a05976..8c0c3aac555a 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/filters/elements/ui-select.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/filters/elements/ui-select.html @@ -42,6 +42,7 @@ } ">
@@ -121,7 +122,8 @@ ">
  • + data-bind="css: { _parent: $data.optgroup }" + data-role="option-group">
    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) ] ); } @@ -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; } @@ -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++; } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Bundle/Option.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Bundle/Option.php index 8b6668775dd6..79d363f4f1e9 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Bundle/Option.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Bundle/Option.php @@ -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. @@ -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; } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Product/ProductForm.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Product/ProductForm.xml index e4f8bad11586..490044cc55e3 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Product/ProductForm.xml +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Product/ProductForm.xml @@ -5,12 +5,8 @@ * See COPYING.txt for license details. */ --> - + - \Magento\Ui\Test\Block\Adminhtml\Section - [data-index='product-details'] - css selector - product select @@ -48,4 +44,4 @@ - + diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceType.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceType.php index be0f886de0a7..8f9c082e8812 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceType.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceType.php @@ -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. @@ -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) { @@ -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'], diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct.xml index f83dd6192d0c..81e4d66fa8e7 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct.xml +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct.xml @@ -34,8 +34,8 @@ - - + + @@ -80,7 +80,7 @@ - + diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Handler/BundleProduct/Curl.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Handler/BundleProduct/Curl.php index 75222de8c73b..c4c00cf8d145 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Handler/BundleProduct/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Handler/BundleProduct/Curl.php @@ -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, diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/BundleProduct.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/BundleProduct.xml index 78fd6fc645cb..90d2536a0890 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/BundleProduct.xml +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/BundleProduct.xml @@ -11,8 +11,8 @@ Bundle dynamic product %isolation% bundle-dynamic-product-%isolation% sku_bundle_dynamic_product_%isolation% - Dynamic - Dynamic + Yes + Yes bundle_dynamic_with_category @@ -30,15 +30,15 @@ Bundle dynamic product %isolation% sku_bundle_dynamic_product_%isolation% - Dynamic - Dynamic + Yes + Yes default_dynamic In Stock - Dynamic + Yes Separately taxable_goods @@ -66,8 +66,8 @@ Bundle fixed product %isolation% sku_bundle_fixed_product_%isolation% - Fixed - Fixed + No + No 750 default_fixed @@ -79,8 +79,7 @@ In Stock 1 - Fixed - Yes + No Yes Together @@ -107,8 +106,8 @@ Bundle fixed product %isolation% bundle-fixed-product-%isolation% sku_bundle_fixed_product_%isolation% - Fixed - Fixed + No + No 100 @@ -116,8 +115,7 @@ taxable_goods 1 - Fixed - Yes + No Main Website @@ -133,8 +131,8 @@ Bundle dynamic product %isolation% bundle-dynamic-product-%isolation% sku_bundle_dynamic_product_%isolation% - Dynamic - Dynamic + Yes + Yes bundle_dynamic_with_category @@ -153,8 +151,8 @@ Bundle fixed product %isolation% bundle-fixed-product-%isolation% sku_bundle_fixed_product_%isolation% - Fixed - Fixed + No + No 100 @@ -162,8 +160,7 @@ taxable_goods 1 - Fixed - Yes + No Main Website @@ -179,8 +176,8 @@ Bundle fixed product %isolation% sku_bundle_fixed_product_%isolation% - Fixed - Fixed + No + No 100 fixed_100_dollar @@ -192,8 +189,7 @@ In Stock 1 - Fixed - Yes + No Yes Together diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/UpdateBundleProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/UpdateBundleProductEntityTest.xml index 30dd9d43f403..3db133804abe 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/UpdateBundleProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/UpdateBundleProductEntityTest.xml @@ -12,10 +12,10 @@ bundle_dynamic_product bundle-product-%isolation% bundle_dynamic_%isolation% - Fixed + No bundle_dynamic_%isolation% dynamic-100 - Fixed + No 1 Bundle Product Fixed Required Together @@ -35,10 +35,10 @@ bundle_fixed_product bundle-product-%isolation% bundle_fixed_%isolation% - Dynamic + Yes bundle_sku_%isolation% fixed-756 - Dynamic + Yes default_subcategory Separately default_fixed diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/Options.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/Options.php index a004b0ca67c6..e8012cb69c66 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/Options.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/Options.php @@ -9,9 +9,11 @@ use Magento\Mtf\Client\Element\SimpleElement; use Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\Options\Search\Grid; use Magento\Mtf\ObjectManager; +use Magento\Mtf\Client\ElementInterface; use Magento\Mtf\Client\Locator; use Magento\Ui\Test\Block\Adminhtml\Section; use Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\Options\AbstractOptions; +use Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\Options\Row; /** * Product custom options section. @@ -23,14 +25,14 @@ class Options extends Section * * @var string */ - protected $customOptionRow = '//*[*[@class="fieldset-wrapper-title"]//span[.="%s"]]'; + protected $customOptionRow = './/*[*[@class="fieldset-wrapper-title"]//span[.="%s"]]'; /** - * New custom option row CSS locator. + * New custom option row locator. * * @var string */ - protected $newCustomOptionRow = '[data-index="custom_options"] [data-role="grid"] tbody tr:nth-child(%d)'; + protected $newCustomOptionRow = './/*[@data-index="options"]/tbody/tr[%d]'; /** * Add an option button. @@ -51,7 +53,35 @@ class Options extends Section * * @var string */ - protected $importGrid = ".product_form_product_form_custom_options_import_options_modal"; + protected $importGrid = ".product_form_product_form_import_options_modal"; + + /** + * Locator for 'Add Value' button. + * + * @var string + */ + protected $addValue = '[data-action="add_new_row"]'; + + /** + * Locator for dynamic data row. + * + * @var string + */ + protected $dynamicDataRow = '[data-index="values"] tbody tr:nth-child(%d)'; + + /** + * Locator for static data row. + * + * @var string + */ + protected $staticDataRow = '[data-index="container_type_static"] div:nth-child(%d)'; + + /** + * Sort rows data. + * + * @var array + */ + protected $sortRowsData = []; /** * Fill custom options form on tab. @@ -81,25 +111,16 @@ public function setFieldsData(array $fields, SimpleElement $element = null) unset($field['options']); } - $rootElement = $this->_rootElement->find(sprintf($this->newCustomOptionRow, $keyRoot + 1)); + $rootElement = $this->_rootElement->find( + sprintf($this->newCustomOptionRow, $keyRoot + 1), + Locator::SELECTOR_XPATH + ); $data = $this->dataMapping($field); $this->_fill($data, $rootElement); // Fill subform if (isset($field['type']) && !empty($options)) { - /** @var AbstractOptions $optionsForm */ - $optionsForm = $this->blockFactory->create( - __NAMESPACE__ . '\Options\Type\\' . $this->optionNameConvert($field['type']), - ['element' => $rootElement] - ); - - foreach ($options as $key => $option) { - ++$key; - $optionsForm->fillOptions( - $option, - $rootElement->find('[data-index="values"] tbody tr:nth-child(' . $key . ')') - ); - } + $this->setOptionTypeData($options, $field['type'], $rootElement); } } @@ -131,8 +152,85 @@ protected function getSearchGridBlock() { return $this->blockFactory->create( 'Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\Options\Search\Grid', - ['element' => $this->_rootElement->find($this->importGrid)] + ['element' => $this->browser->find($this->importGrid)] + ); + } + + /** + * Get select option row block. + * + * @param int $index + * @param SimpleElement $element + * @return Row + */ + private function getRowBlock($index, SimpleElement $element = null) + { + $element = $element ?: $this->_rootElement; + return $this->blockFactory->create( + 'Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\Options\Row', + ['element' => $element->find(sprintf($this->dynamicDataRow, ++$index))] + ); + } + + /** + * Set Option Type data. + * + * @param array $options + * @param string $type + * @param ElementInterface $element + * @return $this + */ + private function setOptionTypeData(array $options, $type, ElementInterface $element) + { + /** @var AbstractOptions $optionsForm */ + $optionsForm = $this->blockFactory->create( + __NAMESPACE__ . '\Options\Type\\' . $this->optionNameConvert($type), + ['element' => $element] ); + $context = $element->find($this->addValue)->isVisible() + ? $this->dynamicDataRow + : $this->staticDataRow; + foreach ($options as $key => $option) { + if (isset($option['sort_order'])) { + $currentSortOrder = (int)$option['sort_order']; + unset($option['sort_order']); + } else { + $currentSortOrder = 0; + } + $optionsForm->fillOptions( + $option, + $element->find(sprintf($context, $key + 1)) + ); + $this->sortOption($key, $currentSortOrder, $element); + } + $this->sortRowsData = []; + + return $this; + } + + /** + * Sort sample element. + * + * @param int $position + * @param int $sortOrder + * @param SimpleElement|null $element + * @return void + */ + private function sortOption($position, $sortOrder, SimpleElement $element = null) + { + $currentSortRowData = ['current_position_in_grid' => $position, 'sort_order' => $sortOrder]; + foreach ($this->sortRowsData as &$sortRowData) { + if ($sortRowData['sort_order'] > $currentSortRowData['sort_order']) { + // need to reload block because we are changing dom + $target = $this->getRowBlock($sortRowData['current_position_in_grid'], $element)->getSortHandle(); + $this->getRowBlock($currentSortRowData['current_position_in_grid'], $element)->dragAndDropTo($target); + + $currentSortRowData['current_position_in_grid']--; + $sortRowData['current_position_in_grid']++; + } + } + unset($sortRowData); + $this->sortRowsData[] = $currentSortRowData; } /** @@ -141,7 +239,6 @@ protected function getSearchGridBlock() * @param array|null $tabFields * @param SimpleElement|null $element * @return array - * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function getFieldsData($tabFields = null, SimpleElement $element = null) @@ -172,18 +269,10 @@ public function getFieldsData($tabFields = null, SimpleElement $element = null) // Data collection subform if (isset($field['type']) && !empty($options)) { - /** @var AbstractOptions $optionsForm */ - $optionsForm = $this->blockFactory->create( - __NAMESPACE__ . '\Options\Type\\' . $this->optionNameConvert($field['type']), - ['element' => $rootElement] + $formDataItem = array_merge( + $formDataItem, + $this->getOptionTypeData($options, $field['type'], $rootElement) ); - - foreach ($options as $key => $option) { - $formDataItem['options'][$key++] = $optionsForm->getDataOptions( - $option, - $rootElement->find('.fieldset .data-table tbody tr:nth-child(' . $key . ')') - ); - } } $formData[$name][$keyRoot] = $formDataItem; } @@ -191,6 +280,42 @@ public function getFieldsData($tabFields = null, SimpleElement $element = null) return $formData; } + /** + * Get option type data. + * + * @param array $options + * @param string $type + * @param ElementInterface $element + * @return array + */ + private function getOptionTypeData(array $options, $type, ElementInterface $element) + { + $formDataItem = []; + /** @var AbstractOptions $optionsForm */ + $optionsForm = $this->blockFactory->create( + __NAMESPACE__ . '\Options\Type\\' . $this->optionNameConvert($type), + ['element' => $element] + ); + $context = $element->find($this->addValue)->isVisible() + ? $this->dynamicDataRow + : $this->staticDataRow; + foreach ($options as $key => $option) { + if (isset($option['sort_order'])) { + $currentSortOrder = (int)$option['sort_order']; + unset($option['sort_order']); + } + $formDataItem['options'][$key] = $optionsForm->getDataOptions( + $option, + $element->find(sprintf($context, $key + 1)) + ); + if (isset($currentSortOrder)) { + $formDataItem['options'][$key]['sort_order'] = $key; + } + } + + return $formDataItem; + } + /** * Prepare custom options with import options. * diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/Options/Row.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/Options/Row.php new file mode 100644 index 000000000000..8771ad2d7ee2 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/Options/Row.php @@ -0,0 +1,43 @@ +getSortHandle()->dragAndDrop($target); + } + + /** + * Get sort handle. + * + * @return ElementInterface + */ + public function getSortHandle() + { + return $this->_rootElement->find($this->sortDraggableHandle); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/Options/Search/Grid.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/Options/Search/Grid.php index 20f6c385426d..53b8db76c01f 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/Options/Search/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/Options/Search/Grid.php @@ -6,30 +6,22 @@ namespace Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\Options\Search; -use Magento\Backend\Test\Block\Widget\Grid as GridInterface; +use Magento\Ui\Test\Block\Adminhtml\DataGrid; /** - * Class Grid - * 'Import custom options to product' grid + * 'Import custom options to product' grid. */ -class Grid extends GridInterface +class Grid extends DataGrid { /** - * Selector for 'Import' button + * Selector for 'Import' button. * * @var string */ - protected $importProducts = '#import-custom-options-apply-button'; + protected $importProducts = '[data-role="action"]'; /** - * An element locator which allows to select entities in grid - * - * @var string - */ - protected $selectItem = 'tbody tr .col-id'; - - /** - * Filters param for grid + * Filters param for grid. * * @var array */ @@ -40,7 +32,7 @@ class Grid extends GridInterface ]; /** - * Press 'Import' button + * Press 'Import' button. * * @return void */ diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/Options/Type.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/Options/Type.php index c335929a6991..c9042494d8a2 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/Options/Type.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/Options/Type.php @@ -18,14 +18,14 @@ class Type extends OptgroupselectElement * * @var string */ - protected $optGroup = './/*/*/*/ul/li/div/label/span/ancestor::li/ul/li/div/label[text() = "%s"]'; + protected $optGroup = './/*[@data-role="option-group" and *//*[contains(.,"%s")]]//span'; /** * Option group locator. * * @var string */ - protected $optGroupValue = './/*/*/*/ul/li/div/label/span[text()="%s"]/ancestor::li/ul/li/div/label[text() = "%s"]'; + protected $optGroupValue = './/*[@data-role="option-group" and div[contains(.,"%s")]]//label[text()="%s"]'; /** * Locator for Advanced Select element @@ -34,6 +34,13 @@ class Type extends OptgroupselectElement */ protected $advancedSelect = '[data-role="advanced-select"]'; + /** + * Selector for selected option. + * + * @var string + */ + protected $selectedOption = '[data-role="selected-option"]'; + /** * Get element data. * @@ -42,7 +49,8 @@ class Type extends OptgroupselectElement */ protected function getData(ElementInterface $element) { - return trim($element->getValue(), chr(0xC2) . chr(0xA0)); + $this->find($this->advancedSelect)->click(); + return trim($element->getText()); } /** diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/ProductDetails/AttributeSet.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/ProductDetails/AttributeSet.php index e0aac594a76a..63e6b7f8906c 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/ProductDetails/AttributeSet.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/ProductDetails/AttributeSet.php @@ -10,87 +10,51 @@ use Magento\Mtf\Client\Locator; /** - * Class AttributeSet - * Set and Get Attribute Set on the Product form + * Set and Get Attribute Set on the Product form. */ class AttributeSet extends SuggestElement { /** - * Attribute Set locator + * Attribute Set locator. * * @var string */ - protected $value = '.action-toggle > span'; + protected $attributeSet = './/div[text()="%s"]'; /** - * Attribute Set button + * Attribute Set value locator. * * @var string */ - protected $actionToggle = '.action-toggle'; + protected $attributeSetValue = '[data-role="selected-option"]'; /** - * Magento loader + * Selector item of search result. * * @var string */ - protected $loader = '[data-role="loader"]'; + protected $resultItem = './/label[contains(@class, "admin__action-multiselect-label")]/span[text() = "%s"]'; /** - * Page header selector. - * - * @var string - */ - protected $header = 'header'; - - /** - * Set value + * Set value. * * @param string $value * @return void */ public function setValue($value) { - if ($value !== $this->find($this->actionToggle)->getText()) { - $this->eventManager->dispatchEvent(['set_value'], [__METHOD__, $this->getAbsoluteSelector()]); - $this->find($this->actionToggle)->click(); - $this->clear(); - if ($value == '') { - return; - } - foreach (str_split($value) as $symbol) { - $this->keys([$symbol]); - $searchedItem = $this->find(sprintf($this->resultItem, $value), Locator::SELECTOR_XPATH); - if ($searchedItem->isVisible()) { - try { - $searchedItem->hover(); - $this->driver->find($this->header)->hover(); - $searchedItem->click(); - break; - } catch (\Exception $e) { - // In parallel run on windows change the focus is lost on element - // that causes disappearing of category suggest list. - } - } - } + if (!$this->find(sprintf($this->attributeSet, $value), Locator::SELECTOR_XPATH)->isVisible()) { + parent::setValue($value); } - // Wait loader - $element = $this->driver; - $selector = $this->loader; - $element->waitUntil( - function () use ($element, $selector) { - return $element->find($selector)->isVisible() == false ? true : null; - } - ); } /** - * Get value + * Get value. * * @return string */ public function getValue() { - return $this->find($this->value)->getText(); + return $this->find($this->attributeSetValue)->getText(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/FormPageActions.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/FormPageActions.php index 812194181bfa..75f6bcf2cf61 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/FormPageActions.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/FormPageActions.php @@ -11,49 +11,48 @@ use Magento\Mtf\Fixture\FixtureInterface; /** - * Class FormAction - * Form action + * Product Form page actions. */ class FormPageActions extends ParentFormPageActions { /** - * Save and create new product - 'Save & New' + * Save and create new product - 'Save & New'. */ - const SAVE_NEW = 'new'; + const SAVE_NEW = '0'; /** - * Save and create a duplicate product - 'Save & Duplicate' + * Save and create a duplicate product - 'Save & Duplicate'. */ - const SAVE_DUPLICATE = 'duplicate'; + const SAVE_DUPLICATE = '1'; /** - * Save and close the product page - 'Save & Close' + * Save and close the product page - 'Save & Close'. */ - const SAVE_CLOSE = 'close'; + const SAVE_CLOSE = '2'; /** - * CSS selector toggle "Save button" + * CSS selector toggle "Save button". * * @var string */ - protected $toggleButton = '[data-ui-id="page-actions-toolbar-save-split-button-dropdown"]'; + protected $toggleButton = '[data-ui-id="save-button-dropdown"]'; /** - * Save type item + * Save type item. * * @var string */ - protected $saveTypeItem = '#save-split-button-%s-button'; + protected $saveTypeItem = '[data-ui-id="save-button-item-%d"]'; /** - * "Save" button + * "Save" button. * * @var string */ - protected $saveButton = '#save-button'; + protected $saveButton = '[data-ui-id="save-button"]'; /** - * Click on "Save" button + * Click on "Save" button. * * @param FixtureInterface|null $product [optional] * @return void diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.php index 97d51281c0c5..0bd64eb03736 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.php @@ -43,7 +43,7 @@ class ProductForm extends FormSections * * @var string */ - protected $customSection = '.admin__collapsible-title'; + protected $customSection = '[data-index="%s"] .admin__collapsible-title'; /** * Attribute block selector. diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml index f819d7c3ac83..65c8a5469750 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml @@ -7,7 +7,7 @@ --> - \Magento\Ui\Test\Block\Adminhtml\Section + \Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\ProductDetails [data-index='product-details'] css selector product @@ -27,8 +27,7 @@ select - [data-role="weight-switcher"] - radiobutton + select [data-index='container_category_ids'] @@ -69,9 +68,9 @@ [name="product[special_from_date]"] - + [name="product[special_to_date]"] - + [name="product[cost]"] @@ -174,16 +173,6 @@ [data-index='schedule-design-update'] css selector - - \Magento\Ui\Test\Block\Adminhtml\Section - [data-index='gift-wrapping-gift-messaging'] - css selector - - - \Magento\Ui\Test\Block\Adminhtml\Section - [data-index='downloadable'] - css selector - \Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\Options [data-index="custom_options"] @@ -205,6 +194,20 @@ + + \Magento\Ui\Test\Block\Adminhtml\Section + [data-index="gift-options"] + css selector + product + + + switcher + + + checkbox + + + \Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Section\Related [data-index="related"] diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.php index 9fcea9e34561..136ad08e294f 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.php @@ -334,10 +334,13 @@ protected function getSelectOptionsData(SimpleElement $element, $firstOption = 1 $count = $firstOption; $selectOption = $element->find(sprintf($this->option, $count), Locator::SELECTOR_XPATH); + $index = 0; while ($selectOption->isVisible()) { - $listOptions[] = $this->parseOptionText($selectOption->getText()); + $listOptions[$index] = $this->parseOptionText($selectOption->getText()); + $listOptions[$index]['sort_order'] = $index; ++$count; $selectOption = $element->find(sprintf($this->option, $count), Locator::SELECTOR_XPATH); + $index++; } return [ diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertAttributeSetOnProductForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertAttributeSetOnProductForm.php index 0f66f26036df..9ad4cee5e868 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertAttributeSetOnProductForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertAttributeSetOnProductForm.php @@ -72,7 +72,7 @@ public function processAssert( ); if ($attributeSetOriginal === null) { - $productEdit->getProductForm()->openTab('product-details'); + $productEdit->getProductForm()->openSection('product-details'); \PHPUnit_Framework_Assert::assertTrue( $productEdit->getProductForm()->checkAttributeLabel($productAttribute), diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductForm.php index 4911ead66bbb..0bce3deb877d 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductForm.php @@ -32,7 +32,6 @@ class AssertProductForm extends AbstractAssertForm * @var array */ protected $sortFields = [ - 'custom_options::title', 'cross_sell_products::id', 'up_sell_products::id', 'related_products::id', diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.xml index 54a5d4ad04c6..5c837ded6d97 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.xml @@ -76,7 +76,7 @@ - + diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual.xml index c70dd2cf8bd6..40e70240c575 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual.xml @@ -74,6 +74,8 @@ + + diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php index 2d13aacee7cb..cb5ed762f6c3 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php @@ -69,8 +69,8 @@ class Curl extends AbstractCurl implements CatalogProductSimpleInterface 'No' => 0 ], 'product_has_weight' => [ - 'Yes' => 1, - 'No' => 0, + 'This item has weight' => 1, + 'This item has no weight' => 0, ], 'use_config_enable_qty_increments' => [ 'Yes' => 1, diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml index a7cf11cf2d18..64d29e43873c 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml @@ -13,7 +13,7 @@ Simple Product %isolation% sku_simple_product_%isolation% - Yes + This item has weight 1 25 @@ -42,7 +42,7 @@ Product \'!@#$%^&*()+:;\\|}{][?=-~` %isolation% sku_simple_product_%isolation% No - Yes + This item has weight 1 25 @@ -74,7 +74,7 @@ 25 In Stock - Yes + This item has weight 1 560 @@ -98,7 +98,7 @@ product_10_dollar %isolation% sku_product_10_dollar_%isolation% - Yes + This item has weight 1 1000 @@ -126,7 +126,7 @@ product_20_dollar %isolation% sku_product_20_dollar_%isolation% - Yes + This item has weight 1 1000 @@ -148,7 +148,7 @@ Simple Product %isolation% sku_simple_product_%isolation% - Yes + This item has weight 1 25 @@ -173,7 +173,7 @@ Simple Product %isolation% sku_simple_product_%isolation% - Yes + This item has weight 1 1000 @@ -201,7 +201,7 @@ Simple Product %isolation% sku_simple_product_%isolation% - Yes + This item has weight 1 25 @@ -230,7 +230,7 @@ 666.0000 In Stock - Yes + This item has weight 1 default @@ -255,7 +255,7 @@ 666 In Stock - Yes + This item has weight 1 default @@ -280,7 +280,7 @@ 666 In Stock - Yes + This item has weight 1 100 @@ -303,7 +303,7 @@ 666 In Stock - Yes + This item has weight 1 default @@ -326,7 +326,7 @@ Simple product without category %isolation% simple-product-%isolation% simple_product_without_category_%isolation% - Yes + This item has weight 1 default @@ -358,7 +358,7 @@ 100 - Yes + This item has weight 100 Main Website @@ -385,7 +385,7 @@ 111 In Stock - Yes + This item has weight 1 Yes @@ -410,7 +410,7 @@ 50 - Yes + This item has weight 50 52 @@ -431,7 +431,7 @@ default - Yes + This item has weight 1 100 @@ -457,7 +457,7 @@ default - Yes + This item has weight 1 10 @@ -490,7 +490,7 @@ 666 In Stock - Yes + This item has weight 1 <p>dfj_full</p> Yes @@ -514,7 +514,7 @@ 666 In Stock - Yes + This item has weight 0.1 <p>Simple with Weight 0.1</p> Yes @@ -538,7 +538,7 @@ 666 In Stock - Yes + This item has weight 150.1 <p>Simple with Weight 150.1</p> Yes @@ -562,7 +562,7 @@ 666 In Stock - Yes + This item has weight 1 <p>adc_Full</p> Yes @@ -584,7 +584,7 @@ 25 In Stock - Yes + This item has weight 1 100 @@ -604,7 +604,7 @@ 100 - Yes + This item has weight 1 99 @@ -623,7 +623,7 @@ 300 - Yes + This item has weight 1 34 @@ -644,7 +644,7 @@ 300 - Yes + This item has weight 1 85 @@ -671,7 +671,7 @@ 300 - Yes + This item has weight 1 23 @@ -698,7 +698,7 @@ 300 - Yes + This item has weight 1 842 @@ -728,7 +728,7 @@ 300 - Yes + This item has weight 1 953 @@ -751,7 +751,7 @@ No 2 - Yes + This item has weight 1 default @@ -771,7 +771,7 @@ Simple Product out of stock %isolation% sku_simple_product_out_of_stock%isolation% - Yes + This item has weight 1 25 @@ -799,7 +799,7 @@ Simple Product offline %isolation% sku_simple_product_offline_%isolation% - Yes + This item has weight 1 25 @@ -828,7 +828,7 @@ Simple Product not visible %isolation% sku_simple_product_not_visible_%isolation% - Yes + This item has weight 1 25 @@ -856,7 +856,7 @@ Simple Product with cart limit %isolation% sku_simple_product_with_cart_limit_%isolation% - Yes + This item has weight 1 25 @@ -893,7 +893,7 @@ 300 - Yes + This item has weight 1 63 @@ -917,7 +917,7 @@ Simple Product with qty increments %isolation% sku_simple_product_with_qty_increments_%isolation% - Yes + This item has weight 1 25 @@ -954,7 +954,7 @@ 300 - Yes + This item has weight 1 25 @@ -976,7 +976,7 @@ 666 In Stock - Yes + This item has weight 1 default @@ -1013,7 +1013,7 @@ 70 - Yes + This item has weight 1 954 @@ -1054,7 +1054,7 @@ In Stock 100 - Yes + This item has weight 1 simple-product-%isolation% @@ -1069,7 +1069,7 @@ Simple Product %isolation% sku_simple_product_%isolation% simple-product-%isolation% - Yes + This item has weight 1 1000 diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Product/CustomOptions.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Product/CustomOptions.xml index a785e3bda5ed..4ffb12ec54a5 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Product/CustomOptions.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Product/CustomOptions.xml @@ -18,6 +18,7 @@ 10 Percent sku_drop_down_row_1 + 0 @@ -31,6 +32,7 @@ 20 Percent sku_drop_down_row_2 + 0 @@ -47,12 +49,14 @@ 10 Percent sku_drop_down_row_1 + 0 20 percent 20 Percent sku_drop_down_row_2 + 1 @@ -82,6 +86,7 @@ 30 Fixed sku_drop_down_row_1 + 0 @@ -98,6 +103,7 @@ 40 Percent sku_drop_down_row_1 + 0 @@ -140,12 +146,14 @@ 110.01 Percent Percent + 0 Test3-2 %isolation% 210.02 Fixed sku3_%isolation% + 1 @@ -159,12 +167,14 @@ 10.01 Percent sku2_%isolation% + 0 Test4-2 %isolation% 20.02 Fixed sku3_%isolation% + 1 @@ -222,18 +232,21 @@ 10 Percent sku_drop_down_row_1_%isolation% + 0 20 percent 20 Percent sku_drop_down_row_2_%isolation% + 1 30 fixed 30 Fixed sku_drop_down_row_3_%isolation% + 2 @@ -273,6 +286,7 @@ 20 Fixed sku_multiple_select_row%isolation% + 0 diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnUpdateTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnUpdateTest.php index 0852269b2894..8417e4589fef 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnUpdateTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnUpdateTest.php @@ -127,9 +127,9 @@ protected function performAction($actionName) */ protected function deleteVariations() { - $this->catalogProductEdit->getProductForm()->openTab('variations'); + $this->catalogProductEdit->getProductForm()->openSection('variations'); /** @var Config $variationsTab */ - $variationsTab = $this->catalogProductEdit->getProductForm()->getTab('variations'); + $variationsTab = $this->catalogProductEdit->getProductForm()->getSection('variations'); $variationsTab->deleteVariations(); } @@ -140,9 +140,9 @@ protected function deleteVariations() */ protected function clearDownloadableData() { - $this->catalogProductEdit->getProductForm()->openTab('downloadable_information'); + $this->catalogProductEdit->getProductForm()->openSection('downloadable_information'); /** @var Downloadable $downloadableInfoTab */ - $downloadableInfoTab = $this->catalogProductEdit->getProductForm()->getTab('downloadable_information'); + $downloadableInfoTab = $this->catalogProductEdit->getProductForm()->getSection('downloadable_information'); $downloadableInfoTab->getDownloadableBlock('Links')->clearDownloadableData(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateSimpleProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateSimpleProductEntityTest.xml index a2f06e94659e..ca158461c35f 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateSimpleProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateSimpleProductEntityTest.xml @@ -13,7 +13,7 @@ Test simple product %isolation% test_simple_product_%isolation% 245.00 - 200.0000 + 200 test-simple-product-%isolation% 120.0000 Catalog, Search @@ -29,7 +29,7 @@ Test simple product %isolation% test_simple_product_%isolation% 325.00 - 123.0000 + 123 test-simple-product-%isolation% 129.0000 Not Visible Individually @@ -43,7 +43,7 @@ Test simple product %isolation% test_simple_product_%isolation% 325.01 - 125.0000 + 125 test-simple-product-%isolation% 25.0000 Catalog @@ -60,7 +60,7 @@ Test simple product %isolation% test_simple_product_%isolation% 325.02 - 89.0000 + 89 test-simple-product-%isolation% 89.0000 Search @@ -77,7 +77,7 @@ Test simple product %isolation% test_simple_product_%isolation% 325.03 - 25.0000 + 25 Out of Stock test-simple-product-%isolation% 125.0000 @@ -94,7 +94,7 @@ Test simple product %isolation% test_simple_product_%isolation% 74.00 - 87.0000 + 87 test-simple-product-%isolation% 333.0000 No @@ -109,7 +109,7 @@ Test simple product %isolation% test_simple_product_%isolation% 74.00 - 87.0000 + 87 test-simple-product-%isolation% 333.0000 diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateVirtualProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateVirtualProductEntityTest.xml index b967e6f87b9f..b27dc6dda848 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateVirtualProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateVirtualProductEntityTest.xml @@ -13,7 +13,6 @@ 99.99 None 999 - No default_subcategory MAGETWO-23002 In Stock @@ -34,7 +33,6 @@ 120.00 taxable_goods 999 - No 45 In Stock Catalog, Search @@ -54,7 +52,6 @@ 185.00 None 999 - No default_subcategory MAGETWO-23002 Out of Stock @@ -74,7 +71,6 @@ virtual_sku_%isolation% 99.99 taxable_goods - No Out of Stock Search virtual-product-%isolation% @@ -90,7 +86,6 @@ virtual_sku_%isolation% 5.00 None - No Out of Stock Catalog virtual-product-%isolation% @@ -107,7 +102,6 @@ 145.00 taxable_goods 999 - No default_subcategory MAGETWO-23002 In Stock @@ -126,7 +120,6 @@ virtual_sku_%isolation% 99.99 None - No default_subcategory 45 Out of Stock @@ -145,7 +138,6 @@ 5.00 taxable_goods Yes - No Out of Stock Search virtual-product-%isolation% @@ -162,7 +154,6 @@ 120.00 None 999 - No default_subcategory In Stock options_suite @@ -181,7 +172,6 @@ virtual_sku_%isolation% 99.99 taxable_goods - No Out of Stock Catalog, Search virtual-product-%isolation% @@ -198,7 +188,6 @@ 99.99 None 999 - No default_subcategory MAGETWO-23002 In Stock diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/ProductForm.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/ProductForm.xml index 6f638f00f4e0..a08e0861e3ef 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/ProductForm.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/ProductForm.xml @@ -8,7 +8,7 @@ \Magento\ConfigurableProduct\Test\Block\Adminhtml\Product\Edit\Tab\Variations\Config - #product_info_tabs_product-details + [data-index='product-details'] css selector diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct.xml index 5e8684995ac9..346f8c86139a 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct.xml @@ -71,7 +71,7 @@ - + diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct.xml index 0e2c351a27c3..64e351ecccca 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct.xml @@ -14,7 +14,7 @@ 40 price_40 - Yes + This item has weight 30 Yes Catalog, Search @@ -45,7 +45,7 @@ price_40 - Yes + This item has weight 30 Yes Catalog, Search @@ -77,7 +77,7 @@ 10 9 - Yes + This item has weight 5 Yes Catalog, Search @@ -105,7 +105,7 @@ Test configurable product with size %isolation% sku_test_configurable_product_%isolation% - Yes + This item has weight 30 Yes Catalog, Search @@ -133,7 +133,7 @@ Test configurable product with color and size %isolation% sku_test_configurable_product_%isolation% - Yes + This item has weight 30 Yes Catalog, Search @@ -161,7 +161,7 @@ Test configurable product %isolation% sku_test_configurable_product_%isolation% - Yes + This item has weight 30 Yes Catalog, Search @@ -190,7 +190,7 @@ 40 price_40 - Yes + This item has weight 30 Yes Catalog, Search @@ -215,7 +215,7 @@ Test configurable product %isolation% sku_test_configurable_product_%isolation% - Yes + This item has weight 30 Yes Catalog, Search @@ -243,7 +243,7 @@ Test configurable product %isolation% sku_test_configurable_product_%isolation% - Yes + This item has weight 30 Yes Catalog, Search @@ -272,7 +272,7 @@ taxable_goods - Yes + This item has weight 1 1 @@ -302,7 +302,7 @@ taxable_goods - Yes + This item has weight 1 Main Website @@ -321,7 +321,7 @@ Test configurable product %isolation% sku_test_configurable_product_%isolation% - Yes + This item has weight 1 Yes Catalog, Search @@ -351,7 +351,7 @@ taxable_goods - Yes + This item has weight 1 1 diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Downloadable.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Downloadable.php index edbb6814a9c7..b06d95fb14ed 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Downloadable.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Downloadable.php @@ -30,7 +30,14 @@ class Downloadable extends Section * * @var string */ - protected $downloadableBlock = '[data-index="downloadable"] > div > fieldset'; + protected $downloadableBlock = '[data-index="container_%s"]'; + + /** + * Locator for is downloadable product checkbox. + * + * @var string + */ + protected $isDownloadableProduct = '[name="is_downloadable"]'; /** * Get Downloadable block. @@ -44,7 +51,7 @@ public function getDownloadableBlock($type, SimpleElement $element = null) $element = $element ?: $this->_rootElement; return $this->blockFactory->create( 'Magento\Downloadable\Test\Block\Adminhtml\Catalog\Product\Edit\Section\Downloadable\\' . $type, - ['element' => $element->find($this->downloadableBlock, Locator::SELECTOR_CSS)] + ['element' => $element->find(sprintf($this->downloadableBlock, strtolower($type)), Locator::SELECTOR_CSS)] ); } @@ -78,11 +85,15 @@ public function getFieldsData($fields = null, SimpleElement $element = null) * * @param array $fields * @param SimpleElement|null $element - * @SuppressWarnings(PHPMD.UnusedFormalParameter) * @return $this */ public function setFieldsData(array $fields, SimpleElement $element = null) { + $context = $element ?: $this->_rootElement; + $isDownloadable = $context->find($this->isDownloadableProduct); + if ($isDownloadable->isVisible()) { + $isDownloadable->click(); + } if (isset($fields['downloadable_sample']['value'])) { $this->getDownloadableBlock('Samples')->fillSamples($fields['downloadable_sample']['value']); } diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Downloadable/Links.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Downloadable/Links.php index 087a92f04be5..b06584a0b14b 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Downloadable/Links.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Downloadable/Links.php @@ -127,7 +127,6 @@ public function clearDownloadableData() while ($this->_rootElement->find(sprintf($this->rowBlock, $index))->isVisible()) { $rowBlock = $this->getRowBlock($index - 1); $rowBlock->clickDeleteButton(); - ++$index; } } diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Product/ProductForm.xml b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Product/ProductForm.xml index c8c639326b23..d0c904cd818d 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Product/ProductForm.xml +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Product/ProductForm.xml @@ -5,10 +5,10 @@ * See COPYING.txt for license details. */ --> - + \Magento\Downloadable\Test\Block\Adminhtml\Catalog\Product\Edit\Section\Downloadable [data-index="downloadable"] css selector - + diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProduct.xml b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProduct.xml index af7f3efc4dbb..6dcd720ecff2 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProduct.xml +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProduct.xml @@ -81,10 +81,11 @@ - - + + + diff --git a/dev/tests/functional/tests/app/Magento/Msrp/Test/Repository/CatalogProductSimple.xml b/dev/tests/functional/tests/app/Magento/Msrp/Test/Repository/CatalogProductSimple.xml index f3ee8cb520a7..da2dc550f734 100644 --- a/dev/tests/functional/tests/app/Magento/Msrp/Test/Repository/CatalogProductSimple.xml +++ b/dev/tests/functional/tests/app/Magento/Msrp/Test/Repository/CatalogProductSimple.xml @@ -14,7 +14,7 @@ Simple Product with msrp %isolation% sku_simple_product_with_msrp_%isolation% 1 - Yes + This item has weight 25 In Stock @@ -42,7 +42,7 @@ simple-product-with-msrp-%isolation% sku_simple_product_with_msrp_%isolation% 1 - Yes + This item has weight 1000 In Stock diff --git a/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Block/Adminhtml/Product/Edit/Tab/ImagesAndVideos.php b/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Block/Adminhtml/Product/Edit/Tab/ImagesAndVideos.php index 814e65531667..40ca3bb74c53 100755 --- a/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Block/Adminhtml/Product/Edit/Tab/ImagesAndVideos.php +++ b/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Block/Adminhtml/Product/Edit/Tab/ImagesAndVideos.php @@ -8,7 +8,6 @@ use Magento\Backend\Test\Block\Widget\Tab; use Magento\Mtf\Client\Element\SimpleElement; -use Magento\Mtf\Client\Locator; /** * Product images tab. @@ -20,7 +19,7 @@ class ImagesAndVideos extends Tab * * @var string */ - protected $addVideoButton = '#product_info_tabs_image-management_content #add_video_button'; + protected $addVideoButton = '[data-role="add-video-button"]'; /** * Video dialog CSS locator. diff --git a/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Block/Adminhtml/Product/ProductForm.xml b/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Block/Adminhtml/Product/ProductForm.xml index 5a3c8fbe3fd8..bf712dbaf98f 100755 --- a/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Block/Adminhtml/Product/ProductForm.xml +++ b/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Block/Adminhtml/Product/ProductForm.xml @@ -5,10 +5,10 @@ * See COPYING.txt for license details. */ --> - + \Magento\ProductVideo\Test\Block\Adminhtml\Product\Edit\Tab\ImagesAndVideos - #product_info_tabs_image-management + [data-index="block_gallery"] css selector @@ -26,4 +26,4 @@ - + diff --git a/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Constraint/AssertGetVideoInfoDataIsCorrect.php b/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Constraint/AssertGetVideoInfoDataIsCorrect.php index be7af60ae89e..ca3bd3174bee 100755 --- a/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Constraint/AssertGetVideoInfoDataIsCorrect.php +++ b/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Constraint/AssertGetVideoInfoDataIsCorrect.php @@ -30,8 +30,8 @@ public function processAssert( ) { $editProductPage->open(['id' => $initialProduct->getId()]); - $editProductPage->getProductForm()->openTab('images-and-videos'); - $imagesTab = $editProductPage->getProductForm()->getTab('images-and-videos'); + $editProductPage->getProductForm()->openSection('images-and-videos'); + $imagesTab = $editProductPage->getProductForm()->getSection('images-and-videos'); $result = $imagesTab->clickFirstVideo()->getVideoDialog()->validate($video); \PHPUnit_Framework_Assert::assertTrue( diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Customer/Edit/Tab/Reviews.php b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Customer/Edit/Tab/Reviews.php index 704420b799b9..9acf44f5e44e 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Customer/Edit/Tab/Reviews.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Customer/Edit/Tab/Reviews.php @@ -6,13 +6,30 @@ namespace Magento\Review\Test\Block\Adminhtml\Customer\Edit\Tab; -use Magento\Review\Test\Block\Adminhtml\ReviewsTab; +use Magento\Backend\Test\Block\Widget\Tab; /** - * Class Reviews - * Reviews tab on customer edit page + * Reviews tab on customer edit page. */ -class Reviews extends ReviewsTab +class Reviews extends Tab { - // + /** + * Product reviews block selector. + * + * @var string + */ + protected $reviews = '#reviwGrid'; + + /** + * Returns product reviews grid. + * + * @return \Magento\Review\Test\Block\Adminhtml\Grid + */ + public function getReviewsGrid() + { + return $this->blockFactory->create( + 'Magento\Review\Test\Block\Adminhtml\Grid', + ['element' => $this->_rootElement->find($this->reviews)] + ); + } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/Edit/Section/Reviews.php b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/Edit/Section/Reviews.php new file mode 100644 index 000000000000..c1c17679a966 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/Edit/Section/Reviews.php @@ -0,0 +1,35 @@ +blockFactory->create( + 'Magento\Review\Test\Block\Adminhtml\Product\Grid', + ['element' => $this->_rootElement->find($this->reviews)] + ); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/Edit/Tab/Reviews.php b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/Edit/Tab/Reviews.php deleted file mode 100644 index 56330ef7a2f5..000000000000 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/Edit/Tab/Reviews.php +++ /dev/null @@ -1,18 +0,0 @@ - [ - 'selector' => 'input[name="entity_id"]', + 'title' => [ + 'selector' => 'input[name="title"]', ], - 'name' => [ - 'selector' => 'input[name="name"]', + 'sku' => [ + 'selector' => 'input[name="sku"]', ], ]; - - /** - * Locator value for link in action column - * - * @var string - */ - protected $editLink = '.col-entity_id'; } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/ProductForm.xml b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/ProductForm.xml index 178ebee634a5..febed388f77a 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/ProductForm.xml +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/ProductForm.xml @@ -5,10 +5,10 @@ * See COPYING.txt for license details. */ --> - + - \Magento\Review\Test\Block\Adminhtml\Product\Edit\Tab\Reviews - #product_info_tabs_product-reviews + \Magento\Review\Test\Block\Adminhtml\Product\Edit\Section\Reviews + [data-index="review"] css selector - + diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/ReviewsTab.php b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/ReviewsTab.php deleted file mode 100644 index 404b7aabe878..000000000000 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/ReviewsTab.php +++ /dev/null @@ -1,36 +0,0 @@ -blockFactory->create( - 'Magento\Review\Test\Block\Adminhtml\Grid', - ['element' => $this->_rootElement->find($this->reviews)] - ); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest.php index 0a373da1808d..fc6db720f92d 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest.php @@ -134,12 +134,12 @@ public function test(Review $review, $rating) ['product' => $product] )->run(); - $this->catalogProductEdit->getProductForm()->openTab('product_reviews'); + $this->catalogProductEdit->getProductForm()->openSection('product_reviews'); $filter = [ 'title' => $this->reviewInitial->getTitle(), 'sku' => $product->getSku(), ]; - $this->catalogProductEdit->getProductForm()->getTab('product_reviews')->getReviewsGrid() + $this->catalogProductEdit->getProductForm()->getSection('product_reviews')->getReviewsGrid() ->searchAndOpen($filter); $this->reviewEdit->getReviewForm()->fill($review); $this->reviewEdit->getPageActions()->save(); diff --git a/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php b/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php index a803f46cd5c7..bd68b11dc2fe 100644 --- a/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php +++ b/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php @@ -238,6 +238,23 @@ public function searchAndOpen(array $filter) } } + /** + * Search item and select it. + * + * @param array $filter + * @throws \Exception + */ + public function searchAndSelect(array $filter) + { + $this->search($filter); + $rowItem = $this->getRow($filter); + if ($rowItem->isVisible()) { + $rowItem->find($this->selectItem)->click(); + } else { + throw new \Exception('Searched item was not found.'); + } + } + /** * Perform selected massaction over checked items. * diff --git a/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/FormSections.php b/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/FormSections.php index 594f1c0f8bb6..674ef10fa2ee 100644 --- a/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/FormSections.php +++ b/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/FormSections.php @@ -114,7 +114,7 @@ public function isCollapsible($sectionName) * @param string $sectionName * @return bool */ - public function isCollapsed($sectionName) + private function isCollapsed($sectionName) { return $this->getContainerElement($sectionName)->find($this->opened)->isVisible(); }