Skip to content

Commit bfbb981

Browse files
MAGETWO-91521: Reports / Sales / Tax report show incorrect amount
- Add automated test
1 parent 8e36968 commit bfbb981

File tree

6 files changed

+300
-0
lines changed

6 files changed

+300
-0
lines changed

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<element name="productStatusUseDefault" type="checkbox" selector="input[name='use_default[status]']"/>
2121
<element name="productNameUseDefault" type="checkbox" selector="input[name='use_default[name]']"/>
2222
<element name="productPrice" type="input" selector=".admin__field[data-index=price] input"/>
23+
<element name="productTaxClass" type="select" selector="//*[@name='product[tax_class_id]']"/>
2324
<element name="productTaxClassUseDefault" type="checkbox" selector="input[name='use_default[tax_class_id]']"/>
2425
<element name="advancedPricingLink" type="button" selector="button[data-index='advanced_pricing_button']"/>
2526
<element name="categoriesDropdown" type="multiselect" selector="div[data-index='category_ids']"/>

app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminTaxActionGroup.xml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,43 @@
100100
<!-- Save the tax rate -->
101101
<click stepKey="saveTaxRate" selector="{{AdminTaxRulesSection.save}}"/>
102102
</actionGroup>
103+
104+
<!--Add Product Tax Class-->
105+
<actionGroup name="addProductTaxClass">
106+
<arguments>
107+
<argument name="prodTaxClassName" type="string"/>
108+
</arguments>
109+
<!--Click Additional Settings-->
110+
<click stepKey="clickAdditionalSettings" selector="{{AdminTaxRulesSection.additionalSettings}}"/>
111+
<!--Click Product Add New Tax Class Button-->
112+
<click stepKey="clickProdAddNewTaxClassBtn" selector="{{AdminTaxRulesSection.productAddNewTaxClass}}"/>
113+
<!--Fill field-->
114+
<fillField stepKey="fillProdNewTaxClass" selector="{{AdminTaxRulesSection.fieldProdNewTaxClass}}" userInput="{{prodTaxClassName}}"/>
115+
<!-- Save Product tax rate -->
116+
<click stepKey="saveProdTaxRate" selector="{{AdminTaxRulesSection.saveProdNewTaxClass}}"/>
117+
</actionGroup>
118+
119+
<!--Add New Tax Rule -->
120+
<actionGroup name="addNewTaxRuleActionGroup">
121+
<!-- Go to tax rule page -->
122+
<amOnPage url="{{AdminTaxRuleGridPage.url}}" stepKey="goToTaxRulePage"/>
123+
<waitForPageLoad stepKey="waitForTaxRatePage"/>
124+
<click stepKey="addNewTaxRate" selector="{{AdminGridMainControls.add}}"/>
125+
</actionGroup>
126+
127+
<!--Delete Product Tax Class-->
128+
<actionGroup name="deleteProductTaxClass">
129+
<arguments>
130+
<argument name="taxClassName" type="string"/>
131+
</arguments>
132+
<!-- Go to tax rule page -->
133+
<amOnPage url="/admin/tax/rule/new" stepKey="goToNewTaxRulePage"/>
134+
<waitForPageLoad stepKey="waitForTaxRatePage"/>
135+
<click stepKey="clickAdditionalSettings" selector="{{AdminTaxRulesSection.additionalSettings}}"/>
136+
<scrollTo stepKey="scrollToAdditionalSettings" selector="{{AdminTaxRulesSection.additionalSettings}}"/>
137+
<moveMouseOver stepKey="hoverDeleteElement" selector="{{AdminTaxRulesSection.deleteTaxClassName(taxClassName)}}"/>
138+
<click stepKey="deleteFirstTaxClass" selector="{{AdminTaxRulesSection.deleteTaxClass(taxClassName)}}"/>
139+
<click stepKey="acceptPopUpDialog" selector="{{AdminTaxRulesSection.popUpDialogOK}}"/>
140+
<waitForPageLoad stepKey="waitForProductTaxClassDeleted"/>
141+
</actionGroup>
103142
</actionGroups>

