Skip to content
This repository has been archived by the owner on May 20, 2019. It is now read-only.

Commit

Permalink
Merge pull request #8 from magento/2.2-develop
Browse files Browse the repository at this point in the history
New pull request
  • Loading branch information
ronak2ram authored Jul 20, 2018
2 parents e324c0d + 45a7e0c commit 38c27fb
Show file tree
Hide file tree
Showing 103 changed files with 2,683 additions and 532 deletions.
4 changes: 4 additions & 0 deletions app/code/Magento/Bundle/Test/Mftf/Data/BundleProductData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@
<entity name="BundleProduct" type="product">
<data key="type_id">bundle</data>
<data key="attribute_set_id">4</data>
<data key="optionTitle1">BundleOption</data>
<data key="optionInputType1">checkbox</data>
<data key="defaultQuantity">10</data>
<data key="name" unique="suffix">BundleProduct</data>
<data key="sku" unique="suffix">BundleProduct</data>
<data key="status">1</data>
<data key="urlKey" unique="suffix">bundleproduct</data>
<data key="visibility">4</data>
<data key="option_title" unique="suffix">TestOption</data>
<data key="input_type" >Drop-down</data>
Expand Down
14 changes: 14 additions & 0 deletions app/code/Magento/Bundle/Test/Mftf/Page/AdminProductCreatePage.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/PageObject.xsd">
<page name="AdminProductCreatePage" url="catalog/product/new/set/{{set}}/type/{{type}}/" area="admin" module="Magento_Catalog" parameterized="true">
<section name="AdminProductFormBundleSection"/>
</page>
</pages>
14 changes: 14 additions & 0 deletions app/code/Magento/Bundle/Test/Mftf/Page/StorefrontProductPage.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/PageObject.xsd">
<page name="StorefrontProductPage" url="/{{var1}}.html" area="storefront" module="Magento_Catalog" parameterized="true">
<section name="StorefrontBundledSection"/>
</page>
</pages>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
<section name="AdminProductFormBundleSection">
<element name="bundleItemsToggle" type="button" selector="//span[text()='Bundle Items']"/>
<element name="addOption" type="button" selector="button[data-index='add_button']"/>
<element name="bundleOptionXTitle" type="input" selector="[name='bundle_options[bundle_options][{{x}}][title]']" parameterized="true"/>
<element name="bundleOptionXInputType" type="select" selector="[name='bundle_options[bundle_options][{{x}}][type]']" parameterized="true"/>
<element name="addProductsToOption" type="button" selector="[data-index='modal_set']" timeout="30"/>
<element name="bundleOptionXProductYQuantity" type="input" selector="[name='bundle_options[bundle_options][{{x}}][bundle_selections][{{y}}][selection_qty]']" parameterized="true"/>
<element name="bundledItems" type="block" selector="[data-index=bundle-items]"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
<section name="StorefrontBundledSection">
<element name="bundleOption" type="input" selector=".option:nth-of-type({{numOption}}) .choice:nth-of-type({{numOptionSelect}}) input" parameterized="true"/>
<element name="addToCart" type="button" selector="#bundle-slide" timeout="30"/>
<element name="addToCartConfigured" type="button" selector="#product-addtocart-button" timeout="30"/>
<element name="updateCart" type="button" selector="#product-updatecart-button" timeout="30"/>
<element name="configuredPrice" type="block" selector=".price-configured_price .price"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
<test name="StorefrontEditBundleProductTest">
<annotations>
<features value="Bundle"/>
<stories value="Bundle products list on Storefront"/>
<title value="Customer should be able to change chosen options for Bundle Product when clicking Edit button in Shopping Cart page"/>
<description value="Customer should be able to change chosen options for Bundle Product when clicking Edit button in Shopping Cart page"/>
<severity value="MAJOR"/>
<testCaseId value="MAGETWO-77523"/>
<group value="bundle"/>
</annotations>
<before>
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
<createData entity="SimpleProduct3" stepKey="simpleProduct1"/>
<createData entity="SimpleProduct3" stepKey="simpleProduct2"/>
</before>
<after>
<actionGroup ref="logout" stepKey="logoutFromAdmin"/>
<deleteData createDataKey="simpleProduct1" stepKey="deleteSimpleProduct1"/>
<deleteData createDataKey="simpleProduct2" stepKey="deleteSimpleProduct2"/>
</after>

