Skip to content

#28270 Showed tier price for pre selected swatch via cart edit #29137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 29, 2020
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.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="StorefrontUpdateCartItemEditParametersProductActionGroup">
<arguments>
<argument name="rowNumber" type="string" defaultValue="1"/>
</arguments>
<click selector="{{CheckoutCartProductSection.nthEditButton(rowNumber)}}" stepKey="clickEditConfigurableProductButton"/>
<waitForPageLoad stepKey="waitForStorefrontProductPageLoad"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<!-- Add Configurable Product with Swatch attribute to the cart -->
<actionGroup name="StorefrontAddProductWithSwatchesTextOptionToTheCartActionGroup">
<annotations>
<description>Select Product product option. Fills in the provided Product Quantity. Clicks on Add To Cart. Validates that the Success Message is present.</description>
</annotations>
<arguments>
<argument name="product"/>
<argument name="productOption" type="string"/>
<argument name="productQty" type="string" />
</arguments>

<waitForPageLoad stepKey="waitForStorefrontProductPageLoad"/>
<click selector="{{StorefrontProductInfoMainSection.swatchOptionByLabel(productOption)}}" stepKey="clickSwatchOption"/>
<fillField selector="{{StorefrontProductPageSection.qtyInput}}" userInput="{{productQty}}" stepKey="fillProduct1Quantity"/>
<click selector="{{StorefrontProductPageSection.addToCartBtn}}" stepKey="clickOnAddToCartButton"/>
<waitForPageLoad stepKey="waitForProductToAddInCart"/>
<waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/>
<seeElement selector="{{StorefrontProductPageSection.successMsg}}" stepKey="seeSuccessSaveMessage"/>

</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<element name="nthSwatchOptionText" type="button" selector="div.swatch-option.text:nth-of-type({{n}})" parameterized="true"/>
<element name="productSwatch" type="button" selector="//div[@class='swatch-option'][@aria-label='{{var1}}']" parameterized="true"/>
<element name="visualSwatchOption" type="button" selector=".swatch-option[data-option-tooltip-value='#{{visualSwatchOption}}']" parameterized="true"/>
<element name="visualSwatchOptionText" type="button" selector=".swatch-option.text[data-option-tooltip-value='{{visualSwatchOptionText}}']" parameterized="true"/>
<element name="swatchOptionTooltip" type="block" selector="div.swatch-option-tooltip"/>
<element name="swatchAttributeSelectedOption" type="text" selector="#product-options-wrapper .swatch-option.selected"/>
</section>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?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="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="StorefrontConfigurableProductSwatchUpdateCartItemTierPriceTest">
<annotations>
<features value="Swatches"/>
<stories value="Configurable product with swatch attribute"/>
<title value="Swatch option should show the tier price on product page when Cart Item edited."/>
<description value="Configurable product with swatch attribute should show the tier price on product page when added Cart Item."/>
<severity value="CRITICAL"/>
<testCaseId value="MC-36047"/>
<group value="Swatches"/>
</annotations>
<before>
<createData entity="ApiCategory" stepKey="createCategory"/>
<createData entity="ApiConfigurableProduct" stepKey="createConfigurableProduct">
<requiredEntity createDataKey="createCategory"/>
</createData>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
</before>
<after>
<deleteData createDataKey="createConfigurableProduct" stepKey="deleteConfigurableProduct"/>
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
<actionGroup ref="DeleteProductAttributeActionGroup" stepKey="deleteColorAttribute">
<argument name="ProductAttribute" value="ProductColorAttribute"/>
</actionGroup>
<actionGroup ref="AdminLogoutActionGroup" stepKey="adminLogout"/>
</after>

<actionGroup ref="AddTextSwatchToProductActionGroup" stepKey="addColorAttribute">
<argument name="attributeName" value="{{ProductColorAttribute.frontend_label}}"/>
<argument name="attributeCode" value="{{ProductColorAttribute.attribute_code}}"/>
<argument name="option1" value="Black"/>
<argument name="option2" value="White"/>
<argument name="option3" value="Blue"/>
</actionGroup>

<amOnPage url="{{AdminProductEditPage.url($createConfigurableProduct.id$)}}" stepKey="goToConfigurableProduct"/>

