Skip to content

Commit 942e44e

Browse files
committed
MC-35640: The product is not added to the cart
1 parent 63434d2 commit 942e44e

File tree

7 files changed

+110
-7
lines changed

7 files changed

+110
-7
lines changed

app/code/Magento/Msrp/Test/Mftf/Data/MsrpSettingsData.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,11 @@
2121
<entity name="DisableMAP" type="msrp_settings_config">
2222
<data key="value">0</data>
2323
</entity>
24+
25+
<entity name="MsrpDisplayPriceOnGesture" type="msrp_settings_config">
26+
<requiredEntity type="display_price_type">DisplayPriceOnGesture</requiredEntity>
27+
</entity>
28+
<entity name="DisplayPriceOnGesture" type="msrp_settings_config">
29+
<data key="value">1</data>
30+
</entity>
2431
</entities>

app/code/Magento/Msrp/Test/Mftf/Data/ProductData.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@
1313
<requiredEntity type="custom_attribute_array">ApiProductCost</requiredEntity>
1414
<requiredEntity type="custom_attribute_array">ApiProductMsrp</requiredEntity>
1515
</entity>
16+
<entity name="SimpleProductWithMsrp" type="product" extends="SimpleProduct">
17+
<data key="price">100.00</data>
18+
<requiredEntity type="custom_attribute_array">ApiProductMsrp</requiredEntity>
19+
</entity>
1620
</entities>

app/code/Magento/Msrp/Test/Mftf/Metadata/MsrpSettingsMeta.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
<object key="enabled" dataType="enabled">
1515
<field key="value">string</field>
1616
</object>
17+
<object key="display_price_type" dataType="display_price_type">
18+
<field key="value">string</field>
19+
</object>
1720
</object>
1821
</object>
1922
</object>
2023
</operation>
21-
</operations>
24+
</operations>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
10+
<section name="StorefrontMsrpCategorySection">
11+
<element name="clickForPrice" type="button" selector="//a[normalize-space() = '{{productName}}']/following::div[@data-role='priceBox']/a[@class='action map-show-info']" parameterized="true" timeout="30"/>
12+
<element name="mapPrice" type="button" selector="//a[normalize-space() = '{{productName}}']/following::div[@data-role='priceBox']//span[contains(@class, 'price-msrp_price')]" parameterized="true" timeout="30"/>
13+
</section>
14+
</sections>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
10+
<section name="StorefrontMsrpSection">
11+
<element name="popupAddToCartButton" type="button" selector="#map-popup-click-for-price .action.tocart" timeout="30"/>
12+
</section>
13+
</sections>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="StorefrontAddMapProductToCartFromPopupOnCategoryPageTest">
12+
<annotations>
13+
<features value="Msrp"/>
14+
<stories value="Minimum advertised price"/>
15+
<title value="Add simple product with MAP to cart from popup on category page"/>
16+
<description value="Check that simple product with MAP is successfully added to cart from popup on category page"/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="MC-40419"/>
19+
<useCaseId value="MC-35640"/>
20+
<group value="Msrp"/>
21+
</annotations>
22+
<before>
23+
<!-- Enable Minimum advertised Price -->
24+
<createData entity="MsrpEnableMAP" stepKey="enableMAP"/>
25+
26+
<!-- Display Price in Popup -->
27+
<createData entity="MsrpDisplayPriceOnGesture" stepKey="displayPriceOnGesture"/>
28+
29+
<!-- Create category -->
30+
<createData entity="_defaultCategory" stepKey="createCategory"/>
31+
32+
<!-- Create product with MAP -->
33+
<createData entity="SimpleProductWithMsrp" stepKey="createProduct">
34+
<requiredEntity createDataKey="createCategory"/>
35+
</createData>
36+
</before>
37+
<after>
38+
<!-- Delete product and category -->
39+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
40+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
41+
42+
<!-- Disable Minimum advertised Price -->
43+
<createData entity="MsrpDisableMAP" stepKey="disableMAP"/>
44+
</after>
45+
46+
<!-- Open created category on Storefront -->
47+
<actionGroup ref="StorefrontNavigateCategoryPageActionGroup" stepKey="navigateToCategoryPage">
48+
<argument name="category" value="$createCategory$"/>
49+
</actionGroup>
50+
51+
<!-- Grab and verify MAP price -->
52+
<grabTextFrom selector="{{StorefrontMsrpCategorySection.mapPrice($createProduct.name$)}}" stepKey="grabMapPrice"/>
53+
<assertEquals stepKey="assertMapPrice">
54+
<actualResult type="const">($grabMapPrice)</actualResult>
55+
<expectedResult type="string">${{ApiProductMsrp.value}}</expectedResult>
56+
</assertEquals>
57+
58+
<!-- Open 'Click for price' popup and click 'Add to Cart' button -->
59+
<click selector="{{StorefrontMsrpCategorySection.clickForPrice($createProduct.name$)}}" stepKey="clickForPrice"/>
60+
<waitForElementVisible selector="{{StorefrontMsrpSection.popupAddToCartButton}}" stepKey="waitForAddToCartButton"/>
61+
<click selector="{{StorefrontMsrpSection.popupAddToCartButton}}" stepKey="clickAddToCartButton"/>
62+
<waitForElementVisible selector="{{StorefrontCategoryMainSection.SuccessMsg}}" stepKey="waitForSuccessMessage"/>
63+
<see selector="{{StorefrontCategoryMainSection.SuccessMsg}}" userInput="You added $createProduct.name$ to your shopping cart." stepKey="assertSuccessMessage"/>
64+
</test>
65+
</tests>

app/code/Magento/Msrp/view/base/templates/product/price/msrp.phtml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,9 @@ $priceElementIdPrefix = $block->getPriceElementIdPrefix() ? $block->getPriceElem
8080
$data['addToCartButton'] = '#product_addtocart_form [type=submit]';
8181
} else {
8282
$data['addToCartButton'] = sprintf(
83-
'form:has(input[type="hidden"][name="product"][value="%s"]) button[type="submit"]',
84-
(int) $productId . ',' .
85-
sprintf(
86-
'.block.widget .price-box[data-product-id=%s]+.product-item-actions button.tocart',
87-
(int)$productId
88-
)
83+
'form:has(input[type="hidden"][name="product"][value="%1$s"]) button[type="submit"],' .
84+
'.block.widget .price-box[data-product-id="%1$s"]+.product-item-actions button.tocart',
85+
$productId
8986
);
9087
}
9188
?>

0 commit comments

Comments
 (0)