<!-- Create a bundle product -->
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="visitAdminProductPageBundle"/>
<waitForPageLoad stepKey="waitForProductPageLoadBundle"/>
<actionGroup ref="goToCreateProductPage" stepKey="goToCreateBundleProduct">
<argument name="product" value="BundleProduct"/>
</actionGroup>

<actionGroup ref="fillProductNameAndSkuInProductForm" stepKey="fillBundleProductNameAndSku">
<argument name="product" value="BundleProduct"/>
</actionGroup>

<!-- Add two bundle items -->
<conditionalClick selector="{{AdminProductFormBundleSection.bundleItemsToggle}}" dependentSelector="{{AdminProductFormBundleSection.bundleItemsToggle}}" visible="false" stepKey="conditionallyOpenSectionBundleItems"/>
<scrollTo selector="{{AdminProductFormBundleSection.bundledItems}}" stepKey="scrollToBundleItems"/>
<click selector="{{AdminProductFormBundleSection.addOption}}" stepKey="clickAddOption3"/>
<waitForElementVisible selector="{{AdminProductFormBundleSection.bundleOptionXTitle('0')}}" stepKey="waitForBundleOptions"/>
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXTitle('0')}}" userInput="{{BundleProduct.optionTitle1}}" stepKey="fillOptionTitle"/>
<selectOption selector="{{AdminProductFormBundleSection.bundleOptionXInputType('0')}}" userInput="{{BundleProduct.optionInputType1}}" stepKey="selectInputType"/>
<waitForElementVisible selector="{{AdminProductFormBundleSection.addProductsToOption}}" stepKey="waitForAddProductsToBundle"/>
<click selector="{{AdminProductFormBundleSection.addProductsToOption}}" stepKey="clickAddProductsToOption"/>
<waitForPageLoad stepKey="waitForPageLoadAfterBundleProducts"/>
<actionGroup ref="filterProductGridBySku" stepKey="filterBundleProductOptions">
<argument name="product" value="$$simpleProduct1$$"/>
</actionGroup>
<checkOption selector="{{AdminAddProductsToOptionPanelSection.firstCheckbox}}" stepKey="selectFirstGridRow"/>
<actionGroup ref="filterProductGridBySku" stepKey="filterBundleProductOptions2">
<argument name="product" value="$$simpleProduct2$$"/>
</actionGroup>
<checkOption selector="{{AdminAddProductsToOptionPanelSection.firstCheckbox}}" stepKey="selectFirstGridRow2"/>
<click selector="{{AdminAddProductsToOptionPanelSection.addSelectedProducts}}" stepKey="clickAddSelectedBundleProducts"/>
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '0')}}" userInput="{{BundleProduct.defaultQuantity}}" stepKey="fillProductDefaultQty1"/>
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '1')}}" userInput="{{BundleProduct.defaultQuantity}}" stepKey="fillProductDefaultQty2"/>

<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveProductBundle"/>
<see selector="{{AdminProductMessagesSection.successMessage}}" userInput="You saved the product." stepKey="assertSuccess"/>

<!-- Go to the storefront bundled product page -->
<amOnPage url="/{{BundleProduct.urlKey}}.html" stepKey="visitStoreFrontBundle"/>
<waitForPageLoad stepKey="waitForStorefront"/>
<click selector="{{StorefrontBundledSection.addToCart}}" stepKey="customizeAndAddToCart"/>
<waitForPageLoad stepKey="waitCustomizableOptionsPopUp"/>

<!-- add two products to the shopping cart, each with one different option -->
<click selector="{{StorefrontBundledSection.bundleOption('1','1')}}" stepKey="selectFirstBundleOption"/>
<waitForPageLoad stepKey="waitForPriceUpdate"/>
<see selector="{{StorefrontBundledSection.configuredPrice}}" userInput="1,230.00" stepKey="seeSinglePrice"/>
<click selector="{{StorefrontBundledSection.addToCartConfigured}}" stepKey="addFirstItemToCart"/>
<waitForPageLoad stepKey="waitForElementAdded"/>

