Skip to content

Commit f7b6084

Browse files
authored
ENGCOM-9352: [MFTF] CreateInvoiceAndCheckInvoiceOrderTest refactoring magento#33536
2 parents 0370a7f + f9d8194 commit f7b6084

8 files changed

+149
-56
lines changed
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+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminClickUpdateQtysButtonOnCreateInvoicePageActionGroup">
12+
<annotations>
13+
<description>Clicks on 'Update Qty's' on the Create Invoice page.</description>
14+
</annotations>
15+
16+
<click selector="{{AdminOrderInvoiceViewSection.updateInvoiceBtn}}" stepKey="clickUpdateQtysBtn"/>
17+
<waitForLoadingMaskToDisappear stepKey="waitForQtysUpdated"/>
18+
</actionGroup>
19+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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="AdminFillInvoiceCommentsFieldOnCreateInvoicePageActionGroup">
12+
<annotations>
13+
<description>Fills the "Invoice Comments" field on the Create Invoice page.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="comment" type="string" defaultValue="test comment"/>
17+
</arguments>
18+
19+
<fillField selector="{{AdminInvoiceTotalSection.invoiceComment}}" userInput="{{comment}}" stepKey="fillInvoiceCommentsField"/>
20+
</actionGroup>
21+
</actionGroups>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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="AdminFillQtyToInvoiceOnCreateInvoicePageActionGroup">
12+
<annotations>
13+
<description>Fills the "Qty to invoice" field on the Create Invoice page</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="qty" type="string" defaultValue="1"/>
17+
</arguments>
18+
19+
<fillField selector="{{AdminOrderInvoiceViewSection.invoiceQty}}" userInput="{{qty}}" stepKey="fillQtyToInvoiceField"/>
20+
</actionGroup>
21+
</actionGroups>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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="AdminOpenInvoiceTabFromOrderPageActionGroup">
12+
<annotations>
13+
<description>Opens the Invoice tab from the Edit Order page</description>
14+
</annotations>
15+
16+
<click selector="{{AdminOrderDetailsMainActionsSection.invoiceTab}}" stepKey="openInvoicesTabFromOrderPage"/>
17+
</actionGroup>
18+
</actionGroups>
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+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="StorefrontOpenInvoiceTabActionGroup">
12+
<annotations>
13+
<description>Opens the Invoice tab from the Order View page</description>
14+
</annotations>
15+
16+
<click selector="{{StorefrontOrderInvoicesSection.invoiceTab}}" stepKey="clickInvoiceTab"/>
17+
<waitForPageLoad stepKey="waitForInvoiceTabLoad"/>
18+
</actionGroup>
19+
</actionGroups>

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

Lines changed: 26 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -19,133 +19,103 @@
1919
<group value="mtf_migrated"/>
2020
</annotations>
2121
<before>
22-
<!-- Login as admin -->
2322
<actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/>
24-
25-
<!-- Create customer -->
2623
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
27-
28-
<!-- Create simple product -->
2924
<createData entity="SimpleProduct2" stepKey="createSimpleProduct">
3025
<field key="price">100</field>
3126
</createData>
32-
33-
<!-- Enable payment method -->
3427
<magentoCLI command="config:set {{BankTransferEnableConfigData.path}} {{BankTransferEnableConfigData.value}}" stepKey="enableBankTransfer"/>
3528
</before>
3629
<after>
37-
<!-- Disable payment method -->
3830
<magentoCLI command="config:set {{BankTransferDisabledConfigData.path}} {{BankTransferDisabledConfigData.value}}" stepKey="enableBankTransfer"/>
39-
40-
<!-- Logout customer -->
4131
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="customerLogoutStorefront"/>
42-
43-
<!-- Delete customer -->
4432
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
45-
46-
<!-- Delete product -->
4733
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
48-
49-
<!-- Log out -->
5034
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
5135
</after>
5236

