Skip to content

Commit

Permalink
MAGETWO-91769: Credit Memo - Wrong tax calculation! #10982
Browse files Browse the repository at this point in the history
- Add automated test
  • Loading branch information
lusinehak committed Sep 26, 2018
1 parent 6cc067a commit bb65b43
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
<element name="saveAndClose" type="button" selector="span[title='Save &amp; Close']" timeout="30"/>
<element name="changeStoreButton" type="button" selector="#store-change-button" timeout="10"/>
<element name="selectStoreView" type="button" selector="//ul[@data-role='stores-list']/li/a[normalize-space(.)='{{var1}}']" timeout="10" parameterized="true"/>
<element name="selectTaxClass" type="select" selector="select[name='product[tax_class_id]']"/>
</section>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@
<element name="emailCopy" type="checkbox" selector=".order-totals-actions #send_email"/>
<element name="refundStoreCredit" type="checkbox" selector=".order-totals-actions .field-refund-store-credit input[type='checkbox']"/>
<element name="submitRefundOffline" type="button" selector=".order-totals-actions button[data-ui-id='order-items-submit-button']" timeout="30"/>
<element name="creditMemoItem" type="text" selector="#sales_order_view_tabs_order_creditmemos"/>
<element name="viewMemo" type="text" selector="div#sales_order_view_tabs_order_creditmemos_content a.action-menu-item"/>
</section>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@
<see stepKey="seeSuccess" selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the configuration."/>
</actionGroup>

<actionGroup name="addCustomTaxRate" extends="addNewTaxRateNoZip">
<remove keyForRemoval="fillZipCode"/>
<remove keyForRemoval="fillRate"/>
<fillField stepKey="fillZipCode" selector="{{AdminTaxRulesSection.zipCode}}" userInput="US-NY-*-Rate 2" after="fillTaxIdentifier"/>
<fillField stepKey="fillRate" selector="{{AdminTaxRulesSection.rate}}" userInput="0" after="selectCountry"/>
</actionGroup>

<!-- Action group to add a tax rate when on a tax rule configuration page -->
<!-- Must already be on a tax rule configuration page or a new tax rule page -->
<actionGroup name="addNewTaxRateNoZip">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,10 @@
<element name="systemValueDisplayZeroTaxSales" type="checkbox" selector="#row_tax_sales_display_zero_tax input[type='checkbox']"/>
<element name="dropdownDisplayZeroTaxSales" type="checkbox" selector="#row_tax_sales_display_zero_tax select"/>
<element name="fixedProductTaxes" type="block" selector="#tax_weee-head" timeout="30"/>

