Skip to content

Commit fe0197f

Browse files
committed
Merge branch 'MC-38242' of https://github.com/magento-mpi/magento2ce into TANGO-PR-11-05-2020_24
2 parents 7240671 + 899fa5f commit fe0197f

File tree

4 files changed

+125
-1
lines changed

4 files changed

+125
-1
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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="AdminSetEnableQtyIncrementsActionGroup">
12+
<annotations>
13+
<description>Set "Enable Qty Increments" config in 'Advanced Inventory' panel on the Admin Product creation/edit page.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="value" type="string"/>
17+
</arguments>
18+
<scrollTo selector="{{AdminProductFormAdvancedInventorySection.enableQtyIncrements}}" stepKey="scrollToEnableQtyIncrements"/>
19+
<click selector="{{AdminProductFormAdvancedInventorySection.enableQtyIncrementsUseConfigSettings}}" stepKey="clickOnEnableQtyIncrementsUseConfigSettingsCheckbox"/>
20+
<selectOption selector="{{AdminProductFormAdvancedInventorySection.enableQtyIncrements}}" userInput="{{value}}"
21+
stepKey="setEnableQtyIncrements"/>
22+
</actionGroup>
23+
</actionGroups>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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="AdminSetQtyIncrementsForProductActionGroup">
12+
<annotations>
13+
<description>Fills in the "Qty Increments" option in 'Advanced Inventory' panel on the Admin Product creation/edit page.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="qty" type="string"/>
17+
</arguments>
18+
<scrollTo selector="{{AdminProductFormAdvancedInventorySection.qtyIncrementsUseConfigSettings}}" stepKey="scrollToQtyIncrementsUseConfigSettings"/>
19+
<click selector="{{AdminProductFormAdvancedInventorySection.qtyIncrementsUseConfigSettings}}" stepKey="clickOnQtyIncrementsUseConfigSettings"/>
20+
<scrollTo selector="{{AdminProductFormAdvancedInventorySection.qtyIncrements}}" stepKey="scrollToQtyIncrements"/>
21+
<fillField selector="{{AdminProductFormAdvancedInventorySection.qtyIncrements}}" userInput="{{qty}}" stepKey="fillQtyIncrements"/>
22+
</actionGroup>
23+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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="StorefrontValidateQuantityIncrementsWithDecimalInventoryTest">
12+
<annotations>
13+
<features value="CatalogInventory"/>
14+
<stories value="Qty increments wrong calculation for decimal fraction quantity"/>
15+
<title value="Validate qty increments for decimal fraction quantity works"/>
16+
<description value="Validate qty increments for decimal fraction quantity works"/>
17+
<severity value="MAJOR"/>
18+
<useCaseId value="MC-38242"/>
19+
<testCaseId value="MC-38883"/>
20+
<group value="catalogInventory"/>
21+
</annotations>
22+
<before>
23+
<createData entity="_defaultCategory" stepKey="createPreReqCategory"/>
24+
<createData entity="SimpleProduct" stepKey="createPreReqSimpleProduct">
25+
<requiredEntity createDataKey="createPreReqCategory"/>
26+
</createData>
27+
</before>
28+
<after>
29+
<!--Clear Filters-->
30+
<actionGroup ref="AdminClearFiltersActionGroup" stepKey="ClearFiltersAfter"/>
31+
<deleteData createDataKey="createPreReqCategory" stepKey="deletePreReqCategory"/>
32+
<deleteData createDataKey="createPreReqSimpleProduct" stepKey="deletePreReqSimpleProduct"/>
33+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
34+
</after>
35+
<!--Step1. Login as admin. Go to Catalog > Products page. Filtering *prod1*. Open *prod1* to edit-->
36+
<actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin" />
37+
<actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="filterGroupedProductOptions">
38+
<argument name="product" value="SimpleProduct"/>
39+
</actionGroup>
40+
<!-- Step2. Update product Advanced Inventory Setting.
41+
Set *Qty Uses Decimals* to *Yes* and *Enable Qty Increments* to *Yes* and *Qty Increments* to *3.33*. -->
42+
<actionGroup ref="OpenProductForEditByClickingRowXColumnYInProductGridActionGroup" stepKey="openProduct"/>
43+
<actionGroup ref="AdminClickOnAdvancedInventoryLinkActionGroup" stepKey="clickOnAdvancedInventoryLink"/>
44+
<actionGroup ref="AdminSetQtyUsesDecimalsConfigActionGroup" stepKey="setQtyUsesDecimalsConfig">
45+
<argument name="value" value="Yes"/>
46+
</actionGroup>
47+
<actionGroup ref="AdminSetEnableQtyIncrementsActionGroup" stepKey="setEnableQtyIncrements">
48+
<argument name="value" value="Yes"/>
49+
</actionGroup>
50+
<actionGroup ref="AdminSetQtyIncrementsForProductActionGroup" stepKey="setQtyIncrementsValue">
51+
<argument name="qty" value="3.33"/>
52+
</actionGroup>
53+
<actionGroup ref="AdminSubmitAdvancedInventoryFormActionGroup" stepKey="clickOnDoneButton"/>
54+
55+
<!--Step3. Save the product-->
56+
<actionGroup ref="AdminProductFormSaveActionGroup" stepKey="clickOnSaveButton2"/>
57+
<!--Step4. Open *Customer view* (Go to *Store Front*). Open *prod1* page (Find via search and click on product name) -->
58+
<amOnPage url="{{StorefrontHomePage.url}}$$createPreReqSimpleProduct.custom_attributes[url_key]$$.html" stepKey="amOnProductPage"/>
59+
<!--Step5. Fill *23.31* in *Qty*. Click on button *Add to Cart*-->
60+
<fillField selector="{{StorefrontProductPageSection.qtyInput}}" userInput="23.31" stepKey="fillQty"/>
61+
<click selector="{{StorefrontProductPageSection.addToCartBtn}}" stepKey="clickOnAddToCart"/>
62+
<waitForElementVisible selector="{{StorefrontProductPageSection.successMsg}}" time="30" stepKey="waitForProductAdded"/>
63+
<!--Step6. Verify the product is successfully added to the cart with success message-->
64+
<see selector="{{StorefrontCategoryMainSection.SuccessMsg}}" userInput="You added $$createPreReqSimpleProduct.name$$ to your shopping cart." stepKey="seeAddedToCartMessage"/>
65+
</test>
66+
</tests>

lib/web/mage/validation.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,24 @@ define([
204204
* @returns {float}
205205
*/
206206
function resolveModulo(qty, qtyIncrements) {
207+
var divideEpsilon = 10000,
208+
epsilon,
209+
remainder;
210+
207211
while (qtyIncrements < 1) {
208212
qty *= 10;
209213
qtyIncrements *= 10;
210214
}
211215

212-
return qty % qtyIncrements;
216+
epsilon = qtyIncrements / divideEpsilon;
217+
remainder = qty % qtyIncrements;
218+
219+
if (Math.abs(remainder - qtyIncrements) < epsilon ||
220+
Math.abs(remainder) < epsilon) {
221+
remainder = 0;
222+
}
223+
224+
return remainder;
213225
}
214226

215227
/**

0 commit comments

Comments
 (0)