53-
<!-- Create order -->
5437
<actionGroup ref="NavigateToNewOrderPageExistingCustomerActionGroup" stepKey="goToCreateOrderPage">
5538
<argument name="customer" value="$$createCustomer$$"/>
5639
</actionGroup>
57-
58-
<!-- Add product to order -->
5940
<actionGroup ref="AddSimpleProductWithQtyToOrderActionGroup" stepKey="addProductToOrder">
6041
<argument name="product" value="$$createSimpleProduct$$"/>
6142
<argument name="productQty" value="2"/>
6243
</actionGroup>
63-
64-
<!-- Select bank transfer payment method -->
6544
<actionGroup ref="SelectBankTransferPaymentMethodActionGroup" stepKey="selectPaymentMethod"/>
66-
67-
<!-- Select shipping method -->
6845
<actionGroup ref="AdminClickGetShippingMethodsAndRatesActionGroup" stepKey="openShippingMethod"/>
6946
<comment userInput="Adding the comment to replace action for preserving Backward Compatibility" stepKey="waitForShippingMethods"/>
7047
<actionGroup ref="AdminSelectFixedShippingMethodActionGroup" stepKey="chooseShippingMethod"/>
7148
<comment userInput="Adding the comment to replace action for preserving Backward Compatibility" stepKey="waitForShippingMethodLoad"/>
72-
73-
<!-- Submit order -->
7449
<actionGroup ref="AdminSubmitOrderActionGroup" stepKey="submitOrder"/>
7550

76-
<!-- Grab order id -->
7751
<comment userInput="BIC workaround" stepKey="getOrderId"/>
7852
<grabTextFrom selector="|Order # (\d+)|" stepKey="orderNumber"/>
7953
<grabFromCurrentUrl regex="~/order_id/(\d+)/~" stepKey="orderId"/>
8054

81-
<!-- Open created order -->
8255
<comment userInput="BIC workaround" stepKey="goToOrdersPage"/>
8356
<comment userInput="BIC workaround" stepKey="filterOrdersGridById"/>
8457
<comment userInput="BIC workaround" stepKey="clickCreatedOrderInGrid"/>
8558
<actionGroup ref="AdminOpenOrderByEntityIdActionGroup" stepKey="openOrder1">
8659
<argument name="entityId" value="{$orderId}"/>
8760
</actionGroup>
8861

89-
<!-- Go to invoice tab and fill data -->
9062
<actionGroup ref="AdminClickInvoiceButtonOrderViewActionGroup" stepKey="clickInvoiceAction"/>
91-
<fillField selector="{{AdminOrderInvoiceViewSection.invoiceQty}}" userInput="1" stepKey="fillInvoiceQuantity"/>
92-
<click selector="{{AdminOrderInvoiceViewSection.updateInvoiceBtn}}" stepKey="clickUpdateQtyInvoiceBtn"/>
93-
<fillField selector="{{AdminInvoiceTotalSection.invoiceComment}}" userInput="comment" stepKey="writeComment"/>
63+
<actionGroup ref="AdminFillQtyToInvoiceOnCreateInvoicePageActionGroup" stepKey="fillInvoiceQuantity"/>
64+
<actionGroup ref="AdminClickUpdateQtysButtonOnCreateInvoicePageActionGroup" stepKey="clickUpdateQtyInvoiceBtn"/>
65+
<actionGroup ref="AdminFillInvoiceCommentsFieldOnCreateInvoicePageActionGroup" stepKey="writeComment"/>
9466
<actionGroup ref="AdminInvoiceClickSubmitActionGroup" stepKey="clickSubmitInvoice"/>
95-
96-
<!-- Assert invoice with shipment success message -->
9767
<see selector="{{AdminOrderDetailsMessagesSection.successMessage}}" userInput="The invoice has been created." stepKey="seeSuccessMessage"/>
9868