app/code/Magento/Tax/Test/Mftf/Data/TaxCodeData.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,16 @@
2626
<data key="zip">*</data>
2727
<data key="rate">0</data>
2828
</entity>
29+
<entity name="SimpleTaxWithZipCode" type="tax">
30+
<data key="state">California</data>
31+
<data key="country">United States</data>
32+
<data key="zip">35005</data>
33+
<data key="rate">7.25</data>
34+
</entity>
35+
<entity name="SimpleSecondTaxWithZipCode" type="tax">
36+
<data key="state">California</data>
37+
<data key="country">United States</data>
38+
<data key="zip">35005</data>
39+
<data key="rate">0.125</data>
40+
</entity>
2941
</entities>
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
11+
<section name="AdminTaxReportsSection">
12+
<element name="refreshStatistics" type="button" selector="//a[contains(text(),'here')]"/>
13+
<element name="fromDate" type="input" selector="#sales_report_from"/>
14+
<element name="toDate" type="input" selector="//*[@id='sales_report_to']/following-sibling::button"/>
15+
<element name="goTodayButton" type="input" selector="//button[contains(text(),'Go Today')]"/>
16+
<element name="showReportButton" type="button" selector="#filter_form_submit"/>
17+
<element name="taxRuleAmount" type="textarea" selector="//*[contains(text(),'{{var1}}')]/following-sibling::td[contains(@class, 'col-tax-amount')]" parameterized="true"/>
18+
</section>
19+
</sections>

