Skip to content

Commit 2ea8501

Browse files
committed
Covering the create backend order getting an out of stock product
1 parent c7c66ad commit 2ea8501

File tree

9 files changed

+122
-0
lines changed

9 files changed

+122
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AssertAdminProductStockStatusActionGroup">
11+
<arguments>
12+
<argument name="productId" type="string"/>
13+
<argument name="stockStatus" type="string"/>
14+
</arguments>
15+
<amOnPage url="{{AdminProductEditPage.url(productId)}}" stepKey="goToProductEditPage"/>
16+
<waitForPageLoad stepKey="waitForProductPageLoad"/>
17+
<seeOptionIsSelected selector="{{AdminProductFormSection.productStockStatus}}" userInput="{{stockStatus}}" stepKey="checkProductStatus" />
18+
</actionGroup>
19+
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
<data key="name">Pursuit Lumaflex&#38;trade; Tone Band</data>
4040
<data key="sku" unique="suffix">x&#38;trade;</data>
4141
</entity>
42+
<entity name="SimpleProduct_25" type="product" extends="SimpleProduct2">
43+
<requiredEntity type="product_extension_attribute">EavStock25</requiredEntity>
44+
</entity>
4245
<entity name="ApiSimpleProductWithCustomPrice" type="product" extends="ApiSimpleProduct">
4346
<data key="price">100</data>
4447
</entity>

app/code/Magento/Catalog/Test/Mftf/Data/ProductExtensionAttributeData.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,7 @@
2626
<entity name="EavStock777" type="product_extension_attribute">
2727
<requiredEntity type="stock_item">Qty_777</requiredEntity>
2828
</entity>
29+
<entity name="EavStock25" type="product_extension_attribute">
30+
<requiredEntity type="stock_item">Qty_25</requiredEntity>
31+
</entity>
2932
</entities>

app/code/Magento/Catalog/Test/Mftf/Data/StockItemData.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,8 @@
4040
<data key="qty">777</data>
4141
<data key="is_in_stock">true</data>
4242
</entity>
43+
<entity name="Qty_25" type="stock_item">
44+
<data key="qty">25</data>
45+
<data key="is_in_stock">true</data>
46+
</entity>
4347
</entities>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminSelectPaymentMethodActionGroup">
11+
<arguments>
12+
<argument name="paymentMethod" type="string"/>
13+
<argument name="paymentTitle" type="string"/>
14+
</arguments>
15+
<click selector="{{AdminOrderFormPaymentSection.header}}" stepKey="unfocus"/>
16+
<waitForPageLoad stepKey="waitForJavascriptToFinish"/>
17+
<selectOption selector="{{paymentMethod}}" userInput="{{paymentTitle}}" stepKey="checkPaymentMethod"/>
18+
<waitForPageLoad stepKey="waitForApplyingPaymentMethod"/>
19+
</actionGroup>
20+
</actionGroups>

app/code/Magento/Payment/Test/Mftf/Data/PaymentMethodData.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@
1111
<entity name="PaymentMethodCheckMoneyOrder" type="payment_method">
1212
<data key="method">checkmo</data>
1313
</entity>
14+
15+
<entity name="CashOnDeliveryPaymentMethodDefault" type="cashondelivery_payment_method">
16+
<requiredEntity type="active">CashOnDeliveryEnableConfigData</requiredEntity>
17+
</entity>
1418
</entities>

