Skip to content

Commit 7fd9000

Browse files
#25037: MFTF tests fix.
1 parent fae93e2 commit 7fd9000

File tree

3 files changed

+32
-17
lines changed

3 files changed

+32
-17
lines changed

app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebar.php

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
namespace Magento\Sales\Block\Adminhtml\Order\Create\Sidebar;
1010

1111
use Magento\Framework\Pricing\PriceCurrencyInterface;
12-
use Magento\Store\Model\ScopeInterface;
1312

1413
/**
1514
* Adminhtml sales order create sidebar block
@@ -136,20 +135,7 @@ public function getItemCount()
136135
{
137136
$count = $this->getData('item_count');
138137
if ($count === null) {
139-
$useQty = $this->_scopeConfig->getValue(
140-
'checkout/cart_link/use_qty',
141-
ScopeInterface::SCOPE_STORE
142-
);
143-
$allItems = $this->getItems();
144-
if ($useQty) {
145-
$count = 0;
146-
foreach ($allItems as $item) {
147-
$count += $item->getQty();
148-
}
149-
} else {
150-
$count = count($allItems);
151-
}
152-
138+
$count = count($this->getItems());
153139
$this->setData('item_count', $count);
154140
}
155141
return $count;

app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Cart.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\Catalog\Model\Product;
1111
use Magento\Catalog\Pricing\Price\FinalPrice;
12+
use Magento\Store\Model\ScopeInterface;
1213

1314
/**
1415
* Adminhtml sales order create sidebar cart block
@@ -146,4 +147,30 @@ private function getCartItemCustomPrice(Product $product): ?float
146147

147148
return null;
148149
}
150+
151+
/**
152+
* @inheritdoc
153+
*/
154+
public function getItemCount()
155+
{
156+
$count = $this->getData('item_count');
157+
if ($count === null) {
158+
$useQty = $this->_scopeConfig->getValue(
159+
'checkout/cart_link/use_qty',
160+
ScopeInterface::SCOPE_STORE
161+
);
162+
$allItems = $this->getItems();
163+
if ($useQty) {
164+
$count = 0;
165+
foreach ($allItems as $item) {
166+
$count += $item->getQty();
167+
}
168+
} else {
169+
$count = count($allItems);
170+
}
171+
$this->setData('item_count', $count);
172+
}
173+
174+
return $count;
175+
}
149176
}

app/code/Magento/Sales/Test/Mftf/Test/AddSimpleProductToOrderFromShoppingCartTest.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@
4646
</actionGroup>
4747

4848
<!-- Add product to cart -->
49-
<actionGroup ref="AddSimpleProductToCart" stepKey="addProductToCart">
49+
<actionGroup ref="StorefrontAddSimpleProductWithQtyActionGroup" stepKey="addSimpleProductToCart">
5050
<argument name="product" value="$$createProduct$$"/>
51+
<argument name="quantity" value="2"/>
5152
</actionGroup>
5253

5354
<!-- Login as admin -->
@@ -64,6 +65,7 @@
6465
<click selector="{{AdminCustomerMainActionsSection.createOrderBtn}}" stepKey="clickCreateOrder"/>
6566

6667
<!-- Check product in customer's activities in shopping cart section -->
68+
<see selector="{{AdminCreateOrderShoppingCartSection.shoppingCartBlock}}" userInput="Shopping Cart (2)" stepKey="seeCorrectNumberInCart"/>
6769
<see selector="{{AdminCustomerActivitiesShoppingCartSection.productName}}" userInput="$$createProduct.name$$" stepKey="seeProductNameInShoppingCartSection"/>
6870
<see selector="{{AdminCustomerActivitiesShoppingCartSection.productPrice}}" userInput="$$createProduct.price$$" stepKey="seeProductPriceInShoppingCartSection"/>
6971

@@ -75,6 +77,6 @@
7577
<!-- Assert product in items ordered grid -->
7678
<see selector="{{AdminCustomerCreateNewOrderSection.productName}}" userInput="$$createProduct.name$$" stepKey="seeProductName"/>
7779
<see selector="{{AdminCustomerCreateNewOrderSection.productPrice}}" userInput="$$createProduct.price$$" stepKey="seeProductPrice"/>
78-
<seeInField selector="{{AdminCustomerCreateNewOrderSection.productQty}}" userInput="{{ApiSimpleSingleQty.quantity}}" stepKey="seeProductQty"/>
80+
<seeInField selector="{{AdminCustomerCreateNewOrderSection.productQty}}" userInput="2" stepKey="seeProductQty"/>
7981
</test>
8082
</tests>

0 commit comments

Comments
 (0)