app/code/Magento/Tax/Test/Mftf/Section/AdminTaxRulesSection.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,13 @@
1919
<element name="country" type="select" selector="#tax_country_id"/>
2020
<element name="rate" type="input" selector="#rate"/>
2121
<element name="save" type="button" selector=".action-save" timeout="30"/>
22+
<element name="additionalSettings" type="button" selector="#details-summarybase_fieldset"/>
23+
<element name="productAddNewTaxClass" type="button" selector="//*[@id='tax_product_class']/following-sibling::section//*[contains(text(),'Add New Tax Class')]"/>
24+
<element name="fieldProdNewTaxClass" type="input" selector="//*[@id='tax_product_class']/following-sibling::section//input[@class='mselect-input']"/>
25+
<element name="saveProdNewTaxClass" type="button" selector="//*[@id='tax_product_class']/following-sibling::section//span[@class='mselect-save']"/>
26+
<element name="defaultTaxClass" type="button" selector="//*[@id='tax_product_class']/following-sibling::section//div[@class='mselect-items-wrapper']/div[1]"/>
27+
<element name="deleteTaxClassName" type="button" selector="//span[contains(text(),'{{var1}}')]" parameterized="true"/>
28+
<element name="deleteTaxClass" type="button" selector="//span[contains(text(),'{{var1}}')]/../..//*[@class='mselect-delete']" parameterized="true"/>
29+
<element name="popUpDialogOK" type="button" selector="//*[@class='modal-footer']//*[contains(text(),'OK')]"/>
2230
</section>
2331
</sections>
Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
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="../../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
11+
<test name="AdminTaxReportGridTest">
12+
<annotations>
13+
<features value="Tax"/>
14+
<stories value="MAGETWO-91521: Reports / Sales / Tax report show incorrect amount"/>
15+
<title value="Checking Tax Report grid"/>
16+
<description value="Tax Report Grid displays Tax amount in rows 'Total' and 'Subtotal' is a sum of all tax amounts"/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="MAGETWO-94338"/>
19+
<group value="Tax"/>
20+
</annotations>
21+
<before>
22+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
23+
24+
<!-- Go to tax rule page -->
25+
<actionGroup ref="addNewTaxRuleActionGroup" stepKey="addFirstTaxRuleActionGroup"/>
26+
<fillField stepKey="fillRuleName" selector="{{AdminTaxRulesSection.ruleName}}" userInput="TaxRule1"/>
27+
28+
<!-- Add NY and CA tax rules -->
29+
<actionGroup ref="addNewTaxRateNoZip" stepKey="addNYTaxRate">
30+
<argument name="taxCode" value="SimpleTaxWithZipCode"/>
31+
</actionGroup>
32+
33+
<actionGroup ref="addProductTaxClass" stepKey="addProductTaxClass">
34+
<argument name="prodTaxClassName" value="TaxClasses1"/>
35+
</actionGroup>
36+
37+
<click stepKey="disableDefaultProdTaxClass" selector="{{AdminTaxRulesSection.defaultTaxClass}}"/>
38+
39+
<click stepKey="clickSave" selector="{{AdminStoresMainActionsSection.saveButton}}"/>
40+
<waitForPageLoad stepKey="waitForNewTaxRuleCreated"/>
41+
42+
<!-- Go to tax rule page to create second Tax Rule-->
43+
<actionGroup ref="addNewTaxRuleActionGroup" stepKey="addSecondTaxRuleActionGroup"/>
44+
<fillField stepKey="fillSecondRuleName" selector="{{AdminTaxRulesSection.ruleName}}" userInput="TaxRule2"/>
45+
46+
<actionGroup ref="addNewTaxRateNoZip" stepKey="addCATaxRate">
47+
<argument name="taxCode" value="SimpleSecondTaxWithZipCode"/>
48+
</actionGroup>
49+
50+
<actionGroup ref="addProductTaxClass" stepKey="addSecondProductTaxClass">
51+
<argument name="prodTaxClassName" value="TaxClasses2"/>
52+
</actionGroup>
53+
54+
<click stepKey="disableSecondProdTaxClass" selector="{{AdminTaxRulesSection.defaultTaxClass}}"/>
55+
<click stepKey="clickSaveBtn" selector="{{AdminStoresMainActionsSection.saveButton}}"/>
56+
<waitForPageLoad stepKey="waitForSecondTaxRuleCreated"/>
57+
58+
<createData entity="_defaultCategory" stepKey="createCategory"/>
59+
<createData entity="_defaultProduct" stepKey="firstProduct">
60+
<requiredEntity createDataKey="createCategory"/>
61+
</createData>
62+
63+
<createData entity="_defaultProduct" stepKey="secondProduct">
64+
<requiredEntity createDataKey="createCategory"/>
65+
</createData>
66+
</before>
67+
68+
<!--Open Created products. In Tax Class select new created Product Tax classes.-->
69+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="goToProductIndex"/>
70+
<waitForPageLoad stepKey="wait1"/>
71+
<actionGroup ref="resetProductGridToDefaultView" stepKey="resetProductGrid"/>
72+
<actionGroup ref="filterProductGridBySku" stepKey="filterProductGridBySku">
73+
<argument name="product" value="$$firstProduct$$"/>
74+
</actionGroup>
75+
<actionGroup ref="openProducForEditByClickingRowXColumnYInProductGrid" stepKey="openFirstProductForEdit"/>
76+
<selectOption selector="{{AdminProductFormSection.productTaxClass}}" stepKey="selectTexClassForFirstProduct" userInput="TaxClasses1"/>
77+
<!-- Save the second product -->
78+
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveFirstProduct"/>
79+
<waitForPageLoad stepKey="waitForFirstProductSaved"/>
80+
81+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="againGoToProductIndex"/>
82+
<waitForPageLoad stepKey="wait2"/>
83+
<actionGroup ref="resetProductGridToDefaultView" stepKey="resetSecondProductGrid"/>
84+
<actionGroup ref="filterProductGridBySku" stepKey="filterSecondProductGridBySku">
85+
<argument name="product" value="$$secondProduct$$"/>
86+
</actionGroup>
87+
<actionGroup ref="openProducForEditByClickingRowXColumnYInProductGrid" stepKey="openSecondProductForEdit"/>
88+
<selectOption selector="{{AdminProductFormSection.productTaxClass}}" stepKey="selectTexClassForSecondProduct" userInput="TaxClasses2"/>
89+
<!-- Save the second product -->
90+
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveSecondProduct"/>
91+
<waitForPageLoad stepKey="waitForSecondProductSaved"/>
92+
93+
<!--Create an order with these 2 products in that zip code.-->
94+
<amOnPage url="{{AdminOrdersPage.url}}" stepKey="navigateToOrderIndexPage"/>
95+
<waitForPageLoad stepKey="waitForIndexPageLoad"/>
96+
<see selector="{{AdminHeaderSection.pageTitle}}" userInput="Orders" stepKey="seeIndexPageTitle"/>
97+
<click selector="{{AdminOrdersGridSection.createNewOrder}}" stepKey="clickCreateNewOrder"/>
98+
<click selector="{{AdminOrderFormActionSection.CreateNewCustomer}}" stepKey="clickCreateCustomer"/>
99+
<see selector="{{AdminHeaderSection.pageTitle}}" userInput="Create New Order" stepKey="seeNewOrderPageTitle"/>
100+
101+
<!--Check if order can be submitted without the required fields including email address-->
102+
<scrollToTopOfPage stepKey="scrollToTopOfOrderFormPage" after="seeNewOrderPageTitle"/>
103+
<actionGroup ref="addSimpleProductToOrder" stepKey="addFirstProductToOrder" after="scrollToTopOfOrderFormPage">
104+
<argument name="product" value="$$firstProduct$$"/>
105+
</actionGroup>
106+
<actionGroup ref="addSimpleProductToOrder" stepKey="addSecondProductToOrder" after="addFirstProductToOrder">
107+
<argument name="product" value="$$secondProduct$$"/>
108+
</actionGroup>
109+
110+
<!--Fill customer group and customer email-->
111+
<selectOption selector="{{AdminOrderFormAccountSection.group}}" userInput="{{GeneralCustomerGroup.code}}" stepKey="selectCustomerGroup" after="addSecondProductToOrder"/>
112+
<fillField selector="{{AdminOrderFormAccountSection.email}}" userInput="{{Simple_US_Customer.email}}" stepKey="fillCustomerEmail" after="selectCustomerGroup"/>
113+
114+
<!--Fill customer address information-->
115+
<actionGroup ref="fillOrderCustomerInformation" stepKey="fillCustomerAddress" after="fillCustomerEmail">
116+
<argument name="customer" value="Simple_US_Customer"/>
117+
<argument name="address" value="US_Address_TX"/>
118+
</actionGroup>
119+
120+
<!-- Select shipping -->
121+
<actionGroup ref="orderSelectFlatRateShipping" stepKey="selectFlatRateShipping" after="fillCustomerAddress"/>
122+
123+
<!--Submit Order and verify information-->
124+
<click selector="{{AdminOrderFormActionSection.SubmitOrder}}" stepKey="clickSubmitOrder" after="selectFlatRateShipping"/>
125+
<seeInCurrentUrl url="{{AdminOrderDetailsPage.url}}" stepKey="seeViewOrderPage" after="clickSubmitOrder"/>
126+
<see selector="{{AdminOrderDetailsMessagesSection.successMessage}}" userInput="You created the order." stepKey="seeSuccessMessage" after="seeViewOrderPage"/>
127+
128+
<!--Create Invoice and Shipment for this Order.-->
129+
<click selector="{{AdminOrderDetailsMainActionsSection.invoice}}" stepKey="clickInvoiceButton"/>
130+
<see selector="{{AdminHeaderSection.pageTitle}}" userInput="New Invoice" stepKey="seeNewInvoiceInPageTitle" after="clickInvoiceButton"/>
131+
<waitForPageLoad stepKey="waitForInvoicePageOpened"/>
132+
133+
<click selector="{{AdminInvoiceMainActionsSection.submitInvoice}}" stepKey="clickSubmitInvoice"/>
134+
<waitForPageLoad stepKey="waitForInvoiceSaved"/>
135+
136+
<click selector="{{AdminOrderDetailsMainActionsSection.ship}}" stepKey="clickShipAction" after="waitForInvoiceSaved"/>
137+
<seeInCurrentUrl url="{{AdminShipmentNewPage.url}}" stepKey="seeOrderShipmentUrl" after="clickShipAction"/>
138+
<!--Submit Shipment-->
139+
<click selector="{{AdminShipmentMainActionsSection.submitShipment}}" stepKey="clickSubmitShipment" after="seeOrderShipmentUrl"/>
140+
<waitForPageLoad stepKey="waitForShipmentSaved"/>
141+
142+
<!--Go to "Reports" -> "Sales" -> "Tax"-->
143+
<amOnPage url="/admin/reports/report_sales/tax/" stepKey="navigateToReportsTaxPage"/>
144+
<waitForPageLoad stepKey="waitForReportsTaxPageLoad"/>
145+
146+
<!--click "here" to refresh last day's statistics -->
147+
<click stepKey="clickRefrashStatisticsHere" selector="{{AdminTaxReportsSection.refreshStatistics}}"/>
148+
<waitForPageLoad stepKey="waitForRefrash"/>
149+
150+
<!--Select Dates-->
151+
<fillField selector="{{AdminTaxReportsSection.fromDate}}" userInput="05/16/2018" stepKey="fillDateFrom"/>
152+
<click selector="{{AdminTaxReportsSection.toDate}}" stepKey="clickDateTo"/>
153+
<click selector="{{AdminTaxReportsSection.goTodayButton}}" stepKey="clickGoTodayDate"/>
154+
<!--Click "Show report" in the upper right corner.-->
155+
<click selector="{{AdminTaxReportsSection.showReportButton}}" stepKey="clickShowReportButton"/>
156+
157+
<!--Tax Report Grid displays Tax amount in rows. "Total" and "Subtotal" is a sum of all tax amounts-->
158+
<grabTextFrom selector="{{AdminTaxReportsSection.taxRuleAmount('TaxRate1')}}" stepKey="amountOfFirstTaxRate"/>
159+
<grabTextFrom selector="{{AdminTaxReportsSection.taxRuleAmount('TaxRate2')}}" stepKey="amountOfSecondTaxRate"/>
160+
<grabTextFrom selector="{{AdminTaxReportsSection.taxRuleAmount('Subtotal')}}" stepKey="amountOfSubtotalTaxRate"/>
161+
<assertEquals stepKey="assertSubtotalFirstField">
162+
<expectedResult type="string">$0.87</expectedResult>
163+
<actualResult type="variable">amountOfFirstTaxRate</actualResult>
164+
</assertEquals>
165+
166+
<assertEquals stepKey="assertSubtotalSecondField">
167+
<expectedResult type="string">$0.02</expectedResult>
168+
<actualResult type="variable">amountOfSecondTaxRate</actualResult>
169+
</assertEquals>
170+
171+
<assertEquals stepKey="assertSubtotalField">
172+
<expectedResult type="string">$0.89</expectedResult>
173+
<actualResult type="variable">amountOfSubtotalTaxRate</actualResult>
174+
</assertEquals>
175+
176+
<after>
177+
<!-- Go to the tax rule page and delete the row we created-->
178+
<amOnPage url="{{AdminTaxRuleGridPage.url}}" stepKey="goToTaxRulesPage"/>
179+
<waitForPageLoad stepKey="waitForRulesPage"/>
180+
181+
<actionGroup ref="deleteEntitySecondaryGrid" stepKey="deleteRule">
182+
<argument name="name" value="TaxRule1"/>
183+
<argument name="searchInput" value="{{AdminSecondaryGridSection.taxIdentifierSearch}}"/>
184+
</actionGroup>
185+
186+
<actionGroup ref="deleteEntitySecondaryGrid" stepKey="deleteSecondRule">
187+
<argument name="name" value="TaxRule2"/>
188+
<argument name="searchInput" value="{{AdminSecondaryGridSection.taxIdentifierSearch}}"/>
189+
</actionGroup>
190+
191+
<!-- Go to the tax rate page -->
192+
<amOnPage url="{{AdminTaxRateGridPage.url}}" stepKey="goToTaxRatesPage"/>
193+
<waitForPageLoad stepKey="waitForRatesPage"/>
194+
195+
<!-- Delete the two tax rates that were created -->
196+
<actionGroup ref="deleteEntitySecondaryGrid" stepKey="deleteNYRate">
197+
<argument name="name" value="{{SimpleTaxWithZipCode.state}}-{{SimpleTaxWithZipCode.rate}}"/>
198+
<argument name="searchInput" value="{{AdminSecondaryGridSection.taxIdentifierSearch}}"/>
199+
</actionGroup>
200+
201+
<actionGroup ref="deleteEntitySecondaryGrid" stepKey="deleteCARate">
202+
<argument name="name" value="{{SimpleSecondTaxWithZipCode.state}}-{{SimpleSecondTaxWithZipCode.rate}}"/>
203+
<argument name="searchInput" value="{{AdminSecondaryGridSection.taxIdentifierSearch}}"/>
204+
</actionGroup>
205+
206+
<deleteData createDataKey="firstProduct" stepKey="deleteFirstProduct"/>
207+
<deleteData createDataKey="secondProduct" stepKey="deleteSecondProduct"/>
208+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
209+
210+
<actionGroup ref="deleteProductTaxClass" stepKey="deleteFirstProductTaxClass">
211+
<argument name="taxClassName" value="TaxClasses1"/>
212+
</actionGroup>
213+
214+
<actionGroup ref="deleteProductTaxClass" stepKey="deleteSecondProductTaxClass">
215+
<argument name="taxClassName" value="TaxClasses2"/>
216+
</actionGroup>
217+
218+
<amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/>
219+
</after>
220+
</test>
221+
</tests>

0 commit comments

Comments
 (0)