<element name="taxClassesCondition" type="block" selector="//a[@id='tax_classes-head' and @class='open']" timeout="30"/>
<element name="useSystemValue" type="checkbox" selector="#tax_classes_default_product_tax_class_inherit"/>
<element name="productTaxClass" type="select" selector="#tax_classes_default_product_tax_class"/>
<element name="save" type="button" selector="#save"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="AdminProductTaxClassSection">
<element name="additionalSettings" type="text" selector="#details-summarybase_fieldset"/>
<element name="additionalSettingsCond" type="text" selector="//summary[@id='details-summarybase_fieldset' and @aria-expanded='true']"/>
<element name="productTaxClass" type="button" selector="//div[contains(@class, 'field-tax_product_class')]//span[text()='Add New Tax Class']"/>
<element name="TaxClassName" type="block" selector="//div[contains(@class, 'field-tax_product_class')]//input[@class='mselect-input']"/>
<element name="confirm" type="button" selector="//div[contains(@class, 'field-tax_product_class')]//span[@class='mselect-save']"/>
</section>
</sections>
144 changes: 144 additions & 0 deletions app/code/Magento/Tax/Test/Mftf/Test/CheckCreditMemoTotalsTest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="CheckCreditMemoTotalsTest">
<annotations>
<features value="Tax"/>
<stories value="MAGETWO-91769 - Credit Memo - Wrong tax calculation! #10982"/>
<title value="Checking Credit memo Totals"/>
<description value="Checking Credit memo Totals"/>
<severity value="MAJOR"/>
<testCaseId value="MAGETWO-95175"/>
<group value="creditMemo"/>
<group value="tax"/>
</annotations>
<before>
<!--Create category and product-->
<createData entity="_defaultCategory" stepKey="createCategory"/>
<createData entity="_defaultProduct" stepKey="createSimpleProduct">
<requiredEntity createDataKey="createCategory"/>
</createData>
<!--Create customer-->
<createData entity="Simple_US_Customer_NY" stepKey="createCustomer"/>
<!--Login as admin-->
<actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/>
<!--Create tax rule and tax rate-->
<amOnPage url="{{AdminTaxRuleGridPage.url}}" stepKey="goToTaxRulePage"/>
<waitForPageLoad stepKey="waitForTaxRatePage"/>
<click stepKey="addNewTaxRate" selector="{{AdminGridMainControls.add}}"/>
<fillField stepKey="fillRuleName" selector="{{AdminTaxRulesSection.ruleName}}" userInput="SampleRule"/>
<actionGroup ref="addCustomTaxRate" stepKey="addCustomTaxRate">
<argument name="taxCode" value="SimpleTaxNY"/>
</actionGroup>
<click stepKey="expandAdditionalSettings" selector="{{AdminProductTaxClassSection.additionalSettings}}"/>
<waitForPageLoad stepKey="waitForPageLoad"/>
<click selector="{{AdminProductTaxClassSection.productTaxClass}}" stepKey="ClickToAddTaxClass"/>
<fillField selector="{{AdminProductTaxClassSection.TaxClassName}}" userInput="NewTaxClass" stepKey="setName"/>
<click selector="{{AdminProductTaxClassSection.confirm}}" stepKey="ClickToDone"/>
<click stepKey="clickSave" selector="{{AdminStoresMainActionsSection.saveButton}}"/>
<waitForPageLoad stepKey="waitForTaxRatePage1"/>
<see userInput="You saved the tax rule." stepKey="VerifyRuleSaved"/>
<!--Search and edit product to add new created tax rule-->
<actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForSimpleProduct">
<argument name="product" value="$$createSimpleProduct$$"/>
</actionGroup>
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="OpenEditProductOnBackend">
<argument name="product" value="$$createSimpleProduct$$"/>
</actionGroup>
<waitForPageLoad stepKey="waitForPageLoad2"/>
<selectOption selector="{{AdminProductFormActionSection.selectTaxClass}}" userInput="NewTaxClass" stepKey="SetNewTaxClass" />
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveProduct"/>
<!--Set configs-->
<amOnPage url="{{AdminTaxConfigurationPage.url}}" stepKey="goToTaxConfigPage"/>
<conditionalClick stepKey="clickOrdersInvoicesCreditSales" selector="{{AdminConfigureTaxSection.taxClasses}}" dependentSelector="{{AdminConfigureTaxSection.taxClassesCondition}}" visible="false"/>
<click selector="{{AdminConfigureTaxSection.useSystemValue}}" stepKey="UncheckUseSystemValue"/>
<selectOption selector="{{AdminConfigureTaxSection.productTaxClass}}" userInput="NewTaxClass" stepKey="selectClass"/>
<click selector="{{AdminConfigureTaxSection.save}}" stepKey="saveConfig"/>
<!--flash cache-->
<magentoCLI command="cache:flush" stepKey="flushCache"/>
</before>
<after>
<!--Delete category and product-->
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
<!--Delete customer-->
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
<!--Roll Back configuration-->
<amOnPage url="{{AdminTaxConfigurationPage.url}}" stepKey="goToTaxConfigPage"/>
<conditionalClick stepKey="clickOrdersInvoicesCreditSales" selector="{{AdminConfigureTaxSection.taxClasses}}" dependentSelector="{{AdminConfigureTaxSection.taxClassesCondition}}" visible="false"/>
<selectOption selector="{{AdminConfigureTaxSection.productTaxClass}}" userInput="Taxable Goods" stepKey="selectClass"/>
<click selector="{{AdminConfigureTaxSection.useSystemValue}}" stepKey="UncheckUseSystemValue"/>
<click selector="{{AdminConfigureTaxSection.save}}" stepKey="saveConfig"/>
<!-- Go to the tax rule page and delete the row we created-->
<amOnPage url="{{AdminTaxRuleGridPage.url}}" stepKey="goToTaxRulesPage"/>
<waitForPageLoad stepKey="waitForRulesPage"/>
<actionGroup ref="deleteEntitySecondaryGrid" stepKey="deleteRule">
<argument name="name" value="SampleRule"/>
<argument name="searchInput" value="{{AdminSecondaryGridSection.taxIdentifierSearch}}"/>
</actionGroup>
<!-- Go to the tax rate page -->
<amOnPage url="{{AdminTaxRateGridPage.url}}" stepKey="goToTaxRatesPage"/>
<waitForPageLoad stepKey="waitForRatesPage"/>
<!-- Delete tax rate that were created -->
<actionGroup ref="deleteEntitySecondaryGrid" stepKey="deleteNYRate">
<argument name="name" value="{{SimpleTaxNY.state}}"/>
<argument name="searchInput" value="{{AdminSecondaryGridSection.taxIdentifierSearch}}"/>
</actionGroup>
<actionGroup ref="deleteProductTaxClass" stepKey="deleteFirstProductTaxClass">
<argument name="taxClassName" value="NewTaxClass"/>
</actionGroup>
<!--logout-->
<actionGroup ref="logout" stepKey="logout"/>
</after>
<!--Create new order-->
<actionGroup stepKey="CreateNewOrder" ref="navigateToNewOrderPageExistingCustomer">
<argument name="customer" value="Simple_US_Customer_NY"/>
</actionGroup>
<!--Add product to order-->
<click stepKey="clickToAddProduct" selector="{{AdminOrderFormItemsSection.addProducts}}"/>
<waitForPageLoad stepKey="waitForProductsOpened"/>
<checkOption selector="{{AdminOrderFormItemsSection.rowCheck('1')}}" stepKey="selectProduct"/>
<click selector="{{AdminOrderFormItemsSection.addSelected}}" stepKey="clickAddSelectedProducts"/>
<waitForPageLoad stepKey="waitForPageLoad3"/>
<!--Set shipping method-->
<actionGroup stepKey="orderSelectFlatRateShipping" ref="orderSelectFlatRateShipping"/>
<!--Submit order-->
<click stepKey="SubmitOrder" selector="{{AdminOrderFormActionSection.SubmitOrder}}"/>
<waitForPageLoad stepKey="waitForPageLoad4"/>
<grabTextFrom stepKey="getOrderId" selector="|Order # (\d+)|"/>
<!--Open new created order-->
<amOnPage url="{{AdminOrdersPage.url}}" stepKey="goToOrders"/>
<waitForPageLoad stepKey="waitForPageLoad5"/>
<actionGroup ref="filterOrderGridById" stepKey="filterOrderGridById">
<argument name="orderId" value="$getOrderId"/>
</actionGroup>
<!--Create order invoice-->
<click selector="{{AdminDataGridTableSection.rowViewAction('1')}}" stepKey="clickCreatedOrderInGrid"/>
<click selector="{{AdminOrderDetailsMainActionsSection.invoice}}" stepKey="clickInvoiceAction"/>
<see selector="{{AdminHeaderSection.pageTitle}}" userInput="New Invoice" stepKey="seePageNameNewInvoicePage"/>
<click selector="{{AdminInvoiceMainActionsSection.submitInvoice}}" stepKey="clickSubmitInvoice"/>
<see selector="{{AdminOrderDetailsMessagesSection.successMessage}}" userInput="The invoice has been created." stepKey="seeInvoiceCreateSuccess"/>
<see selector="{{AdminInvoiceOrderInformationSection.orderStatus}}" userInput="Processing" stepKey="seeOrderProcessing"/>
<!--Create Credit Memo-->
<click selector="{{AdminOrderDetailsMainActionsSection.creditMemo}}" stepKey="clickCreditMemoAction"/>
<fillField selector="{{AdminCreditMemoTotalSection.refundShipping}}" userInput="0" stepKey="setRefundShipping"/>
<see selector="{{AdminHeaderSection.pageTitle}}" userInput="New Memo" stepKey="seeNewMemoInPageTitle"/>
<click selector="{{AdminCreditMemoTotalSection.submitRefundOffline}}" stepKey="clickRefundOffline"/>
<see selector="{{AdminOrderDetailsMessagesSection.successMessage}}" userInput="You created the credit memo." stepKey="seeCreditMemoSuccess"/>
<click selector="{{AdminCreditMemoTotalSection.creditMemoItem}}" stepKey="goToCreatedCreditMemo"/>
<waitForPageLoad stepKey="waitForPageLoad6"/>
<!--View created memo and verify tax for product-->
<click selector="{{AdminCreditMemoTotalSection.viewMemo}}" stepKey="ViewMemo"/>
<waitForPageLoad stepKey="waitForPageLoad7"/>
<grabTextFrom selector="{{AdminCreditMemoTotalSection.grandTotal}}" stepKey="getGrandTotal"/>
<assertEquals expected='$123.00' expectedType="string" actual="($getGrandTotal)" stepKey="assertGrandTotalValue"/>

</test>
</tests>

0 comments on commit bb65b43

Please sign in to comment.