diff --git a/app/code/Magento/Bundle/view/base/web/js/price-bundle.js b/app/code/Magento/Bundle/view/base/web/js/price-bundle.js index 1a76acf17475670674c064c8384d628b87d924a7..607ac6e03a75a8beeb644c84a11400eee09012d9 100644 --- a/app/code/Magento/Bundle/view/base/web/js/price-bundle.js +++ b/app/code/Magento/Bundle/view/base/web/js/price-bundle.js @@ -295,6 +295,10 @@ define([ case 'hidden': optionHash = 'bundle-option-' + optionName + '##' + optionValue; optionQty = optionConfig[optionValue].qty || 0; + canQtyCustomize = optionConfig[optionValue].customQty === '1'; + qtyField = element.data('qtyField'); + qtyField.data('option', element); + toggleQtyField(qtyField, optionQty, optionId, optionValue, canQtyCustomize); tempChanges = utils.deepClone(optionConfig[optionValue].prices); tempChanges = applyTierPrice(tempChanges, optionQty, optionConfig); tempChanges = applyQty(tempChanges, optionQty); diff --git a/app/code/Magento/Catalog/Block/Product/AbstractProduct.php b/app/code/Magento/Catalog/Block/Product/AbstractProduct.php index d9702c5073fb653c132c89d761e9ddf14faa34c1..f1bb89d4424f7f4436abea0c137a0457a0ad13c8 100644 --- a/app/code/Magento/Catalog/Block/Product/AbstractProduct.php +++ b/app/code/Magento/Catalog/Block/Product/AbstractProduct.php @@ -124,7 +124,7 @@ class AbstractProduct extends \Magento\Framework\View\Element\Template */ public function getAddToCartUrl($product, $additional = []) { - if ($product->getTypeInstance()->hasRequiredOptions($product)) { + if (!$product->getTypeInstance()->isPossibleBuyFromList($product)) { if (!isset($additional['_escape'])) { $additional['_escape'] = true; } diff --git a/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php b/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php index 6de6ea6c6c6bca8029aee2be5749d555690d48c8..11b8d03fc7ee5cc23dd627e65ad9651a5b243b7d 100644 --- a/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php +++ b/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php @@ -1092,4 +1092,15 @@ abstract class AbstractType { return []; } + + /** + * Check if product can be potentially buyed from the category page or some other list + * + * @param \Magento\Catalog\Model\Product $product + * @return bool + */ + public function isPossibleBuyFromList($product) + { + return !$this->hasRequiredOptions($product); + } } diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php index f420f140b35820e3cbcebf986ed305217523aab2..39e3263722a7c3f84fce9f6ce3e5b8ee2f2899d6 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php @@ -154,9 +154,9 @@ class ListProductTest extends \PHPUnit_Framework_TestCase ]; $this->typeInstanceMock->expects($this->once()) - ->method('hasRequiredOptions') + ->method('isPossibleBuyFromList') ->with($this->equalTo($this->productMock)) - ->will($this->returnValue(false)); + ->will($this->returnValue(true)); $this->cartHelperMock->expects($this->any()) ->method('getAddUrl') ->with($this->equalTo($this->productMock), $this->equalTo([])) diff --git a/app/code/Magento/Catalog/view/frontend/web/js/catalog-add-to-cart.js b/app/code/Magento/Catalog/view/frontend/web/js/catalog-add-to-cart.js index 45c9f73e051c788c55f24d2f95f1e286c7d6bd02..7db4f5d745626c0da12d9a4032bc5466c57f282b 100644 --- a/app/code/Magento/Catalog/view/frontend/web/js/catalog-add-to-cart.js +++ b/app/code/Magento/Catalog/view/frontend/web/js/catalog-add-to-cart.js @@ -84,6 +84,17 @@ define([ } if (res.backUrl) { + var eventData = { + 'form': form, + 'redirectParameters': [] + } + // trigger global event, so other modules will be able add parameters to redirect url + $('body').trigger('catalogCategoryAddToCartRedirect', eventData); + if (eventData.redirectParameters.length > 0) { + var parameters = res.backUrl.split('#'); + parameters.push(eventData.redirectParameters.join('&')); + res.backUrl = parameters.join('#'); + } window.location = res.backUrl; return; } diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php index 0b8a4aee9feced6e4f104208b7563bda16b6305c..0bd2f23418221770d4562eb67d6af9d3e8bd4646 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php @@ -1287,4 +1287,19 @@ class Configurable extends \Magento\Catalog\Model\Product\Type\AbstractType } return $this->catalogConfig; } + + /** + * @inheritdoc + */ + public function isPossibleBuyFromList($product) + { + $isAllCustomOptionsDisplayed = true; + foreach ($this->getConfigurableAttributes($product) as $attribute) { + $eavAttribute = $attribute->getProductAttribute(); + + $isAllCustomOptionsDisplayed = ($isAllCustomOptionsDisplayed && $eavAttribute->getUsedInProductListing()); + } + + return $isAllCustomOptionsDisplayed; + } } diff --git a/app/code/Magento/Swatches/view/frontend/templates/product/listing/renderer.phtml b/app/code/Magento/Swatches/view/frontend/templates/product/listing/renderer.phtml index 86046fdce4b6ee3d264d86f94f3a7dcfbf4b13b3..9c3274627b984cc093ecf5f39c54190ead2412fa 100644 --- a/app/code/Magento/Swatches/view/frontend/templates/product/listing/renderer.phtml +++ b/app/code/Magento/Swatches/view/frontend/templates/product/listing/renderer.phtml @@ -7,15 +7,17 @@ <?php /** @var $block \Magento\Swatches\Block\Product\Renderer\Configurable */ ?> <div class="swatch-opt-<?php /* @escapeNotVerified */ echo $block->getProduct()->getId() ?>"></div> <script> - require(["jquery", "jquery/ui", "Magento_Swatches/js/swatch-renderer"], function ($) { - $('.swatch-opt-<?php /* @escapeNotVerified */ echo $block->getProduct()->getId() ?>').SwatchRenderer({ - selectorProduct: '.product-item-details', - onlySwatches: true, - enableControlLabel: false, - numberToShow: <?php /* @escapeNotVerified */ echo $block->getNumberSwatchesPerProduct(); ?>, - jsonConfig: <?php /* @escapeNotVerified */ echo $block->getJsonConfig(); ?>, - jsonSwatchConfig: <?php /* @escapeNotVerified */ echo $block->getJsonSwatchConfig(); ?>, - mediaCallback: '<?php /* @escapeNotVerified */ echo $block->getMediaCallback() ?>' - }); + require( + ["jquery", "jquery/ui", "Magento_Swatches/js/swatch-renderer", "Magento_Swatches/js/catalog-add-to-cart"], + function ($) { + $('.swatch-opt-<?php /* @escapeNotVerified */ echo $block->getProduct()->getId() ?>').SwatchRenderer({ + selectorProduct: '.product-item-details', + onlySwatches: true, + enableControlLabel: false, + numberToShow: <?php /* @escapeNotVerified */ echo $block->getNumberSwatchesPerProduct(); ?>, + jsonConfig: <?php /* @escapeNotVerified */ echo $block->getJsonConfig(); ?>, + jsonSwatchConfig: <?php /* @escapeNotVerified */ echo $block->getJsonSwatchConfig(); ?>, + mediaCallback: '<?php /* @escapeNotVerified */ echo $block->getMediaCallback() ?>' + }); }); </script> diff --git a/app/code/Magento/Swatches/view/frontend/web/js/catalog-add-to-cart.js b/app/code/Magento/Swatches/view/frontend/web/js/catalog-add-to-cart.js new file mode 100644 index 0000000000000000000000000000000000000000..7900ff67b09be952f13bcfd1bd88842327dd0db4 --- /dev/null +++ b/app/code/Magento/Swatches/view/frontend/web/js/catalog-add-to-cart.js @@ -0,0 +1,17 @@ +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +require([ + 'jquery' +], function ($) { + 'use strict'; + + $('body').on('catalogCategoryAddToCartRedirect', function (event, data) { + $(data.form).find('[name*="super"]').each(function (index, item) { + var $item = $(item); + + data.redirectParameters.push($item.attr('data-attr-name') + '=' + $item.val()); + }); + }); +}); diff --git a/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js b/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js index 54e207c335ffb5b6a007a7774df4e2c4a0760628..452c9b6f94d3c60e83bd35a5a932c6b5f8a9092f 100644 --- a/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js +++ b/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js @@ -264,6 +264,8 @@ define([ */ _init: function () { if (this.options.jsonConfig !== '' && this.options.jsonSwatchConfig !== '') { + // store unsorted attributes + this.options.jsonConfig.mappedAttributes = _.clone(this.options.jsonConfig.attributes); this._sortAttributes(); this._RenderControls(); $(this.element).trigger('swatch.initialized'); @@ -617,6 +619,7 @@ define([ $parent.attr('option-selected', $this.attr('option-id')).find('.selected').removeClass('selected'); $label.text($this.attr('option-label')); $input.val($this.attr('option-id')); + $input.attr('data-attr-name', this._getAttributeCodeById(attributeId)); $this.addClass('selected'); $widget._toggleCheckedAttributes($this, $wrapper); } @@ -633,6 +636,19 @@ define([ $input.trigger('change'); }, + /** + * Get human readable attribute code (eg. size, color) by it ID from configuration + * + * @param {Number} attributeId + * @returns {*} + * @private + */ + _getAttributeCodeById: function (attributeId) { + var attribute = this.options.jsonConfig.mappedAttributes[attributeId]; + + return attribute ? attribute.code : attributeId; + }, + /** * Toggle accessibility attributes * @@ -1104,7 +1120,7 @@ define([ params = $.parseQuery(window.location.href.substr(hashIndex + 1)); selectedAttributes = _.invert(_.mapObject(_.invert(params), function (attributeId) { - var attribute = this.options.jsonConfig.attributes[attributeId]; + var attribute = this.options.jsonConfig.mappedAttributes[attributeId]; return attribute ? attribute.code : attributeId; }.bind(this))); diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Bundle/Option/Selection.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Bundle/Option/Selection.xml index 3a124f0cc38b5a76620fce7265890775a047d79f..e8485df0733de8385e31f55f2c95db9b0061848c 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Bundle/Option/Selection.xml +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Bundle/Option/Selection.xml @@ -21,6 +21,10 @@ <selection_qty> <selector>[name$='[selection_qty]']</selector> </selection_qty> + <user_defined> + <selector>[name$='[selection_can_change_qty]']</selector> + <input>checkbox</input> + </user_defined> <getProductName> <selector>span[data-index="name"]</selector> </getProductName> diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View.php index db349d16a86c673f7fcd89d57e94b42461f51012..ec96c5b27f50a39ffcfc6f88bfc5d1299a17af83 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View.php @@ -6,11 +6,10 @@ namespace Magento\Bundle\Test\Block\Catalog\Product; +use Magento\Bundle\Test\Block\Catalog\Product\View\Summary; use Magento\Bundle\Test\Block\Catalog\Product\View\Type\Bundle; -use Magento\Bundle\Test\Fixture\BundleProduct; use Magento\Mtf\Client\Locator; use Magento\Mtf\Fixture\FixtureInterface; -use Magento\Mtf\Fixture\InjectableFixture; /** * Class View @@ -46,6 +45,13 @@ class View extends \Magento\Catalog\Test\Block\Product\View */ protected $newsletterFormSelector = '#newsletter-validate-detail[novalidate="novalidate"]'; + /** + * Summary Block selector. + * + * @var string + */ + private $summaryBlockSelector = '#bundleSummary'; + /** * Get bundle options block. * @@ -59,6 +65,19 @@ class View extends \Magento\Catalog\Test\Block\Product\View ); } + /** + * Get bundle Summary block. + * + * @return Summary + */ + public function getBundleSummaryBlock() + { + return $this->blockFactory->create( + Summary::class, + ['element' => $this->_rootElement->find($this->summaryBlockSelector)] + ); + } + /** * Click "Customize and add to cart button". * diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Summary.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Summary.php new file mode 100644 index 0000000000000000000000000000000000000000..76a46bfe3088a47f79dafa7f8c71d649e324b130 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Summary.php @@ -0,0 +1,35 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Bundle\Test\Block\Catalog\Product\View; + +use Magento\Bundle\Test\Block\Catalog\Product\View\Summary\ConfiguredPrice; + +/** + * Bundle Summary block. + */ +class Summary extends \Magento\Catalog\Test\Block\Product\View +{ + /** + * Configured Price block selector. + * + * @var string + */ + private $configuredPriceBlockSelector = '.price-configured_price'; + + /** + * Get configured price block. + * + * @return ConfiguredPrice + */ + public function getConfiguredPriceBlock() + { + return $this->blockFactory->create( + ConfiguredPrice::class, + ['element' => $this->_rootElement->find($this->configuredPriceBlockSelector)] + ); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Summary/ConfiguredPrice.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Summary/ConfiguredPrice.php new file mode 100644 index 0000000000000000000000000000000000000000..30effcdeef060af5a81f92ed1a463e3f69bc57a0 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Summary/ConfiguredPrice.php @@ -0,0 +1,35 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Bundle\Test\Block\Catalog\Product\View\Summary; + +/** + * This class is used to access the price related information from the storefront. + */ +class ConfiguredPrice extends \Magento\Catalog\Test\Block\AbstractPriceBlock +{ + /** + * Mapping for different type of price. + * + * @var array + */ + protected $mapTypePrices = [ + 'configured_price' => [ + 'selector' => '.price', + ] + ]; + + /** + * This method returns the price represented by the block. + * + * @param string $currency + * @return string|null + */ + public function getPrice($currency = '$') + { + return $this->getTypePrice('configured_price', $currency); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php index 23ac2d25ee017dab9e869e35b1dea7cac4abb94c..ccf47420b11521f9f5bf1a6c4b0f347d86c1baa0 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php @@ -107,11 +107,11 @@ class Bundle extends Block /** @var SimpleElement $optionElement */ $optionElement = $listFormOptions[$title]; - $getTypeData = 'get' . $this->optionNameConvert($option['type']) . 'Data'; + $getTypeData = 'get' . $this->optionNameConvert($option['frontend_type']) . 'Data'; $optionData = $this->$getTypeData($optionElement); $optionData['title'] = $title; - $optionData['type'] = $option['type']; + $optionData['type'] = $option['frontend_type']; $optionData['is_require'] = $optionElement->find($this->required, Locator::SELECTOR_XPATH)->isVisible() ? 'Yes' : 'No'; @@ -266,7 +266,7 @@ class Bundle extends Block /** @var Option $optionBlock */ $optionBlock = $this->blockFactory->create( 'Magento\Bundle\Test\Block\Catalog\Product\View\Type\Option\\' - . $this->optionNameConvert($option['type']), + . $this->optionNameConvert($option['frontend_type']), ['element' => $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)] ); $optionBlock->fillOption($option['value']); diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Element/Qty.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Element/Qty.php new file mode 100644 index 0000000000000000000000000000000000000000..7506b81f8471c7ad8130aa45e31a1680cc26cd34 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Element/Qty.php @@ -0,0 +1,37 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Bundle\Test\Block\Catalog\Product\View\Type\Option\Element; + +use Magento\Mtf\Client\Element\SimpleElement; + +/** + * Typified element class for qty element. + */ +class Qty extends SimpleElement +{ + /** + * "Backspace" key code. + */ + const BACKSPACE = "\xEE\x80\x83"; + + /** + * "RIGHT" key code. + */ + const RIGHT = "\xEE\x80\x94"; + + /** + * Set the value. + * + * @param string|array $value + * @return void + */ + public function setValue($value) + { + $this->keys([self::RIGHT, self::BACKSPACE, $value]); + $this->context->click(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Hidden.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Hidden.php new file mode 100644 index 0000000000000000000000000000000000000000..9fa54759b8e579728cdf2ea053d94481eb520503 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Hidden.php @@ -0,0 +1,17 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Bundle\Test\Block\Catalog\Product\View\Type\Option; + +use Magento\Bundle\Test\Block\Catalog\Product\View\Type\Option; + +/** + * Bundle option hidden type. + */ +class Hidden extends Option +{ + // +} diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Hidden.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Hidden.xml new file mode 100644 index 0000000000000000000000000000000000000000..356f6a52d6b0c296abc0eb857fe2d8b3dccc4b84 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Option/Hidden.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" ?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<mapping strict="1"> + <fields> + <qty> + <selector>//input[contains(@class,"qty")]</selector> + <strategy>xpath</strategy> + <class>Magento\Bundle\Test\Block\Catalog\Product\View\Type\Option\Element\Qty</class> + </qty> + </fields> +</mapping> diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleItemsOnProductPage.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleItemsOnProductPage.php index ddd8e35a301d6907cf75c3790cefaf6d79b394da..411c53d982fcb8a2445e8a5d214383670ec7bf4a 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleItemsOnProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleItemsOnProductPage.php @@ -61,7 +61,7 @@ class AssertBundleItemsOnProductPage extends AbstractAssertForm foreach ($bundleOptions as $optionKey => $bundleOption) { $optionData = [ 'title' => $bundleOption['title'], - 'type' => $bundleOption['type'], + 'type' => $bundleOption['frontend_type'], 'is_require' => $bundleOption['required'], ]; diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceCalculatedOnProductPage.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceCalculatedOnProductPage.php new file mode 100644 index 0000000000000000000000000000000000000000..756fe75eea7db1f943f3a8c490b8eb2427e63095 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceCalculatedOnProductPage.php @@ -0,0 +1,64 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Bundle\Test\Constraint; + +use Magento\Bundle\Test\Fixture\BundleProduct; +use Magento\Catalog\Test\Page\Product\CatalogProductView; +use Magento\Catalog\Test\TestStep\ConfigureProductOnProductPageStep; +use Magento\Mtf\Constraint\AbstractConstraint; +use Magento\Mtf\TestStep\TestStepFactory; + +/** + * Assert calculated price after configure bundle product on product page. + */ +class AssertBundlePriceCalculatedOnProductPage extends AbstractConstraint +{ + /** + * Assert calculated price after configure bundle product on product page. + * + * @param TestStepFactory $stepFactory + * @param BundleProduct $product + * @param CatalogProductView $catalogProductView + */ + public function processAssert( + TestStepFactory $stepFactory, + BundleProduct $product, + CatalogProductView $catalogProductView + ) { + $stepFactory->create(ConfigureProductOnProductPageStep::class, ['product' => $product])->run(); + + //Process assertions + $this->assertPrice($product, $catalogProductView); + } + + /** + * Assert prices on the product view Page. + * + * @param BundleProduct $product + * @param CatalogProductView $productView + * @return void + */ + protected function assertPrice(BundleProduct $product, CatalogProductView $productView) + { + $checkoutData = $product->getCheckoutData(); + \PHPUnit_Framework_Assert::assertEquals( + $checkoutData['cartItem']['configuredPrice'], + $productView->getBundleViewBlock()->getBundleSummaryBlock()->getConfiguredPriceBlock()->getPrice(), + 'Bundle price calculated is not correct.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Bundle price calculates right on product view page.'; + } +} 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 4a4aea603cf8619d0d12335f496b1e6a9e50fd33..6a3572ab15a7af1e9a84ee06841cedf772bc9283 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 @@ -68,6 +68,10 @@ class Curl extends ProductCurl implements BundleProductInterface 'gift_message_available' => [ 'Yes' => 1, 'No' => 0 + ], + 'user_defined' => [ + 'Yes' => 1, + 'No' => 0 ] ]; } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Handler/BundleProduct/Webapi.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Handler/BundleProduct/Webapi.php index 634f6c00a6cc87aac749b187fafd2452e3fd98fb..2fbdaffefc7a33192c73309d0dde80729311b5d8 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Handler/BundleProduct/Webapi.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Handler/BundleProduct/Webapi.php @@ -64,25 +64,8 @@ class Webapi extends SimpleProductWebapi implements BundleProductInterface 'title' => $bundleOption['title'], 'type' => $bundleOption['type'], 'required' => $bundleOption['required'], - 'product_links' => [], + 'product_links' => $this->prepareLinksInfo($bundleSelections, $key) ]; - - $productLinksInfo = $bundleOption['assigned_products']; - $products = $bundleSelections['products'][$key]; - foreach ($productLinksInfo as $linkKey => $productLink) { - $product = $products[$linkKey]; - $bundleProductOptions[$key]['product_links'][] = [ - 'sku' => $product->getSku(), - 'qty' => $productLink['data']['selection_qty'], - 'is_default' => false, - 'price' => isset($productLink['data']['selection_price_value']) - ? $productLink['data']['selection_price_value'] - : null, - 'price_type' => isset($productLink['data']['selection_price_type']) - ? $productLink['data']['selection_price_type'] - : null, - ]; - } } } @@ -92,6 +75,39 @@ class Webapi extends SimpleProductWebapi implements BundleProductInterface unset($this->fields['product']['bundle_selections']); } + /** + * Prepare links info field. + * + * @param array $bundleSelections + * @param int $key + * @return array + */ + private function prepareLinksInfo(array $bundleSelections, $key) + { + $result = []; + $productLinksInfo = $bundleSelections['bundle_options'][$key]['assigned_products']; + $products = $bundleSelections['products'][$key]; + foreach ($productLinksInfo as $linkKey => $productLink) { + $product = $products[$linkKey]; + $result[] = [ + 'sku' => $product->getSku(), + 'qty' => $productLink['data']['selection_qty'], + 'is_default' => false, + 'price' => isset($productLink['data']['selection_price_value']) + ? $productLink['data']['selection_price_value'] + : null, + 'price_type' => isset($productLink['data']['selection_price_type']) + ? $productLink['data']['selection_price_type'] + : null, + 'can_change_quantity' => isset($productLink['data']['user_defined']) + ? $productLink['data']['user_defined'] + : 0, + ]; + } + + return $result; + } + /** * Parse response. * diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/BundleProduct/BundleSelections.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/BundleProduct/BundleSelections.xml index 7131aab3cffcbb69ca84f1078540a2dbada2ae28..c19a78f64894e17b256a1ec13828b0612bdada08 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/BundleProduct/BundleSelections.xml +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/BundleProduct/BundleSelections.xml @@ -12,6 +12,7 @@ <item name="0" xsi:type="array"> <item name="title" xsi:type="string">Drop-down Option</item> <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Drop-down</item> <item name="required" xsi:type="string">Yes</item> <item name="assigned_products" xsi:type="array"> <item name="0" xsi:type="array"> @@ -46,6 +47,7 @@ <item name="0" xsi:type="array"> <item name="title" xsi:type="string">Drop-down Option</item> <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Drop-down</item> <item name="required" xsi:type="string">Yes</item> <item name="assigned_products" xsi:type="array"> <item name="0" xsi:type="array"> @@ -84,6 +86,7 @@ <item name="0" xsi:type="array"> <item name="title" xsi:type="string">Drop-down Option</item> <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Drop-down</item> <item name="required" xsi:type="string">Yes</item> <item name="assigned_products" xsi:type="array"> <item name="0" xsi:type="array"> @@ -122,6 +125,7 @@ <item name="0" xsi:type="array"> <item name="title" xsi:type="string">Drop-down Option</item> <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Drop-down</item> <item name="required" xsi:type="string">Yes</item> <item name="assigned_products" xsi:type="array"> <item name="0" xsi:type="array"> @@ -160,6 +164,7 @@ <item name="0" xsi:type="array"> <item name="title" xsi:type="string">Drop-down Option</item> <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Drop-down</item> <item name="required" xsi:type="string">Yes</item> <item name="assigned_products" xsi:type="array"> <item name="0" xsi:type="array"> @@ -187,6 +192,7 @@ <item name="1" xsi:type="array"> <item name="title" xsi:type="string">Radio Button Option</item> <item name="type" xsi:type="string">Radio Buttons</item> + <item name="frontend_type" xsi:type="string">Radio Buttons</item> <item name="required" xsi:type="string">Yes</item> <item name="assigned_products" xsi:type="array"> <item name="0" xsi:type="array"> @@ -214,6 +220,7 @@ <item name="2" xsi:type="array"> <item name="title" xsi:type="string">Checkbox Option</item> <item name="type" xsi:type="string">Checkbox</item> + <item name="frontend_type" xsi:type="string">Checkbox</item> <item name="required" xsi:type="string">Yes</item> <item name="assigned_products" xsi:type="array"> <item name="0" xsi:type="array"> @@ -241,6 +248,7 @@ <item name="3" xsi:type="array"> <item name="title" xsi:type="string">Multiple Select Option</item> <item name="type" xsi:type="string">Multiple Select</item> + <item name="frontend_type" xsi:type="string">Multiple Select</item> <item name="required" xsi:type="string">Yes</item> <item name="assigned_products" xsi:type="array"> <item name="0" xsi:type="array"> @@ -291,6 +299,7 @@ <item name="0" xsi:type="array"> <item name="title" xsi:type="string">Drop-down Option</item> <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Drop-down</item> <item name="required" xsi:type="string">Yes</item> <item name="assigned_products" xsi:type="array"> <item name="0" xsi:type="array"> @@ -314,6 +323,7 @@ <item name="1" xsi:type="array"> <item name="title" xsi:type="string">Radio Button Option</item> <item name="type" xsi:type="string">Radio Buttons</item> + <item name="frontend_type" xsi:type="string">Radio Buttons</item> <item name="required" xsi:type="string">Yes</item> <item name="assigned_products" xsi:type="array"> <item name="0" xsi:type="array"> @@ -337,6 +347,7 @@ <item name="2" xsi:type="array"> <item name="title" xsi:type="string">Checkbox Option</item> <item name="type" xsi:type="string">Checkbox</item> + <item name="frontend_type" xsi:type="string">Checkbox</item> <item name="required" xsi:type="string">Yes</item> <item name="assigned_products" xsi:type="array"> <item name="0" xsi:type="array"> @@ -360,6 +371,7 @@ <item name="3" xsi:type="array"> <item name="title" xsi:type="string">Multiple Select Option</item> <item name="type" xsi:type="string">Multiple Select</item> + <item name="frontend_type" xsi:type="string">Multiple Select</item> <item name="required" xsi:type="string">Yes</item> <item name="assigned_products" xsi:type="array"> <item name="0" xsi:type="array"> @@ -406,6 +418,7 @@ <item name="0" xsi:type="array"> <item name="title" xsi:type="string">Drop-down Option</item> <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Drop-down</item> <item name="required" xsi:type="string">No</item> <item name="assigned_products" xsi:type="array"> <item name="0" xsi:type="array"> @@ -433,6 +446,7 @@ <item name="1" xsi:type="array"> <item name="title" xsi:type="string">Radio Button Option</item> <item name="type" xsi:type="string">Radio Buttons</item> + <item name="frontend_type" xsi:type="string">Radio Buttons</item> <item name="required" xsi:type="string">No</item> <item name="assigned_products" xsi:type="array"> <item name="0" xsi:type="array"> @@ -475,6 +489,7 @@ <item name="0" xsi:type="array"> <item name="title" xsi:type="string">Drop-down Option</item> <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Drop-down</item> <item name="required" xsi:type="string">Yes</item> <item name="assigned_products" xsi:type="array"> <item name="0" xsi:type="array"> @@ -513,6 +528,7 @@ <item name="0" xsi:type="array"> <item name="title" xsi:type="string">Drop-down Option</item> <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Drop-down</item> <item name="required" xsi:type="string">Yes</item> <item name="assigned_products" xsi:type="array"> <item name="0" xsi:type="array"> @@ -547,6 +563,7 @@ <item name="0" xsi:type="array"> <item name="title" xsi:type="string">Drop-down Option</item> <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Drop-down</item> <item name="required" xsi:type="string">Yes</item> <item name="assigned_products" xsi:type="array"> <item name="0" xsi:type="array"> @@ -572,6 +589,7 @@ <item name="0" xsi:type="array"> <item name="title" xsi:type="string">Drop-down Option</item> <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Drop-down</item> <item name="required" xsi:type="string">Yes</item> <item name="assigned_products" xsi:type="array"> <item name="0" xsi:type="array"> @@ -610,6 +628,7 @@ <item name="0" xsi:type="array"> <item name="title" xsi:type="string">Drop-down Option</item> <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Drop-down</item> <item name="required" xsi:type="string">Yes</item> <item name="assigned_products" xsi:type="array"> <item name="0" xsi:type="array"> @@ -633,6 +652,7 @@ <item name="1" xsi:type="array"> <item name="title" xsi:type="string">Drop-down Option</item> <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Drop-down</item> <item name="required" xsi:type="string">Yes</item> <item name="assigned_products" xsi:type="array"> <item name="0" xsi:type="array"> @@ -830,5 +850,32 @@ </item> </field> </dataset> + + <dataset name="one_required_option_with_one_item"> + <field name="bundle_options" xsi:type="array"> + <item name="0" xsi:type="array"> + <item name="title" xsi:type="string">Drop-down Option</item> + <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Hidden</item> + <item name="required" xsi:type="string">Yes</item> + <item name="assigned_products" xsi:type="array"> + <item name="0" xsi:type="array"> + <item name="search_data" xsi:type="array"> + <item name="name" xsi:type="string">%product_name%</item> + </item> + <item name="data" xsi:type="array"> + <item name="selection_qty" xsi:type="string">1</item> + <item name="user_defined" xsi:type="string">Yes</item> + </item> + </item> + </item> + </item> + </field> + <field name="products" xsi:type="array"> + <item name="0" xsi:type="array"> + <item name="0" xsi:type="string">catalogProductSimple::default</item> + </item> + </field> + </dataset> </repository> </config> diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/BundleProduct/CheckoutData.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/BundleProduct/CheckoutData.xml index 3e7550b9d784e3858bd9800e66b88b8c60326b1b..d68fb0d0b83f8ff3520508a1c72bc51dcf8ff1c1 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/BundleProduct/CheckoutData.xml +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/BundleProduct/CheckoutData.xml @@ -13,6 +13,7 @@ <item name="0" xsi:type="array"> <item name="title" xsi:type="string">Drop-down Option</item> <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Drop-down</item> <item name="value" xsi:type="array"> <item name="name" xsi:type="string">product_100_dollar</item> </item> @@ -27,6 +28,7 @@ <item name="0" xsi:type="array"> <item name="title" xsi:type="string">Drop-down Option</item> <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Drop-down</item> <item name="value" xsi:type="array"> <item name="name" xsi:type="string">product_100_dollar</item> </item> @@ -47,6 +49,7 @@ <item name="0" xsi:type="array"> <item name="title" xsi:type="string">Drop-down Option</item> <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Drop-down</item> <item name="value" xsi:type="array"> <item name="name" xsi:type="string">product_100_dollar</item> </item> @@ -67,6 +70,7 @@ <item name="0" xsi:type="array"> <item name="title" xsi:type="string">Drop-down Option</item> <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Drop-down</item> <item name="value" xsi:type="array"> <item name="name" xsi:type="string">product_10_dollar</item> </item> @@ -87,6 +91,7 @@ <item name="0" xsi:type="array"> <item name="title" xsi:type="string">Drop-down Option</item> <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Drop-down</item> <item name="value" xsi:type="array"> <item name="name" xsi:type="string">Simple Product</item> </item> @@ -107,6 +112,7 @@ <item name="0" xsi:type="array"> <item name="title" xsi:type="string">Drop-down Option</item> <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Drop-down</item> <item name="value" xsi:type="array"> <item name="name" xsi:type="string">product_100_dollar</item> </item> @@ -114,6 +120,7 @@ <item name="1" xsi:type="array"> <item name="title" xsi:type="string">Radio Button Option</item> <item name="type" xsi:type="string">Radio Buttons</item> + <item name="frontend_type" xsi:type="string">Radio Buttons</item> <item name="value" xsi:type="array"> <item name="name" xsi:type="string">product_100_dollar</item> </item> @@ -128,6 +135,7 @@ <item name="0" xsi:type="array"> <item name="title" xsi:type="string">Drop-down Option</item> <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Drop-down</item> <item name="value" xsi:type="array"> <item name="name" xsi:type="string">product_100_dollar</item> </item> @@ -192,6 +200,7 @@ <item name="0" xsi:type="array"> <item name="title" xsi:type="string">Drop-down Option</item> <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Drop-down</item> <item name="value" xsi:type="array"> <item name="name" xsi:type="string">product_100_dollar</item> </item> @@ -212,6 +221,7 @@ <item name="0" xsi:type="array"> <item name="title" xsi:type="string">Drop-down Option</item> <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Drop-down</item> <item name="value" xsi:type="array"> <item name="name" xsi:type="string">product_10_dollar</item> </item> @@ -242,6 +252,7 @@ <item name="0" xsi:type="array"> <item name="title" xsi:type="string">Drop-down Option</item> <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Drop-down</item> <item name="value" xsi:type="array"> <item name="name" xsi:type="string">product_100_dollar</item> </item> @@ -249,6 +260,7 @@ <item name="1" xsi:type="array"> <item name="title" xsi:type="string">Radio Button Option</item> <item name="type" xsi:type="string">Radio Buttons</item> + <item name="frontend_type" xsi:type="string">Radio Buttons</item> <item name="value" xsi:type="array"> <item name="name" xsi:type="string">product_100_dollar</item> </item> @@ -256,6 +268,7 @@ <item name="2" xsi:type="array"> <item name="title" xsi:type="string">Checkbox Option</item> <item name="type" xsi:type="string">Checkbox</item> + <item name="frontend_type" xsi:type="string">Checkbox</item> <item name="value" xsi:type="array"> <item name="name" xsi:type="string">product_100_dollar</item> </item> @@ -263,6 +276,7 @@ <item name="3" xsi:type="array"> <item name="title" xsi:type="string">Multiple Select Option</item> <item name="type" xsi:type="string">Multiple</item> + <item name="frontend_type" xsi:type="string">Multiple</item> <item name="value" xsi:type="array"> <item name="name" xsi:type="string">product_100_dollar</item> </item> @@ -315,6 +329,7 @@ <item name="0" xsi:type="array"> <item name="title" xsi:type="string">Drop-down Option</item> <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Drop-down</item> <item name="value" xsi:type="array"> <item name="name" xsi:type="string">product_100_dollar</item> </item> @@ -322,6 +337,7 @@ <item name="1" xsi:type="array"> <item name="title" xsi:type="string">Radio Button Option</item> <item name="type" xsi:type="string">Radio Buttons</item> + <item name="frontend_type" xsi:type="string">Radio Buttons</item> <item name="value" xsi:type="array"> <item name="name" xsi:type="string">product_100_dollar</item> </item> @@ -329,6 +345,7 @@ <item name="2" xsi:type="array"> <item name="title" xsi:type="string">Checkbox Option</item> <item name="type" xsi:type="string">Checkbox</item> + <item name="frontend_type" xsi:type="string">Checkbox</item> <item name="value" xsi:type="array"> <item name="name" xsi:type="string">product_100_dollar</item> </item> @@ -357,5 +374,24 @@ </item> </field> </dataset> + + <dataset name="one_required_option_with_one_item"> + <field name="options" xsi:type="array"> + <item name="bundle_options" xsi:type="array"> + <item name="0" xsi:type="array"> + <item name="title" xsi:type="string">Drop-down Option</item> + <item name="type" xsi:type="string">Drop-down</item> + <item name="frontend_type" xsi:type="string">Hidden</item> + <item name="value" xsi:type="array"> + <item name="name" xsi:type="string">Simple Product</item> + <item name="qty" xsi:type="string">3</item> + </item> + </item> + </item> + </field> + <field name="cartItem" xsi:type="array"> + <item name="configuredPrice" xsi:type="string">1680</item> + </field> + </dataset> </repository> </config> diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.xml index 7d4ccea704ec7664c9c7da086c8367104b5fa677..56b2ceb917fe6d46296e408954bdfc88380af5a3 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/CreateBundleProductEntityTest.xml @@ -455,5 +455,17 @@ <constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" /> <constraint name="Magento\Bundle\Test\Constraint\AssertBundleProductPage" /> </variation> + <variation name="CreateBundleProductEntityTestVariation25" summary="Create Bundle (dynamic) Product with one require option with one item" ticketId="MAGETWO-59841"> + <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" xsi:type="string">sku_bundle_dynamic_%isolation%</data> + <data name="product/data/price_type" xsi:type="string">Yes</data> + <data name="product/data/category" xsi:type="string">category_%isolation%</data> + <data name="product/data/shipment_type" xsi:type="string">Together</data> + <data name="product/data/bundle_selections/dataset" xsi:type="string">one_required_option_with_one_item</data> + <data name="product/data/checkout_data/dataset" xsi:type="string">one_required_option_with_one_item</data> + <constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" /> + <constraint name="Magento\Bundle\Test\Constraint\AssertBundlePriceCalculatedOnProductPage" /> + </variation> </testCase> </config> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View.php index 3134fda0d2b2b3f98b3e9d0ef5c835e8cb1aad53..de6adb0efd8b21df23cf0531624fa0b90983225d 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View.php @@ -10,7 +10,7 @@ use Magento\Catalog\Test\Block\AbstractConfigureBlock; use Magento\Catalog\Test\Fixture\CatalogProductSimple; use Magento\Mtf\Client\Locator; use Magento\Mtf\Fixture\FixtureInterface; -use Magento\Mtf\Fixture\InjectableFixture; +use Magento\Checkout\Test\Block\Cart\Sidebar; /** * Product view block on the product page. @@ -145,7 +145,14 @@ class View extends AbstractConfigureBlock * * @var string */ - protected $miniCartBlock = '[data-block="minicart"]'; + protected $miniCartBlockSelector = '[data-block="minicart"]'; + + /** + * Minicart block element. + * + * @var Sidebar + */ + private $miniCartBlock; /** * Success message selector. @@ -222,21 +229,44 @@ class View extends AbstractConfigureBlock */ public function addToCart(FixtureInterface $product) { - /** @var \Magento\Checkout\Test\Block\Cart\Sidebar $miniCart */ - $miniCart = $this->blockFactory->create( - \Magento\Checkout\Test\Block\Cart\Sidebar::class, - ['element' => $this->browser->find($this->miniCartBlock)] - ); + $this->configure($product); + $this->clickAddToCart(); + $this->getMiniCartBlock()->waitLoader(); + } + + /** + * Configure Product. + * + * @param FixtureInterface $product + * @return void + */ + public function configure(FixtureInterface $product) + { /** @var CatalogProductSimple $product */ $checkoutData = $product->getCheckoutData(); - $miniCart->waitInit(); + $this->getMiniCartBlock()->waitInit(); $this->fillOptions($product); if (isset($checkoutData['qty'])) { $this->setQty($checkoutData['qty']); } - $this->clickAddToCart(); - $miniCart->waitLoader(); + } + + /** + * Get MiniCart block. + * + * @return Sidebar + */ + private function getMiniCartBlock() + { + if ($this->miniCartBlock === null) { + $this->miniCartBlock = $this->blockFactory->create( + Sidebar::class, + ['element' => $this->browser->find($this->miniCartBlockSelector)] + ); + } + + return $this->miniCartBlock; } /** @@ -313,14 +343,8 @@ class View extends AbstractConfigureBlock public function braintreePaypalCheckout() { $currentWindow = $this->browser->getCurrentWindow(); - /** @var \Magento\Checkout\Test\Block\Cart\Sidebar $miniCart */ - $miniCart = $this->blockFactory->create( - \Magento\Checkout\Test\Block\Cart\Sidebar::class, - ['element' => $this->browser->find($this->miniCartBlock)] - ); - - $miniCart->openMiniCart(); - $miniCart->clickBraintreePaypalButton(); + $this->getMiniCartBlock()->openMiniCart(); + $this->getMiniCartBlock()->clickBraintreePaypalButton(); return $currentWindow; } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php index a4a773ae7c7ecd02e11b6e824d6ec3d50925523b..db43cc535ca01c4bbac96e425a435bd71ef3fcef 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php @@ -47,6 +47,14 @@ class Curl extends AbstractCurl implements CatalogProductAttributeInterface 'No' => 0, 'Yes' => 1, ], + 'is_global' => [ + 'Store View' => '0', + 'Global' => '1', + ], + 'used_in_product_listing' => [ + 'No' => '0', + 'Yes' => '1', + ], ]; /** @@ -76,6 +84,7 @@ class Curl extends AbstractCurl implements CatalogProductAttributeInterface unset($data['options']); } + $data = $this->changeStructureOfTheData($data); $url = $_ENV['app_backend_url'] . 'catalog/product_attribute/save/back/edit'; $curl = new BackendDecorator(new CurlTransport(), $this->_configuration); $curl->write($url, $data); @@ -104,4 +113,13 @@ class Curl extends AbstractCurl implements CatalogProductAttributeInterface return $resultData; } + + /** + * @param array $data + * @return array + */ + protected function changeStructureOfTheData(array $data) + { + return $data; + } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/ConfigureProductOnProductPageStep.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/ConfigureProductOnProductPageStep.php new file mode 100644 index 0000000000000000000000000000000000000000..f2f08513d7297ad1a3fe3345c8bdca1b848e4819 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/ConfigureProductOnProductPageStep.php @@ -0,0 +1,66 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Catalog\Test\TestStep; + +use Magento\Catalog\Test\Page\Product\CatalogProductView; +use Magento\Mtf\Client\BrowserInterface; +use Magento\Mtf\Fixture\InjectableFixture; +use Magento\Mtf\TestStep\TestStepInterface; + +/** + * Configure Product on Product Page step. + */ +class ConfigureProductOnProductPageStep implements TestStepInterface +{ + /** + * Product fixture. + * + * @var InjectableFixture + */ + private $product; + + /** + * Frontend product view page. + * + * @var CatalogProductView + */ + private $catalogProductView; + + /** + * Interface Browser. + * + * @var BrowserInterface + */ + private $browser; + + /** + * @constructor + * @param CatalogProductView $catalogProductView + * @param BrowserInterface $browser + * @param InjectableFixture $product + */ + public function __construct( + CatalogProductView $catalogProductView, + BrowserInterface $browser, + InjectableFixture $product + ) { + $this->product = $product; + $this->catalogProductView = $catalogProductView; + $this->browser = $browser; + } + + /** + * Configure product. + * + * @return void + */ + public function run() + { + $this->browser->open($_ENV['app_frontend_url'] . $this->product->getUrlKey() . '.html'); + $this->catalogProductView->getViewBlock()->configure($this->product); + } +} diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/ConfigurableProduct/Curl.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/ConfigurableProduct/Curl.php index bf5d5944aa3da0a7093d5bbe33ea00897f3b5397..626be7dee3652ee88407d47f1bac313a96dde225 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/ConfigurableProduct/Curl.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/ConfigurableProduct/Curl.php @@ -172,7 +172,7 @@ class Curl extends ProductCurl implements ConfigurableProductInterface $keyIds[] = $attribute['options'][$optionKey]['id']; $configurableAttribute[] = sprintf( '"%s":"%s"', - $attribute['attribute_code'], + isset($attribute['attribute_code']) ? $attribute['attribute_code'] : $attribute['frontend_label'], $attribute['options'][$optionKey]['id'] ); } diff --git a/dev/tests/functional/tests/app/Magento/Swatches/Test/Block/Product/ListProduct.php b/dev/tests/functional/tests/app/Magento/Swatches/Test/Block/Product/ListProduct.php new file mode 100644 index 0000000000000000000000000000000000000000..39c630a0aa2060f23e6ef87c2682e73169ffa777 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Swatches/Test/Block/Product/ListProduct.php @@ -0,0 +1,30 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Swatches\Test\Block\Product; + +use Magento\Mtf\Client\Locator; +use Magento\Mtf\Fixture\FixtureInterface; +use Magento\Catalog\Test\Block\Product\ListProduct as CatalogListProduct; + +/** + * Product list block. + */ +class ListProduct extends CatalogListProduct +{ + /** + * @inheritdoc + */ + public function getProductItem(FixtureInterface $product) + { + $locator = sprintf($this->productItem, $product->getName()); + + return $this->blockFactory->create( + \Magento\Swatches\Test\Block\Product\ProductList\ProductItem::class, + ['element' => $this->_rootElement->find($locator, Locator::SELECTOR_XPATH)] + ); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Swatches/Test/Block/Product/ProductList/ProductItem.php b/dev/tests/functional/tests/app/Magento/Swatches/Test/Block/Product/ProductList/ProductItem.php new file mode 100755 index 0000000000000000000000000000000000000000..414d03bc687871490b551fcfb807f2958fd4e25e --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Swatches/Test/Block/Product/ProductList/ProductItem.php @@ -0,0 +1,71 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Swatches\Test\Block\Product\ProductList; + +use Magento\Mtf\Client\Locator; +use Magento\Catalog\Test\Block\Product\ProductList\ProductItem as CatalogProductItem; + +/** + * Product item block on frontend category view. + */ +class ProductItem extends CatalogProductItem +{ + /** + * Selector for the swatches of the product. + * + * @var string + */ + protected $swatchSelector = 'div[option-id="%s"]'; + + /** + * Fill product options on category page. + * + * @param \Magento\ConfigurableProduct\Test\Fixture\ConfigurableProduct $product + * @return void + */ + public function fillData(\Magento\ConfigurableProduct\Test\Fixture\ConfigurableProduct $product) + { + $checkoutData = $product->getCheckoutData(); + $options = $checkoutData['options']['configurable_options']; + $confAttrData = $product->getDataFieldConfig('configurable_attributes_data'); + $confAttrSource = $confAttrData['source']; + $attributes = $confAttrSource->getAttributes(); + + foreach ($options as $option) { + if (!isset($attributes[$option['title']])) { + continue; + } + $availableOptions = $attributes[$option['title']]->getOptions(); + $optionKey = str_replace('option_key_', '', $option['value']); + if (!isset($availableOptions[$optionKey])) { + continue; + } + $optionForSelect = $availableOptions[$optionKey]; + $this->clickOnSwatch($optionForSelect['id']); + } + } + + /** + * Click on swatch. + * + * @param $optionId + */ + private function clickOnSwatch($optionId) + { + $selector = sprintf($this->swatchSelector, $optionId); + $this->_rootElement->find($selector, Locator::SELECTOR_CSS)->click(); + } + + /** + * @inheritdoc + */ + public function clickAddToCart() + { + $this->_rootElement->hover(); + parent::clickAddToCart(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Swatches/Test/Block/Product/ViewWithSwatches.php b/dev/tests/functional/tests/app/Magento/Swatches/Test/Block/Product/ViewWithSwatches.php new file mode 100644 index 0000000000000000000000000000000000000000..c1405b4a807718edbb511569ac23d03fc2b52d43 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Swatches/Test/Block/Product/ViewWithSwatches.php @@ -0,0 +1,45 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Swatches\Test\Block\Product; + +use Magento\Catalog\Test\Block\Product\View; +use Magento\Mtf\Fixture\InjectableFixture; + +/** + * Configurable product view block with swatch attributes on frontend product page + */ +class ViewWithSwatches extends View +{ + /** + * Selector for swatch attribute value + * + * @var string + */ + private $swatchAttributeSelector = '.swatch-attribute.%s .swatch-attribute-selected-option'; + + /** + * Get chosen options from the product view page. + * + * @param InjectableFixture $product + * @return array + */ + public function getSelectedSwatchOptions(InjectableFixture $product) + { + $checkoutData = $product->getCheckoutData(); + $availableAttributes = $product->getConfigurableAttributesData(); + $attributesData = $availableAttributes['attributes_data']; + $formData = []; + foreach ($checkoutData['options']['configurable_options'] as $item) { + $selector = sprintf($this->swatchAttributeSelector, $attributesData[$item['title']]['attribute_code']); + $this->waitForElementVisible($selector); + $selected = $this->_rootElement->find($selector)->getText(); + $formData[$item['title']] = $selected; + } + + return $formData; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Swatches/Test/Constraint/AssertSwatchConfigurableProductPage.php b/dev/tests/functional/tests/app/Magento/Swatches/Test/Constraint/AssertSwatchConfigurableProductPage.php new file mode 100644 index 0000000000000000000000000000000000000000..460a13ce49d704f30f513af5c8f3189c45f3ffc4 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Swatches/Test/Constraint/AssertSwatchConfigurableProductPage.php @@ -0,0 +1,97 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Swatches\Test\Constraint; + +use Magento\Catalog\Test\Constraint\AssertProductPage; +use Magento\Mtf\Fixture\FixtureInterface; +use Magento\Catalog\Test\Page\Product\CatalogProductView; +use Magento\Mtf\Client\BrowserInterface; + +/** + * Assert that product with swatches and regular dropdown redirect can't be add to cart from catalog catergory page. + */ +class AssertSwatchConfigurableProductPage extends AssertProductPage +{ + /** + * {@inheritdoc} + */ + public function processAssert( + BrowserInterface $browser, + CatalogProductView $catalogProductView, + FixtureInterface $product + ) { + $this->product = $product; + $this->productView = $catalogProductView->getProductViewWithSwatchesBlock(); + $this->objectManager->create( + \Magento\Swatches\Test\TestStep\AddProductToCartFromCatalogCategoryPageStep::class, + [ + 'product' => $product + ] + )->run(); + // we need this line for waiti until page will be fully loaded + $this->productView->getSelectedSwatchOptions($this->product); + $errors = $this->verify(); + \PHPUnit_Framework_Assert::assertEmpty( + $errors, + "\nFound the following errors:\n" . implode(" \n", $errors) + ); + } + + /** + * Verify product on product view page. + * + * @return array + */ + protected function verify() + { + $errors = parent::verify(); + $errors[] = $this->verifySwatches(); + + return array_filter($errors); + } + + /** + * Verify selected swatches on product view page. + * + * @return array + */ + protected function verifySwatches() + { + $actualData = $this->productView->getSelectedSwatchOptions($this->product); + $expectedData = $this->convertCheckoutData($this->product); + $this->verifyData($expectedData, $actualData); + } + + /** + * Get swatch attributes formatter to attributes comparison. + * + * @param FixtureInterface $product + * @return array + */ + public function convertCheckoutData(FixtureInterface $product) + { + $out = []; + $checkoutData = $product->getCheckoutData(); + $availableAttributes = $product->getConfigurableAttributesData(); + $attributesData = $availableAttributes['attributes_data']; + foreach ($checkoutData['options']['configurable_options'] as $item) { + $out[$item['title']] = $attributesData[$item['title']]['options'][$item['value']]['label']; + } + + return $out; + } + + /** + * Return string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Swatch attributes displayed as expected on product page'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Swatches/Test/Fixture/Cart/Item.php b/dev/tests/functional/tests/app/Magento/Swatches/Test/Fixture/Cart/Item.php new file mode 100644 index 0000000000000000000000000000000000000000..46c9b383ae8420c5210a3d4f71ac49b3513b1724 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Swatches/Test/Fixture/Cart/Item.php @@ -0,0 +1,17 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Swatches\Test\Fixture\Cart; + +use Magento\ConfigurableProduct\Test\Fixture\Cart\Item as ConfigurableCart; + +/** + * @inheritdoc + */ +class Item extends ConfigurableCart +{ + // +} diff --git a/dev/tests/functional/tests/app/Magento/Swatches/Test/Fixture/ConfigurableProduct.xml b/dev/tests/functional/tests/app/Magento/Swatches/Test/Fixture/ConfigurableProduct.xml new file mode 100644 index 0000000000000000000000000000000000000000..dbc57a321a68238adff45355fd87a4e97028cde2 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Swatches/Test/Fixture/ConfigurableProduct.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/fixture.xsd"> + <fixture + name="configurableProductSwatch" + module="Magento_Swatches" + class="Magento\Swatches\Test\Fixture\ConfigurableProduct" + extends="\Magento\ConfigurableProduct\Test\Fixture\ConfigurableProduct" + > + </fixture> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Swatches/Test/Fixture/SwatchProductAttribute.xml b/dev/tests/functional/tests/app/Magento/Swatches/Test/Fixture/SwatchProductAttribute.xml new file mode 100644 index 0000000000000000000000000000000000000000..d96331b8159d50a60f6aa215d523d492aa5de7a4 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Swatches/Test/Fixture/SwatchProductAttribute.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/fixture.xsd"> + <fixture name="swatchesProductAttribute" + module="Magento_Swatches" + handler_interface="Magento\Swatches\Test\Handler\SwatchProductAttribute\SwatchProductAttributeInterface" + repository_class="Magento\Swatches\Test\Repository\SwatchProductAttribute" + class="Magento\Swatches\Test\Fixture\SwatchesProductAttribute" + extends="\Magento\Catalog\Test\Fixture\CatalogProductAttribute"> + </fixture> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Swatches/Test/Handler/SwatchProductAttribute/Curl.php b/dev/tests/functional/tests/app/Magento/Swatches/Test/Handler/SwatchProductAttribute/Curl.php new file mode 100644 index 0000000000000000000000000000000000000000..86de2d651da1ecf3d48fdb165de0b223a665f126 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Swatches/Test/Handler/SwatchProductAttribute/Curl.php @@ -0,0 +1,49 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Swatches\Test\Handler\SwatchProductAttribute; + +use Magento\Catalog\Test\Handler\CatalogProductAttribute\Curl as CatalogProductAttributeCurl; +use Magento\Mtf\Config\DataInterface; +use Magento\Mtf\System\Event\EventManagerInterface; + +/** + * Curl handler for creating Swatch Attribute. + */ +class Curl extends CatalogProductAttributeCurl implements SwatchProductAttributeInterface +{ + /** + * Add mapping data related to swatches. + * + * @param DataInterface $configuration + * @param EventManagerInterface $eventManager + */ + public function __construct(DataInterface $configuration, EventManagerInterface $eventManager) + { + parent::__construct($configuration, $eventManager); + $this->mappingData['frontend_input'] = [ + 'Text Swatch' => 'swatch_text', + ]; + } + + /** + * Re-map options from default options structure to swatches structure, + * as swatches was initially created with name convention differ from other attributes. + * + * @param array $data + * @return array + */ + protected function changeStructureOfTheData(array $data) + { + $data = parent::changeStructureOfTheData($data); + $data['optiontext'] = $data['option']; + $data['swatchtext'] = [ + 'value' => $data['option']['value'] + ]; + unset($data['option']); + return $data; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Swatches/Test/Handler/SwatchProductAttribute/SwatchProductAttributeInterface.php b/dev/tests/functional/tests/app/Magento/Swatches/Test/Handler/SwatchProductAttribute/SwatchProductAttributeInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..41fdebdd5ce8b084eca0a40c58aeba580a7b3518 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Swatches/Test/Handler/SwatchProductAttribute/SwatchProductAttributeInterface.php @@ -0,0 +1,17 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Swatches\Test\Handler\SwatchProductAttribute; + +use Magento\Mtf\Handler\HandlerInterface; + +/** + * Interface for swatch specific Curl calls + */ +interface SwatchProductAttributeInterface extends HandlerInterface +{ + // +} diff --git a/dev/tests/functional/tests/app/Magento/Swatches/Test/Page/Category/CatalogCategoryView.xml b/dev/tests/functional/tests/app/Magento/Swatches/Test/Page/Category/CatalogCategoryView.xml new file mode 100644 index 0000000000000000000000000000000000000000..9cb5e4fbdf69756a5289555e15d568f577bbf21d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Swatches/Test/Page/Category/CatalogCategoryView.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> + <page name="CatalogCategoryView" area="Category" mca="catalog/category/view" module="Magento_Catalog"> + <block name="listSwatchesProductBlock" class="Magento\Swatches\Test\Block\Product\ListProduct" locator=".products.wrapper.grid" strategy="css selector"/> + </page> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Swatches/Test/Page/Product/CatalogProductView.xml b/dev/tests/functional/tests/app/Magento/Swatches/Test/Page/Product/CatalogProductView.xml new file mode 100644 index 0000000000000000000000000000000000000000..315c6a02ee968e6bc93ec52bd5555d65be3f87d7 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Swatches/Test/Page/Product/CatalogProductView.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> + <page name="CatalogProductView" area="Product" mca="catalog/product/view"> + <block name="productViewWithSwatchesBlock" class="Magento\Swatches\Test\Block\Product\ViewWithSwatches" locator="#maincontent" strategy="css selector" /> + </page> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Swatches/Test/Repository/ConfigurableProduct.xml b/dev/tests/functional/tests/app/Magento/Swatches/Test/Repository/ConfigurableProduct.xml new file mode 100644 index 0000000000000000000000000000000000000000..22e73572ead0d9081b3bdf15c78f75df12409a3c --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Swatches/Test/Repository/ConfigurableProduct.xml @@ -0,0 +1,83 @@ +<?xml version="1.0" ?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd"> + <repository class="Magento\ConfigurableProduct\Test\Repository\ConfigurableProduct"> + <dataset name="product_with_text_swatch"> + <field name="name" xsi:type="string">Test configurable product with color and size %isolation%</field> + <field name="sku" xsi:type="string">sku_test_configurable_product_%isolation%</field> + <field name="product_has_weight" xsi:type="string">This item has weight</field> + <field name="weight" xsi:type="string">30</field> + <field name="status" xsi:type="string">Yes</field> + <field name="visibility" xsi:type="string">Catalog, Search</field> + <field name="tax_class_id" xsi:type="array"> + <item name="dataset" xsi:type="string">taxable_goods</item> + </field> + <field name="url_key" xsi:type="string">configurable-product-%isolation%</field> + <field name="configurable_attributes_data" xsi:type="array"> + <item name="dataset" xsi:type="string">text_swatch</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="category_ids" xsi:type="array"> + <item name="dataset" xsi:type="string">default_subcategory</item> + </field> + <field name="website_ids" xsi:type="array"> + <item name="0" xsi:type="array"> + <item name="dataset" xsi:type="string">default</item> + </item> + </field> + <field name="attribute_set_id" xsi:type="array"> + <item name="dataset" xsi:type="string">custom_attribute_set</item> + </field> + <field name="price" xsi:type="array"> + <item name="value" xsi:type="string">40</item> + <item name="dataset" xsi:type="string">price_40</item> + </field> + <field name="checkout_data" xsi:type="array"> + <item name="dataset" xsi:type="string">two_text_swatches</item> + </field> + </dataset> + <dataset name="product_with_text_swatch_and_size"> + <field name="name" xsi:type="string">Test configurable product with color and size %isolation%</field> + <field name="sku" xsi:type="string">sku_test_configurable_product_%isolation%</field> + <field name="product_has_weight" xsi:type="string">This item has weight</field> + <field name="weight" xsi:type="string">30</field> + <field name="status" xsi:type="string">Yes</field> + <field name="visibility" xsi:type="string">Catalog, Search</field> + <field name="tax_class_id" xsi:type="array"> + <item name="dataset" xsi:type="string">taxable_goods</item> + </field> + <field name="url_key" xsi:type="string">configurable-product-%isolation%</field> + <field name="configurable_attributes_data" xsi:type="array"> + <item name="dataset" xsi:type="string">text_swatch_with_dropdown</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="category_ids" xsi:type="array"> + <item name="dataset" xsi:type="string">default_subcategory</item> + </field> + <field name="website_ids" xsi:type="array"> + <item name="0" xsi:type="array"> + <item name="dataset" xsi:type="string">default</item> + </item> + </field> + <field name="attribute_set_id" xsi:type="array"> + <item name="dataset" xsi:type="string">custom_attribute_set</item> + </field> + <field name="price" xsi:type="array"> + <item name="value" xsi:type="string">40</item> + <item name="dataset" xsi:type="string">price_40</item> + </field> + <field name="checkout_data" xsi:type="array"> + <item name="dataset" xsi:type="string">swatches_with_dropdown</item> + </field> + </dataset> + </repository> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Swatches/Test/Repository/ConfigurableProduct/CheckoutData.xml b/dev/tests/functional/tests/app/Magento/Swatches/Test/Repository/ConfigurableProduct/CheckoutData.xml new file mode 100644 index 0000000000000000000000000000000000000000..9b369d5a536f0de9e41bb302910526dd8f5023fb --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Swatches/Test/Repository/ConfigurableProduct/CheckoutData.xml @@ -0,0 +1,47 @@ +<?xml version="1.0" ?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd"> + <repository class="Magento\ConfigurableProduct\Test\Repository\ConfigurableProduct\CheckoutData"> + <dataset name="two_text_swatches"> + <field name="options" xsi:type="array"> + <item name="configurable_options" xsi:type="array"> + <item name="0" xsi:type="array"> + <item name="title" xsi:type="string">attribute_key_0</item> + <item name="value" xsi:type="string">option_key_1</item> + </item> + <item name="1" xsi:type="array"> + <item name="title" xsi:type="string">attribute_key_1</item> + <item name="value" xsi:type="string">option_key_2</item> + </item> + </item> + </field> + <field name="qty" xsi:type="string">1</field> + <field name="cartItem" xsi:type="array"> + <item name="price" xsi:type="string">42</item> + <item name="qty" xsi:type="string">1</item> + <item name="subtotal" xsi:type="string">47</item> + </field> + </dataset> + <dataset name="swatches_with_dropdown"> + <field name="options" xsi:type="array"> + <item name="configurable_options" xsi:type="array"> + <item name="0" xsi:type="array"> + <item name="title" xsi:type="string">attribute_key_0</item> + <item name="value" xsi:type="string">option_key_1</item> + </item> + </item> + </field> + <field name="qty" xsi:type="string">1</field> + <field name="cartItem" xsi:type="array"> + <item name="price" xsi:type="string">42</item> + <item name="qty" xsi:type="string">1</item> + <item name="subtotal" xsi:type="string">47</item> + </field> + </dataset> + </repository> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Swatches/Test/Repository/ConfigurableProduct/ConfigurableAttributesData.xml b/dev/tests/functional/tests/app/Magento/Swatches/Test/Repository/ConfigurableProduct/ConfigurableAttributesData.xml new file mode 100644 index 0000000000000000000000000000000000000000..492fda6b751c664bdfde231d813a866e24073f7b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Swatches/Test/Repository/ConfigurableProduct/ConfigurableAttributesData.xml @@ -0,0 +1,151 @@ +<?xml version="1.0" ?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd"> + <repository class="Magento\ConfigurableProduct\Test\Repository\ConfigurableProduct\ConfigurableAttributesData"> + <dataset name="text_swatch"> + <field name="attributes_data" xsi:type="array"> + <item name="attribute_key_0" xsi:type="array"> + <item name="options" xsi:type="array"> + <item name="option_key_0" xsi:type="array"> + <item name="pricing_value" xsi:type="string">12.00</item> + <item name="include" xsi:type="string">Yes</item> + </item> + <item name="option_key_1" xsi:type="array"> + <item name="pricing_value" xsi:type="string">20.00</item> + <item name="include" xsi:type="string">Yes</item> + </item> + <item name="option_key_2" xsi:type="array"> + <item name="pricing_value" xsi:type="string">18.00</item> + <item name="include" xsi:type="string">Yes</item> + </item> + </item> + </item> + <item name="attribute_key_1" xsi:type="array"> + <item name="options" xsi:type="array"> + <item name="option_key_0" xsi:type="array"> + <item name="pricing_value" xsi:type="string">42.00</item> + <item name="include" xsi:type="string">Yes</item> + </item> + <item name="option_key_1" xsi:type="array"> + <item name="pricing_value" xsi:type="string">40.00</item> + <item name="include" xsi:type="string">Yes</item> + </item> + <item name="option_key_2" xsi:type="array"> + <item name="pricing_value" xsi:type="string">48.00</item> + <item name="include" xsi:type="string">Yes</item> + </item> + </item> + </item> + </field> + <field name="attributes" xsi:type="array"> + <item name="attribute_key_0" xsi:type="string">swatchesProductAttribute::attribute_type_text_swatch</item> + <item name="attribute_key_1" xsi:type="string">swatchesProductAttribute::attribute_type_text_swatch</item> + </field> + <field name="matrix" xsi:type="array"> + <item name="attribute_key_0:option_key_0 attribute_key_1:option_key_0" xsi:type="array"> + <item name="qty" xsi:type="string">10</item> + <item name="weight" xsi:type="string">1</item> + </item> + <item name="attribute_key_0:option_key_0 attribute_key_1:option_key_1" xsi:type="array"> + <item name="qty" xsi:type="string">10</item> + <item name="weight" xsi:type="string">1</item> + </item> + <item name="attribute_key_0:option_key_0 attribute_key_1:option_key_2" xsi:type="array"> + <item name="qty" xsi:type="string">10</item> + <item name="weight" xsi:type="string">1</item> + </item> + <item name="attribute_key_0:option_key_1 attribute_key_1:option_key_0" xsi:type="array"> + <item name="qty" xsi:type="string">10</item> + <item name="weight" xsi:type="string">1</item> + </item> + <item name="attribute_key_0:option_key_1 attribute_key_1:option_key_1" xsi:type="array"> + <item name="qty" xsi:type="string">10</item> + <item name="weight" xsi:type="string">1</item> + </item> + <item name="attribute_key_0:option_key_1 attribute_key_1:option_key_2" xsi:type="array"> + <item name="qty" xsi:type="string">10</item> + <item name="weight" xsi:type="string">1</item> + </item> + <item name="attribute_key_0:option_key_2 attribute_key_1:option_key_0" xsi:type="array"> + <item name="qty" xsi:type="string">10</item> + <item name="weight" xsi:type="string">1</item> + </item> + <item name="attribute_key_0:option_key_2 attribute_key_1:option_key_1" xsi:type="array"> + <item name="qty" xsi:type="string">10</item> + <item name="weight" xsi:type="string">1</item> + </item> + <item name="attribute_key_0:option_key_2 attribute_key_1:option_key_2" xsi:type="array"> + <item name="qty" xsi:type="string">10</item> + <item name="weight" xsi:type="string">1</item> + </item> + </field> + </dataset> + <dataset name="text_swatch_with_dropdown"> + <field name="attributes_data" xsi:type="array"> + <item name="attribute_key_0" xsi:type="array"> + <item name="options" xsi:type="array"> + <item name="option_key_0" xsi:type="array"> + <item name="pricing_value" xsi:type="string">12.00</item> + <item name="include" xsi:type="string">Yes</item> + </item> + <item name="option_key_1" xsi:type="array"> + <item name="pricing_value" xsi:type="string">20.00</item> + <item name="include" xsi:type="string">Yes</item> + </item> + <item name="option_key_2" xsi:type="array"> + <item name="pricing_value" xsi:type="string">18.00</item> + <item name="include" xsi:type="string">Yes</item> + </item> + </item> + </item> + <item name="attribute_key_1" xsi:type="array"> + <item name="options" xsi:type="array"> + <item name="option_key_0" xsi:type="array"> + <item name="pricing_value" xsi:type="string">42.00</item> + <item name="include" xsi:type="string">Yes</item> + </item> + <item name="option_key_1" xsi:type="array"> + <item name="pricing_value" xsi:type="string">40.00</item> + <item name="include" xsi:type="string">Yes</item> + </item> + </item> + </item> + </field> + <field name="attributes" xsi:type="array"> + <item name="attribute_key_0" xsi:type="string">swatchesProductAttribute::attribute_type_text_swatch</item> + <item name="attribute_key_1" xsi:type="string">catalogProductAttribute::size</item> + </field> + <field name="matrix" xsi:type="array"> + <item name="attribute_key_0:option_key_0 attribute_key_1:option_key_0" xsi:type="array"> + <item name="qty" xsi:type="string">10</item> + <item name="weight" xsi:type="string">1</item> + </item> + <item name="attribute_key_0:option_key_0 attribute_key_1:option_key_1" xsi:type="array"> + <item name="qty" xsi:type="string">10</item> + <item name="weight" xsi:type="string">1</item> + </item> + <item name="attribute_key_0:option_key_1 attribute_key_1:option_key_0" xsi:type="array"> + <item name="qty" xsi:type="string">10</item> + <item name="weight" xsi:type="string">1</item> + </item> + <item name="attribute_key_0:option_key_1 attribute_key_1:option_key_1" xsi:type="array"> + <item name="qty" xsi:type="string">10</item> + <item name="weight" xsi:type="string">1</item> + </item> + <item name="attribute_key_0:option_key_2 attribute_key_1:option_key_0" xsi:type="array"> + <item name="qty" xsi:type="string">10</item> + <item name="weight" xsi:type="string">1</item> + </item> + <item name="attribute_key_0:option_key_2 attribute_key_1:option_key_1" xsi:type="array"> + <item name="qty" xsi:type="string">10</item> + <item name="weight" xsi:type="string">1</item> + </item> + </field> + </dataset> + </repository> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Swatches/Test/Repository/SwatchProductAttribute.xml b/dev/tests/functional/tests/app/Magento/Swatches/Test/Repository/SwatchProductAttribute.xml new file mode 100644 index 0000000000000000000000000000000000000000..fc92146861d1e89e5ef32666c67b8c63882d9691 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Swatches/Test/Repository/SwatchProductAttribute.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" ?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd"> + <repository class="Magento\Swatches\Test\Repository\SwatchProductAttribute"> + <dataset name="attribute_type_text_swatch"> + <field name="attribute_code" xsi:type="string">sw_color%isolation%</field> + <field name="frontend_input" xsi:type="string" >Text Swatch</field> + <field name="frontend_label" xsi:type="string" >Text Swatch</field> + <field name="options" xsi:type="array"> + <item name="0" xsi:type="array"> + <item name="is_default" xsi:type="string">No</item> + <item name="admin" xsi:type="string">R</item> + <item name="view" xsi:type="string">R</item> + </item> + <item name="1" xsi:type="array"> + <item name="is_default" xsi:type="string">No</item> + <item name="admin" xsi:type="string">G</item> + <item name="view" xsi:type="string">G</item> + </item> + <item name="2" xsi:type="array"> + <item name="is_default" xsi:type="string">No</item> + <item name="admin" xsi:type="string">B</item> + <item name="view" xsi:type="string">B</item> + </item> + </field> + <field name="is_global" xsi:type="string">Global</field> + <field name="used_in_product_listing" xsi:type="string">Yes</field> + </dataset> + </repository> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Swatches/Test/TestCase/AddConfigurableProductWithSwatchToShopingCartTest.php b/dev/tests/functional/tests/app/Magento/Swatches/Test/TestCase/AddConfigurableProductWithSwatchToShopingCartTest.php new file mode 100644 index 0000000000000000000000000000000000000000..60cc61f7f0f79319336d57d0d81289de6fe31cab --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Swatches/Test/TestCase/AddConfigurableProductWithSwatchToShopingCartTest.php @@ -0,0 +1,38 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Swatches\Test\TestCase; + +use Magento\Mtf\TestCase\Scenario; + +/** + * Preconditions: + * 1. Configure text swatch attribute. + * 2. Create configurable product with this attribute + * 3. Open it on catalog page + * 4. Click on 'Add to Cart' button + * + * Steps: + * 1. Go to Frontend. + * 2. Open category page with created product + * 3. Click on 'Add to Cart' button + * 4. Perform asserts + * + * @group Configurable_Product + * @ZephyrId MAGETWO-59958 + */ +class AddConfigurableProductWithSwatchToShopingCartTest extends Scenario +{ + /** + * Runs add configurable product with swatches attributes test. + * + * @return void + */ + public function test() + { + $this->executeScenario(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Swatches/Test/TestCase/AddConfigurableProductWithSwatchToShopingCartTest.xml b/dev/tests/functional/tests/app/Magento/Swatches/Test/TestCase/AddConfigurableProductWithSwatchToShopingCartTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..adf8d71395ccb9c4b714ad58887ec741391871a2 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Swatches/Test/TestCase/AddConfigurableProductWithSwatchToShopingCartTest.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Swatches\Test\TestCase\AddConfigurableProductWithSwatchToShopingCartTest" summary="Create text swatch attribute" ticketId="MAGETWO-47017"> + <variation name="AddConfigurableProductWithSwatchToShopingCartTest1"> + <data name="attributeTypeAction" xsi:type="string">addOptions</data> + <data name="product" xsi:type="string">configurableProductSwatch::product_with_text_swatch</data> + <constraint name="Magento\Checkout\Test\Constraint\AssertCartItemsOptions" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Swatches/Test/TestCase/TryToAddConfigurableProductWithSwatchToShopingCartTest.php b/dev/tests/functional/tests/app/Magento/Swatches/Test/TestCase/TryToAddConfigurableProductWithSwatchToShopingCartTest.php new file mode 100644 index 0000000000000000000000000000000000000000..ac3016ade3f016b82a856677715db6c93736c1ef --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Swatches/Test/TestCase/TryToAddConfigurableProductWithSwatchToShopingCartTest.php @@ -0,0 +1,38 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Swatches\Test\TestCase; + +use Magento\Mtf\TestCase\Scenario; + +/** + * Preconditions: + * 1. Configure text swatch attribute. + * 2. Create configurable product with this attribute + * 3. Open it on catalog page + * 4. Click on 'Add to Cart' button + * + * Steps: + * 1. Go to Frontend. + * 2. Open category page with created product + * 3. Click on 'Add to Cart' button + * 4. Perform asserts + * + * @group Configurable_Product + * @ZephyrId TODO: MAGETWO-59979 + */ +class TryToAddConfigurableProductWithSwatchToShopingCartTest extends Scenario +{ + /** + * Runs add configurable product with swatches attributes test. + * + * @return void + */ + public function test() + { + $this->executeScenario(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Swatches/Test/TestCase/TryToAddConfigurableProductWithSwatchToShopingCartTest.xml b/dev/tests/functional/tests/app/Magento/Swatches/Test/TestCase/TryToAddConfigurableProductWithSwatchToShopingCartTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..4cb7a3e01676f09c6c3e6b9ffcd3d85fb9abbe4a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Swatches/Test/TestCase/TryToAddConfigurableProductWithSwatchToShopingCartTest.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Swatches\Test\TestCase\TryToAddConfigurableProductWithSwatchToShopingCartTest" summary="Create text swatch attribute" ticketId="MAGETWO-47017"> + <variation name="TryToAddConfigurableProductWithSwatchToShopingCartTest1"> + <data name="attributeTypeAction" xsi:type="string">addOptions</data> + <data name="product" xsi:type="string">configurableProductSwatch::product_with_text_swatch_and_size</data> + <constraint name="Magento\Swatches\Test\Constraint\AssertSwatchConfigurableProductPage" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Swatches/Test/TestStep/AddProductToCartFromCatalogCategoryPageStep.php b/dev/tests/functional/tests/app/Magento/Swatches/Test/TestStep/AddProductToCartFromCatalogCategoryPageStep.php new file mode 100644 index 0000000000000000000000000000000000000000..e19f9d7b3c362ca61d5869ea409c20359b4b4ffb --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Swatches/Test/TestStep/AddProductToCartFromCatalogCategoryPageStep.php @@ -0,0 +1,96 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Swatches\Test\TestStep; + +use Magento\Mtf\TestStep\TestStepInterface; +use Magento\Mtf\Fixture\FixtureFactory; +use Magento\Swatches\Test\Block\Product\ProductList\ProductItem; +use Magento\Mtf\Fixture\InjectableFixture; +use Magento\Catalog\Test\Page\Category\CatalogCategoryView; +use Magento\Cms\Test\Page\CmsIndex; + +/** + * Add configurable product to cart. + */ +class AddProductToCartFromCatalogCategoryPageStep implements TestStepInterface +{ + /** + * Fixture of configurable product with swatches configuration. + * + * @var \Magento\Swatches\Test\Fixture\ConfigurableProduct + */ + private $product; + + /** + * Fixture factory for create/get fixtures. + * + * @var FixtureFactory + */ + private $fixtureFactory; + + /** + * Page of catalog category view. + * + * @var CatalogCategoryView + */ + private $categoryView; + + /** + * CMS index page. + * + * @var CmsIndex + */ + private $cmsIndex; + + /** + * @constructor + * @param FixtureFactory $fixtureFactory + * @param CmsIndex $cmsIndex + * @param InjectableFixture $product + * @param CatalogCategoryView $categoryView + */ + public function __construct( + FixtureFactory $fixtureFactory, + CmsIndex $cmsIndex, + CatalogCategoryView $categoryView, + InjectableFixture $product + ) { + $this->fixtureFactory = $fixtureFactory; + $this->cmsIndex = $cmsIndex; + $this->categoryView = $categoryView; + $this->product = $product; + } + + /** + * Update configurable product. + * + * @return array + */ + public function run() + { + $categoryName = $this->product->getCategoryIds()[0]; + $this->cmsIndex->open(); + $this->cmsIndex->getTopmenu()->selectCategoryByName($categoryName); + /** @var \Magento\Swatches\Test\Block\Product\ListProduct $productsList */ + $productsList = $this->categoryView->getListSwatchesProductBlock(); + /** @var ProductItem $productItemBlock */ + $productItemBlock = $productsList->getProductItem($this->product); + $productItemBlock->fillData($this->product); + $productItemBlock->clickAddToCart(); + $cart = [ + 'data' => [ + 'items' => [ + 'products' => [$this->product] + ] + ] + ]; + + return [ + 'cart' => $this->fixtureFactory->createByCode('cart', $cart) + ]; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Swatches/Test/etc/curl/di.xml b/dev/tests/functional/tests/app/Magento/Swatches/Test/etc/curl/di.xml new file mode 100644 index 0000000000000000000000000000000000000000..ac3ad40f804e1abac634c135228d89fca3a90876 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Swatches/Test/etc/curl/di.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" ?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> + <preference for="Magento\Swatches\Test\Handler\SwatchProductAttribute\SwatchProductAttributeInterface" type="\Magento\Swatches\Test\Handler\SwatchProductAttribute\Curl" /> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Swatches/Test/etc/testcase.xml b/dev/tests/functional/tests/app/Magento/Swatches/Test/etc/testcase.xml new file mode 100644 index 0000000000000000000000000000000000000000..f2e30c42a7a859e52ad129eda213aa8b1e597aad --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Swatches/Test/etc/testcase.xml @@ -0,0 +1,16 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/TestCase/etc/testcase.xsd"> + <scenario name="AddConfigurableProductWithSwatchToShopingCartTest" firstStep="createProduct"> + <step name="createProduct" module="Magento_Catalog" next="addProductToCartFromCatalogCategoryPage" /> + <step name="addProductToCartFromCatalogCategoryPage" module="Magento_Swatches" /> + </scenario> + <scenario name="TryToAddConfigurableProductWithSwatchToShopingCartTest" firstStep="createProduct"> + <step name="createProduct" module="Magento_Catalog" /> + </scenario> +</config>