<click selector="{{StorefrontBundledSection.bundleOption('1','1')}}" stepKey="unselectFirstBundleOption"/>
<click selector="{{StorefrontBundledSection.bundleOption('1','2')}}" stepKey="selectSecondBundleOption"/>
<waitForPageLoad stepKey="waitForPriceUpdate2"/>
<see selector="{{StorefrontBundledSection.configuredPrice}}" userInput="1,230.00" stepKey="seeSinglePrice2"/>
<click selector="{{StorefrontBundledSection.addToCartConfigured}}" stepKey="addSecondItemToCart"/>
<waitForPageLoad stepKey="waitForElementAdded2"/>

<!-- Go to the shopping cart page and edit the first product -->
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="onPageShoppingCart"/>
<waitForPageLoad stepKey="waitForCartPageLoad"/>
<waitForElementVisible selector="{{CheckoutCartSummarySection.total}}" stepKey="waitForInfoDropdown"/>
<waitForPageLoad stepKey="waitForCartPageLoad3"/>
<grabTextFrom selector="{{CheckoutCartSummarySection.total}}" stepKey="grabTotalBefore"/>
<click selector="{{CheckoutCartProductSection.editItemParametersButton('1')}}" stepKey="clickEdit"/>
<waitForPageLoad stepKey="waitForStorefront2"/>

<!-- Choose both of the options on the storefront -->
<click selector="{{StorefrontBundledSection.bundleOption('1','1')}}" stepKey="selectFirstBundleOption2"/>
<click selector="{{StorefrontBundledSection.bundleOption('1','2')}}" stepKey="selectSecondBundleOption2"/>

<waitForPageLoad stepKey="waitForPriceUpdate3"/>
<see selector="{{StorefrontBundledSection.configuredPrice}}" userInput="2,460.00" stepKey="seeDoublePrice"/>

<click selector="{{StorefrontBundledSection.updateCart}}" stepKey="addFirstItemToCart2"/>
<waitForPageLoad stepKey="waitForElementAdded3"/>

<!-- Go to the shopping cart page -->
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="onPageShoppingCart2"/>
<waitForPageLoad stepKey="waitForCartPageLoad2"/>

<!-- Assert that the options are both there and the proce no longer matches -->
<see selector="{{CheckoutCartProductSection.itemOptionsBlock('2')}}" userInput="$$simpleProduct1.sku$$" stepKey="assertBothOptions"/>
<see selector="{{CheckoutCartProductSection.itemOptionsBlock('2')}}" userInput="$$simpleProduct2.sku$$" stepKey="assertBothOptions2"/>
<waitForElementVisible selector="{{CheckoutCartSummarySection.total}}" stepKey="waitForInfoDropdown2"/>
<waitForPageLoad stepKey="waitForCartPageLoad4"/>
<grabTextFrom selector="{{CheckoutCartSummarySection.total}}" stepKey="grabTotalAfter"/>
<assertNotEquals expected="{$grabTotalBefore}" expectedType="string" actual="{$grabTotalAfter}" actualType="string" stepKey="assertNotEquals"/>

<!-- Delete the bundled product -->
<actionGroup ref="deleteProductUsingProductGrid" stepKey="deleteBundle">
<argument name="product" value="BundleProduct"/>
</actionGroup>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public function initializeFromData(\Magento\Catalog\Model\Product $product, arra
}

$productData = $this->normalize($productData);
$productData = $this->convertSpecialFromDateStringToObject($productData);

if (!empty($productData['is_downloadable'])) {
$productData['product_has_weight'] = 0;
Expand Down Expand Up @@ -452,4 +453,19 @@ private function fillProductOptions(Product $product, array $productOptions)

return $product->setOptions($customOptions);
}

/**
* Convert string date presentation into object
*
* @param array $productData
* @return array
*/
private function convertSpecialFromDateStringToObject($productData)
{
if (isset($productData['special_from_date']) && $productData['special_from_date'] != '') {
$productData['special_from_date'] = new \DateTime($productData['special_from_date']);
}

return $productData;
}
}
Loading

0 comments on commit 38c27fb

Please sign in to comment.