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/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 211e09861995f27e22a446b93e465a7197936965..e5497a5a33a0dc6e3c197defdcce8d53ff3ea95f 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 @@ -446,5 +446,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/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); + } +}