Skip to content

Commit 4e32711

Browse files
author
Oleksandr Dubovyk
committed
Merge remote-tracking branch 'chaika/MC-38576' into PR17november
2 parents 91af2eb + c06db23 commit 4e32711

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

app/code/Magento/Bundle/Test/Mftf/Test/AdminAddBundleItemsTest.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@
5959
</actionGroup>
6060
<checkOption selector="{{AdminAddProductsToOptionPanel.firstCheckbox}}" stepKey="selectFirstGridRow2"/>
6161
<click selector="{{AdminAddProductsToOptionPanel.addSelectedProducts}}" stepKey="clickAddSelectedBundleProducts"/>
62+
<!-- Check that Bundle Options initialized with default quantity -->
63+
<grabValueFrom selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '0')}}" stepKey="grabbedFirstBundleOptionQuantity"/>
64+
<assertEquals stepKey="assertFirstBundleOptionDefaultQuantity">
65+
<expectedResult type="string">1</expectedResult>
66+
<actualResult type="string">$grabbedFirstBundleOptionQuantity</actualResult>
67+
</assertEquals>
68+
<grabValueFrom selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '1')}}" stepKey="grabbedSecondBundleOptionQuantity"/>
69+
<assertEquals stepKey="assertSecondBundleOptionDefaultQuantity">
70+
<expectedResult type="string">1</expectedResult>
71+
<actualResult type="string">$grabbedSecondBundleOptionQuantity</actualResult>
72+
</assertEquals>
73+
6274
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '0')}}" userInput="{{BundleProduct.defaultQuantity}}" stepKey="fillProductDefaultQty1"/>
6375
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '1')}}" userInput="{{BundleProduct.defaultQuantity}}" stepKey="fillProductDefaultQty2"/>
6476

@@ -108,6 +120,17 @@
108120
</actionGroup>
109121
<checkOption selector="{{AdminProductFormBundleSection.firstProductOption}}" stepKey="selectNewFirstGridRow2"/>
110122
<click selector="{{AdminAddProductsToOptionPanel.addSelectedProducts}}" stepKey="clickAddNewSelectedBundleProducts"/>
123+
<!-- Check that existing Bundle Options do not loose user input quantity values -->
124+
<grabValueFrom selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '0')}}" stepKey="grabbedFirstBundleOptionQuantityAfterUserInput"/>
125+
<assertEquals stepKey="assertFirstBundleOptionDefaultQuantityAfterUserInput">
126+
<expectedResult type="string">{{BundleProduct.defaultQuantity}}</expectedResult>
127+
<actualResult type="string">$grabbedFirstBundleOptionQuantityAfterUserInput</actualResult>
128+
</assertEquals>
129+
<grabValueFrom selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '1')}}" stepKey="grabbedSecondBundleOptionQuantityAfterUserInput"/>
130+
<assertEquals stepKey="assertSecondBundleOptionDefaultQuantityAfterUserInput">
131+
<expectedResult type="string">{{BundleProduct.defaultQuantity}}</expectedResult>
132+
<actualResult type="string">$grabbedSecondBundleOptionQuantityAfterUserInput</actualResult>
133+
</assertEquals>
111134
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '2')}}" userInput="{{BundleProduct.defaultQuantity}}" stepKey="fillNewProductDefaultQty1"/>
112135
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '3')}}" userInput="{{BundleProduct.defaultQuantity}}" stepKey="fillNewProductDefaultQty2"/>
113136

app/code/Magento/Bundle/view/adminhtml/web/js/components/bundle-option-qty.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,26 @@ define([
1717
}
1818
},
1919

20+
/**
21+
* @inheritdoc
22+
*/
23+
setInitialValue: function () {
24+
this.initialValue = this.getInitialValue();
25+
26+
if (this.initialValue === undefined || this.initialValue === '') {
27+
this.initialValue = 1;
28+
}
29+
30+
if (this.value.peek() !== this.initialValue) {
31+
this.value(this.initialValue);
32+
}
33+
34+
this.on('value', this.onUpdate.bind(this));
35+
this.isUseDefault(this.disabled());
36+
37+
return this;
38+
},
39+
2040
/**
2141
* @inheritdoc
2242
*/
@@ -33,6 +53,5 @@ define([
3353

3454
return !this.visible() ? false : notEqual;
3555
}
36-
3756
});
3857
});

0 commit comments

Comments
 (0)