99-
<!-- Assert invoice in invoices grid -->
10069
<actionGroup ref="FilterInvoiceGridByOrderIdWithCleanFiltersActionGroup" stepKey="filterInvoiceGridByOrderId">
10170
<argument name="orderId" value="$orderNumber"/>
10271
</actionGroup>
103-
<click selector="{{AdminInvoicesGridSection.firstRow}}" stepKey="opeCreatedInvoice"/>
104-
<waitForPageLoad stepKey="waitForInvoiceDetailsPageToLoad"/>
72+
<actionGroup ref="AdminSelectFirstGridRowActionGroup" stepKey="opeCreatedInvoice"/>
73+
<comment userInput="Adding the comment to replace action for preserving Backward Compatibility" stepKey="waitForInvoiceDetailsPageToLoad"/>
10574
<grabFromCurrentUrl regex="~/invoice_id/(\d+)/~" stepKey="grabInvoiceId"/>
106-
107-
<!-- Assert invoice in invoices tab -->
10875
<comment userInput="BIC workaround" stepKey="goToOrders"/>
10976
<comment userInput="BIC workaround" stepKey="filterOrderGridByIdForAssertingInvoiceBtn"/>
11077
<comment userInput="BIC workaround" stepKey="clickOrderInGrid"/>
11178
<actionGroup ref="AdminOpenOrderByEntityIdActionGroup" stepKey="openOrder2">
11279
<argument name="entityId" value="{$orderId}"/>
11380
</actionGroup>
114-
<click selector="{{AdminOrderDetailsMainActionsSection.invoiceTab}}" stepKey="clickInvoicesTabOrdersPage"/>
115-
<conditionalClick selector="{{AdminOrderInvoicesTabSection.clearFilters}}" dependentSelector="{{AdminOrderInvoicesTabSection.clearFilters}}" visible="true" stepKey="clearInvoiceFilters"/>
116-
<click selector="{{AdminOrderInvoicesTabSection.filters}}" stepKey="openOrderInvoicesGridFilters"/>
117-
<fillField selector="{{AdminOrderInvoicesTabSection.invoiceId}}" userInput="$grabInvoiceId" stepKey="fillInvoiceIdFilter"/>
118-
<fillField selector="{{AdminOrderInvoicesTabSection.amountFrom}}" userInput="110.00" stepKey="fillAmountFromFilter"/>
119-
<fillField selector="{{AdminOrderInvoicesTabSection.amountTo}}" userInput="110.00" stepKey="fillAmountToFilter"/>
120-
<click selector="{{AdminOrderInvoicesTabSection.applyFilters}}" stepKey="clickOrderApplyFilters"/>
81+
<actionGroup ref="AdminOpenInvoiceTabFromOrderPageActionGroup" stepKey="clickInvoicesTabOrdersPage"/>
82+
<actionGroup ref="AdminGridFilterResetActionGroup" stepKey="clearInvoiceFilters"/>
83+
<comment userInput="Adding the comment to replace action for preserving Backward Compatibility" stepKey="openOrderInvoicesGridFilters"/>
84+
<actionGroup ref="AdminGridFilterFillFieldBySelectorActionGroup" stepKey="fillInvoiceIdFilter">
85+
<argument name="selector" value="{{AdminOrderInvoicesTabSection.invoiceId}}"/>
86+
<argument name="filterValue" value="$grabInvoiceId"/>
87+
</actionGroup>
88+
<actionGroup ref="AdminGridFilterFillFieldBySelectorActionGroup" stepKey="fillAmountFromFilter">
89+
<argument name="selector" value="{{AdminOrderInvoicesTabSection.amountFrom}}"/>
90+
<argument name="filterValue" value="110.00"/>
91+
</actionGroup>
92+
<actionGroup ref="AdminGridFilterFillFieldBySelectorActionGroup" stepKey="fillAmountToFilter">
93+
<argument name="selector" value="{{AdminOrderInvoicesTabSection.amountTo}}"/>
94+
<argument name="filterValue" value="110.00"/>
95+
</actionGroup>
96+
<actionGroup ref="AdminClickSearchInGridActionGroup" stepKey="clickOrderApplyFilters"/>
12197
<dontSeeElement selector="{{AdminDataGridTableSection.dataGridEmpty}}" stepKey="assertThatInvoiceGridNotEmpty"/>
122-
123-
<!-- Assert invoice items -->
98+
12499
<actionGroup ref="FilterInvoiceGridByOrderIdWithCleanFiltersActionGroup" stepKey="filterInvoiceByOrderId">
125100
<argument name="orderId" value="$orderNumber"/>
126101
</actionGroup>
127-
<click selector="{{AdminInvoicesGridSection.firstRow}}" stepKey="openInvoice"/>
102+
<actionGroup ref="AdminSelectFirstGridRowActionGroup" stepKey="openInvoice"/>
128103
<waitForPageLoad stepKey="waitForInvoicePageToLoad"/>
129104
<see selector="{{AdminInvoiceTotalSection.itemName}}" userInput="$$createSimpleProduct.name$$" stepKey="seeProductNameInInvoiceItems"/>
130105
<see selector="{{AdminInvoiceTotalSection.itemQty}}" userInput="1" stepKey="seeProductQtyInInvoiceItems"/>
131106
<see selector="{{AdminInvoiceTotalSection.itemTotalPrice}}" userInput="$$createSimpleProduct.price$$" stepKey="seeProductTotalPriceInInvoiceItems"/>
132107