<actionGroup ref="GenerateConfigurationsByAttributeCodeActionGroup" stepKey="createProductConfigurations">
<argument name="attributeCode" value="{{ProductColorAttribute.attribute_code}}"/>
</actionGroup>
<actionGroup ref="SaveConfigurableProductAddToCurrentAttributeSetActionGroup" stepKey="saveConfigurableProduct"/>

<actionGroup ref="FilterAndSelectProductActionGroup" stepKey="filterProduct">
<argument name="productSku" value="$$createConfigurableProduct.sku$$-White"/>
</actionGroup>
<actionGroup ref="ProductSetAdvancedPricingActionGroup" stepKey="addTierPriceToSimpleProduct">
<argument name="group" value="ALL GROUPS"/>
<argument name="quantity" value="5"/>
<argument name="price" value="Discount"/>
<argument name="amount" value="50"/>
</actionGroup>
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveSimpleProduct"/>

<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openConfigurableProductPage">
<argument name="productUrl" value="$createConfigurableProduct.custom_attributes[url_key]$"/>
</actionGroup>
<waitForPageLoad stepKey="waitForConfigurableProductPage"/>

<actionGroup ref="StorefrontSelectSwatchOptionOnProductPageActionGroup" stepKey="selectWhiteOption">
<argument name="optionName" value="White"/>
</actionGroup>

<actionGroup ref="AssertStorefrontProductDetailPageTierPriceActionGroup" stepKey="assertProductTierPriceText">
<argument name="tierProductPriceDiscountQuantity" value="5"/>
<argument name="productPriceWithAppliedTierPriceDiscount" value="61.50"/>
<argument name="productSavedPricePercent" value="50"/>
</actionGroup>

<actionGroup ref="StorefrontAddProductWithSwatchesTextOptionToTheCartActionGroup" stepKey="addConfigurableProductToTheCart">
<argument name="productQty" value="1"/>
<argument name="product" value="ApiConfigurableProduct"/>
<argument name="productOption" value="Blue"/>
</actionGroup>

<actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="openShoppingCartPage"/>

<actionGroup ref="StorefrontUpdateCartItemEditParametersProductActionGroup" stepKey="updateCartItem">
<argument name="rowNumber" value="1"/>
</actionGroup>

<actionGroup ref="StorefrontSelectSwatchOptionOnProductPageActionGroup" stepKey="selectWhiteOption2">
<argument name="optionName" value="White"/>
</actionGroup>

<actionGroup ref="AssertStorefrontProductDetailPageTierPriceActionGroup" stepKey="assertProductTierPriceText2">
<argument name="tierProductPriceDiscountQuantity" value="5"/>
<argument name="productPriceWithAppliedTierPriceDiscount" value="61.50"/>
<argument name="productSavedPricePercent" value="50"/>
</actionGroup>

<actionGroup ref="StorefrontSelectSwatchOptionOnProductPageActionGroup" stepKey="selectWhiteOption3">
<argument name="optionName" value="Blue"/>
</actionGroup>

<dontSee selector="{{StorefrontProductInfoMainSection.tierPriceText}}" stepKey="dontSeeTierPriceForOption"/>

<actionGroup ref="StorefrontAddProductWithSwatchesTextOptionToTheCartActionGroup" stepKey="addUpdatedConfigurableProductToTheCart">
<argument name="productQty" value="10"/>
<argument name="product" value="ApiConfigurableProduct"/>
<argument name="productOption" value="White"/>
</actionGroup>

<actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="openShoppingCartPage2"/>

</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ define([
if ($(this.element).attr('data-rendered')) {
return;
}

$(this.element).attr('data-rendered', true);

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

this.options.tierPriceTemplate = $(this.options.tierPriceTemplateSelector).html();

if (this.options.jsonConfig !== '' && this.options.jsonSwatchConfig !== '') {
// store unsorted attributes
this.options.jsonConfig.mappedAttributes = _.clone(this.options.jsonConfig.attributes);
Expand All @@ -330,7 +333,6 @@ define([
} else {
console.log('SwatchRenderer: No input data received');
}
this.options.tierPriceTemplate = $(this.options.tierPriceTemplateSelector).html();
},

/**
Expand Down