Skip to content

Commit 96197a0

Browse files
authored
ENGCOM-7845: #28270 Showed tier price for pre selected swatch via cart edit #29137
2 parents eca1a9b + 4b3a517 commit 96197a0

File tree

5 files changed

+167
-1
lines changed

5 files changed

+167
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="StorefrontUpdateCartItemEditParametersProductActionGroup">
12+
<arguments>
13+
<argument name="rowNumber" type="string" defaultValue="1"/>
14+
</arguments>
15+
<click selector="{{CheckoutCartProductSection.nthEditButton(rowNumber)}}" stepKey="clickEditConfigurableProductButton"/>
16+
<waitForPageLoad stepKey="waitForStorefrontProductPageLoad"/>
17+
</actionGroup>
18+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<!-- Add Configurable Product with Swatch attribute to the cart -->
12+
<actionGroup name="StorefrontAddProductWithSwatchesTextOptionToTheCartActionGroup">
13+
<annotations>
14+
<description>Select Product product option. Fills in the provided Product Quantity. Clicks on Add To Cart. Validates that the Success Message is present.</description>
15+
</annotations>
16+
<arguments>
17+
<argument name="product"/>
18+
<argument name="productOption" type="string"/>
19+
<argument name="productQty" type="string" />
20+
</arguments>
21+
22+
<waitForPageLoad stepKey="waitForStorefrontProductPageLoad"/>
23+
<click selector="{{StorefrontProductInfoMainSection.swatchOptionByLabel(productOption)}}" stepKey="clickSwatchOption"/>
24+
<fillField selector="{{StorefrontProductPageSection.qtyInput}}" userInput="{{productQty}}" stepKey="fillProduct1Quantity"/>
25+
<click selector="{{StorefrontProductPageSection.addToCartBtn}}" stepKey="clickOnAddToCartButton"/>
26+
<waitForPageLoad stepKey="waitForProductToAddInCart"/>
27+
<waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/>
28+
<seeElement selector="{{StorefrontProductPageSection.successMsg}}" stepKey="seeSuccessSaveMessage"/>
29+
30+
</actionGroup>
31+
</actionGroups>