133-
<!-- Login as customer -->
134108
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginToStorefrontAccount">
135109
<argument name="Customer" value="$$createCustomer$$"/>
136110
</actionGroup>
137-
<waitForPageLoad stepKey="waitForCustomerLogin"/>
138-
139-
<!-- Open My Account > My Orders -->
111+
<comment userInput="Adding the comment to replace action for preserving Backward Compatibility" stepKey="waitForCustomerLogin"/>
140112
<actionGroup ref="StorefrontOpenMyAccountPageActionGroup" stepKey="goToMyAccountPage"/>
141113
<actionGroup ref="StorefrontCustomerGoToSidebarMenu" stepKey="goToSidebarMenu">
142114
<argument name="menu" value="My Orders"/>
143115
</actionGroup>
144-
145-
<!-- Assert invoiced amount on frontend -->
146-
<click selector="{{StorefrontCustomerOrderSection.viewOrder}}" stepKey="clickViewOrder"/>
116+
<actionGroup ref="StorefrontClickViewOrderLinkOnMyOrdersPageActionGroup" stepKey="clickViewOrder"/>
147117
<dontSeeElement selector="{{StorefrontOrderDetailsSection.orderDateTagElement}}" stepKey="dontSeeDateTag"/>
148-
<click selector="{{StorefrontOrderInvoicesSection.invoiceTab}}" stepKey="clickInvoiceTabOnStorefront"/>
118+
<actionGroup ref="StorefrontOpenInvoiceTabActionGroup" stepKey="clickInvoiceTabOnStorefront"/>
149119
<see selector="{{StorefrontOrderInvoicesSection.grandTotalPrice}}" userInput="$110.00" stepKey="seePrice"/>
150120
</test>
151121
</tests>
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="AdminGridFilterFillFieldBySelectorActionGroup">
12+
<annotations>
13+
<description>Fills the provided Filter Value for the element with specified selector.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="selector" type="string"/>
17+
<argument name="filterValue" type="string"/>
18+
</arguments>
19+
20+
<conditionalClick selector="{{AdminDataGridFilterSection.filtersButton}}" dependentSelector="{{AdminDataGridFilterSection.filterExpanded}}" visible="false" stepKey="expandFiltersFormIfCollapsed"/>
21+
<fillField userInput="{{filterValue}}" selector="{{selector}}" stepKey="fillFieldWithValue"/>
22+
</actionGroup>
23+
</actionGroups>

app/code/Magento/Ui/Test/Mftf/Section/AdminDataGridFilterSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
<section name="AdminDataGridFilterSection">
1212
<element name="filterForm" type="block" selector="[data-part='filter-form']" />
1313
<element name="filterExpand" type="button" selector="//div[@class='admin__data-grid-header'][(not(ancestor::*[@class='sticky-header']) and not(contains(@style,'visibility: hidden'))) or (ancestor::*[@class='sticky-header' and not(contains(@style,'display: none'))])]//button[@data-action='grid-filter-expand']" />
14+
<element name="filtersButton" type="button" selector="//button[contains(text(),'Filters')]" />
15+
<element name="filterExpanded" type="button" selector="button.action-default._active"/>
1416
<element name="inputFieldByNameAttr" type="input" selector="//*[@data-part='filter-form']//input[@name='{{inputNameAttr}}']" parameterized="true" />
1517
<element name="inputFieldByNameAttrInGrid" type="input" selector="//*[@data-role='filter-form']//input[@name='{{inputNameAttr}}']" parameterized="true"/>
1618
<element name="selectByNameAttrInGrid" type="input" selector="//*[@data-role='filter-form']//select[@name='{{inputNameAttr}}']" parameterized="true"/>

0 commit comments

Comments
 (0)