app/code/Magento/Payment/Test/Mftf/Metadata/payment_method-meta.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,18 @@
1111
<operation name="CreatePaymentMethod" dataType="payment_method" type="create">
1212
<field key="method">string</field>
1313
</operation>
14+
<operation name="cashondeliveryPaymentMethodSetup" dataType="cashondelivery_payment_method" type="create" auth="adminFormKey" url="/admin/system_config/save/section/payment/" method="POST">
15+
<object key="groups" dataType="cashondelivery_payment_method">
16+
<object key="cashondelivery" dataType="cashondelivery_payment_method">
17+
<object key="fields" dataType="cashondelivery_payment_method">
18+
<object key="active" dataType="active">
19+
<field key="value">string</field>
20+
</object>
21+
<object key="title" dataType="title">
22+
<field key="value">string</field>
23+
</object>
24+
</object>
25+
</object>
26+
</object>
27+
</operation>
1428
</operations>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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="AdminCreateOrderWithSimpleProductTest">
12+
<annotations>
13+
<title value="Create Order in Admin with simple product"/>
14+
<stories value="MAGETWO-12798: Create order with condition available product qty = ordered product qty"/>
15+
<description value="Create order with simple product and assert if it gets out of stock after ordering it."/>
16+
<features value="Sales"/>
17+
<severity value="AVERAGE"/>
18+
<group value="Sales"/>
19+
<group value="mtf_migrated"/>
20+
</annotations>
21+
<before>
22+
<createData entity="FlatRateShippingMethodDefault" stepKey="setDefaultFlatRateShippingMethod"/>
23+
<createData entity="CashOnDeliveryPaymentMethodDefault" stepKey="cashOnDeliveryPaymentMethod"/>
24+
<createData entity="Simple_US_Customer_CA" stepKey="simpleCustomer"/>
25+
<createData entity="SimpleProduct_25" stepKey="simpleProduct">
26+
<field key="price">5</field>
27+
</createData>
28+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
29+
</before>
30+
<actionGroup ref="navigateToNewOrderPageExistingCustomer" stepKey="navigateToNewOrderWithExistingCustomer">
31+
<argument name="customer" value="$$simpleCustomer$$"/>
32+
</actionGroup>
33+
<actionGroup ref="addSimpleProductToOrder" stepKey="addSimpleProductToOrder">
34+
<argument name="product" value="$$simpleProduct$$"/>
35+
<argument name="productQty" value="25"/>
36+
</actionGroup>
37+
<actionGroup ref="AdminSelectPaymentMethodActionGroup" stepKey="selectPaymentMethod">
38+
<argument name="paymentMethod" value="{{AdminOrderFormPaymentSection.checkCashOnDelivery}}"/>
39+
<argument name="paymentTitle" value="$$cashOnDeliveryPaymentMethod.title$$"/>
40+
</actionGroup>
41+
<actionGroup ref="orderSelectFlatRateShipping" stepKey="orderSelectFlatRateShippingMethod"/>
42+
<actionGroup ref="AdminSubmitOrderActionGroup" stepKey="submitOrder"/>
43+
<actionGroup ref="verifyCreatedOrderInformation" stepKey="verifyCreatedOrderInformation"/>
44+
<actionGroup ref="AssertAdminProductStockStatusActionGroup" stepKey="checkProductStockStatus">
45+
<argument name="productId" value="$$simpleProduct.id$$"/>
46+
<argument name="stockStatus" value="Out of Stock"/>
47+
</actionGroup>
48+
<after>
49+
<actionGroup ref="logout" stepKey="logout"/>
50+
<deleteData createDataKey="simpleCustomer" stepKey="deleteSimpleCustomer"/>
51+
<deleteData createDataKey="simpleProduct" stepKey="deleteSimpleProduct"/>
52+
</after>
53+
</test>
54+
</tests>

dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd">
99
<testCase name="Magento\Sales\Test\TestCase\CreateOrderBackendTest" summary="Create Order from Admin within Offline Payment Methods" ticketId="MAGETWO-28696">
1010
<variation name="CreateOrderBackendTestVariation18" summary="Create order with condition available product qty = ordered product qty" ticketId="MAGETWO-12798">
11+
<data name="tag" xsi:type="string">mftf_migrated:yes</data>
1112
<data name="products/0" xsi:type="string">catalogProductSimple::product_with_qty_25</data>
1213
<data name="customer/dataset" xsi:type="string">default</data>
1314
<data name="billingAddress/dataset" xsi:type="string">US_address_1_without_email</data>

0 commit comments

Comments
 (0)