app/code/Magento/Swatches/Test/Mftf/Section/StorefrontProductInfoMainSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<element name="nthSwatchOptionText" type="button" selector="div.swatch-option.text:nth-of-type({{n}})" parameterized="true"/>
1717
<element name="productSwatch" type="button" selector="//div[@class='swatch-option'][@aria-label='{{var1}}']" parameterized="true"/>
1818
<element name="visualSwatchOption" type="button" selector=".swatch-option[data-option-tooltip-value='#{{visualSwatchOption}}']" parameterized="true"/>
19+
<element name="visualSwatchOptionText" type="button" selector=".swatch-option.text[data-option-tooltip-value='{{visualSwatchOptionText}}']" parameterized="true"/>
1920
<element name="swatchOptionTooltip" type="block" selector="div.swatch-option-tooltip"/>
2021
<element name="swatchAttributeSelectedOption" type="text" selector="#product-options-wrapper .swatch-option.selected"/>
2122
</section>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="StorefrontConfigurableProductSwatchUpdateCartItemTierPriceTest">
11+
<annotations>
12+
<features value="Swatches"/>
13+
<stories value="Configurable product with swatch attribute"/>
14+
<title value="Swatch option should show the tier price on product page when Cart Item edited."/>
15+
<description value="Configurable product with swatch attribute should show the tier price on product page when added Cart Item."/>
16+
<severity value="CRITICAL"/>
17+
<testCaseId value="MC-36047"/>
18+
<group value="Swatches"/>
19+
</annotations>
20+
<before>
21+
<createData entity="ApiCategory" stepKey="createCategory"/>
22+
<createData entity="ApiConfigurableProduct" stepKey="createConfigurableProduct">
23+
<requiredEntity createDataKey="createCategory"/>
24+
</createData>
25+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
26+
</before>
27+
<after>
28+
<deleteData createDataKey="createConfigurableProduct" stepKey="deleteConfigurableProduct"/>
29+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
30+
<actionGroup ref="DeleteProductAttributeActionGroup" stepKey="deleteColorAttribute">
31+
<argument name="ProductAttribute" value="ProductColorAttribute"/>
32+
</actionGroup>
33+
<actionGroup ref="AdminLogoutActionGroup" stepKey="adminLogout"/>
34+
</after>
35+
36+
<actionGroup ref="AddTextSwatchToProductActionGroup" stepKey="addColorAttribute">
37+
<argument name="attributeName" value="{{ProductColorAttribute.frontend_label}}"/>
38+
<argument name="attributeCode" value="{{ProductColorAttribute.attribute_code}}"/>
39+
<argument name="option1" value="Black"/>
40+
<argument name="option2" value="White"/>
41+
<argument name="option3" value="Blue"/>
42+
</actionGroup>
43+
44+
<amOnPage url="{{AdminProductEditPage.url($createConfigurableProduct.id$)}}" stepKey="goToConfigurableProduct"/>
45+
46+
<actionGroup ref="GenerateConfigurationsByAttributeCodeActionGroup" stepKey="createProductConfigurations">
47+
<argument name="attributeCode" value="{{ProductColorAttribute.attribute_code}}"/>
48+
</actionGroup>
49+
<actionGroup ref="SaveConfigurableProductAddToCurrentAttributeSetActionGroup" stepKey="saveConfigurableProduct"/>
50+
51+
<actionGroup ref="FilterAndSelectProductActionGroup" stepKey="filterProduct">
52+
<argument name="productSku" value="$$createConfigurableProduct.sku$$-White"/>
53+
</actionGroup>
54+
<actionGroup ref="ProductSetAdvancedPricingActionGroup" stepKey="addTierPriceToSimpleProduct">
55+
<argument name="group" value="ALL GROUPS"/>
56+
<argument name="quantity" value="5"/>
57+
<argument name="price" value="Discount"/>
58+
<argument name="amount" value="50"/>
59+
</actionGroup>
60+
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveSimpleProduct"/>
61+
62+
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openConfigurableProductPage">
63+
<argument name="productUrl" value="$createConfigurableProduct.custom_attributes[url_key]$"/>
64+
</actionGroup>
65+
<waitForPageLoad stepKey="waitForConfigurableProductPage"/>
66+
67+
<actionGroup ref="StorefrontSelectSwatchOptionOnProductPageActionGroup" stepKey="selectWhiteOption">
68+
<argument name="optionName" value="White"/>
69+
</actionGroup>
70+
71+
<actionGroup ref="AssertStorefrontProductDetailPageTierPriceActionGroup" stepKey="assertProductTierPriceText">
72+
<argument name="tierProductPriceDiscountQuantity" value="5"/>
73+
<argument name="productPriceWithAppliedTierPriceDiscount" value="61.50"/>
74+
<argument name="productSavedPricePercent" value="50"/>
75+
</actionGroup>
76+
77+
<actionGroup ref="StorefrontAddProductWithSwatchesTextOptionToTheCartActionGroup" stepKey="addConfigurableProductToTheCart">
78+
<argument name="productQty" value="1"/>
79+
<argument name="product" value="ApiConfigurableProduct"/>
80+
<argument name="productOption" value="Blue"/>
81+
</actionGroup>
82+
83+
<actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="openShoppingCartPage"/>
84+
85+
<actionGroup ref="StorefrontUpdateCartItemEditParametersProductActionGroup" stepKey="updateCartItem">
86+
<argument name="rowNumber" value="1"/>
87+
</actionGroup>
88+
89+
<actionGroup ref="StorefrontSelectSwatchOptionOnProductPageActionGroup" stepKey="selectWhiteOption2">
90+
<argument name="optionName" value="White"/>
91+
</actionGroup>
92+
93+
<actionGroup ref="AssertStorefrontProductDetailPageTierPriceActionGroup" stepKey="assertProductTierPriceText2">
94+
<argument name="tierProductPriceDiscountQuantity" value="5"/>
95+
<argument name="productPriceWithAppliedTierPriceDiscount" value="61.50"/>
96+
<argument name="productSavedPricePercent" value="50"/>
97+
</actionGroup>
98+
99+
<actionGroup ref="StorefrontSelectSwatchOptionOnProductPageActionGroup" stepKey="selectWhiteOption3">
100+
<argument name="optionName" value="Blue"/>
101+
</actionGroup>
102+
103+
<dontSee selector="{{StorefrontProductInfoMainSection.tierPriceText}}" stepKey="dontSeeTierPriceForOption"/>
104+
105+
<actionGroup ref="StorefrontAddProductWithSwatchesTextOptionToTheCartActionGroup" stepKey="addUpdatedConfigurableProductToTheCart">
106+
<argument name="productQty" value="10"/>
107+
<argument name="product" value="ApiConfigurableProduct"/>
108+
<argument name="productOption" value="White"/>
109+
</actionGroup>
110+
111+
<actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="openShoppingCartPage2"/>
112+
113+
</test>
114+
</tests>

app/code/Magento/Swatches/view/base/web/js/swatch-renderer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ define([
311311
if ($(this.element).attr('data-rendered')) {
312312
return;
313313
}
314+
314315
$(this.element).attr('data-rendered', true);
315316

316317
if (_.isEmpty(this.options.jsonConfig.images)) {
@@ -320,6 +321,8 @@ define([
320321
this._debouncedLoadProductMedia = _.debounce(this._LoadProductMedia.bind(this), 500);
321322
}
322323

324+
this.options.tierPriceTemplate = $(this.options.tierPriceTemplateSelector).html();
325+
323326
if (this.options.jsonConfig !== '' && this.options.jsonSwatchConfig !== '') {
324327
// store unsorted attributes
325328
this.options.jsonConfig.mappedAttributes = _.clone(this.options.jsonConfig.attributes);
@@ -330,7 +333,6 @@ define([
330333
} else {
331334
console.log('SwatchRenderer: No input data received');
332335
}
333-
this.options.tierPriceTemplate = $(this.options.tierPriceTemplateSelector).html();
334336
},
335337

336338
/**

0 commit comments

Comments
 (0)