Skip to content

Commit 92cb7a2

Browse files
author
Stas Puga
committed
MAGETWO-90325: Automate with MFTF tax recalculation on checkout
1 parent cc4b174 commit 92cb7a2

18 files changed

+918
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
11+
<!-- Logged in user checkout add new address Payment section -->
12+
<actionGroup name="CustomerCheckoutFillNewBillingAddressActionGroup">
13+
<arguments>
14+
<argument name="customerVar"/>
15+
<argument name="customerAddressVar"/>
16+
</arguments>
17+
<fillField selector="{{CheckoutPaymentSection.guestFirstName}}" userInput="{{customerVar.firstname}}" stepKey="enterFirstName"/>
18+
<fillField selector="{{CheckoutPaymentSection.guestLastName}}" userInput="{{customerVar.lastname}}" stepKey="enterLastName"/>
19+
<fillField selector="{{CheckoutPaymentSection.guestStreet}}" userInput="{{customerAddressVar.street[0]}}" stepKey="enterStreet"/>
20+
<fillField selector="{{CheckoutPaymentSection.guestCity}}" userInput="{{customerAddressVar.city}}" stepKey="enterCity"/>
21+
<selectOption selector="{{CheckoutPaymentSection.guestRegion}}" userInput="{{customerAddressVar.state}}" stepKey="selectRegion"/>
22+
<fillField selector="{{CheckoutPaymentSection.guestPostcode}}" userInput="{{customerAddressVar.postcode}}" stepKey="enterPostcode"/>
23+
<fillField selector="{{CheckoutPaymentSection.guestTelephone}}" userInput="{{customerAddressVar.telephone}}" stepKey="enterTelephone"/>
24+
</actionGroup>
25+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
11+
<!-- Logged in user checkout add new adress shipping section -->
12+
<actionGroup name="LoggedInUserCheckoutAddNewAddressInShippingSectionActionGroup">
13+
<arguments>
14+
<argument name="customerVar"/>
15+
<argument name="customerAddressVar"/>
16+
</arguments>
17+
<fillField selector="{{CheckoutShippingSection.addStreet}}" userInput="{{customerAddressVar.street[0]}}" stepKey="enterStreet"/>
18+
<fillField selector="{{CheckoutShippingSection.addCity}}" userInput="{{customerAddressVar.city}}" stepKey="enterCity"/>
19+
<selectOption selector="{{CheckoutShippingSection.addState}}" userInput="{{customerAddressVar.state}}" stepKey="selectRegion"/>
20+
<fillField selector="{{CheckoutShippingSection.addPostcode}}" userInput="{{customerAddressVar.postcode}}" stepKey="enterPostcode"/>
21+
<fillField selector="{{CheckoutShippingSection.addTelephone}}" userInput="{{customerAddressVar.telephone}}" stepKey="enterTelephone"/>
22+
<click selector="{{CheckoutShippingSection.addSaveButton}}" stepKey="clickSaveAdressAdd"/>
23+
<see stepKey="seeRegionSelected" selector="{{CheckoutShippingSection.selectedShippingAddress}}" userInput="{{customerAddressVar.state}}"/>
24+
<waitForPageLoad stepKey="waitPageLoad"/>
25+
</actionGroup>
26+
</actionGroups>

app/code/Magento/Checkout/Test/Mftf/Section/CheckoutPaymentSection.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,9 @@
3333
<element name="cartItemsAreaActive" type="textarea" selector=".items-in-cart.active"/>
3434
<element name="paymentSectionTitle" type="text" selector="#checkout-payment-method-load .step-title" />
3535
<element name="paymentMethodTitle" type="text" selector=".payment-method-title span" />
36+
<element name="editAddressButton" type="button" selector=".payment-method._active .action.action-edit-address"/>
37+
<element name="newAddressSelect" type="select" selector=".payment-method._active select[name*='billing_address_id']"/>
38+
<element name="goToShipping" type="button" selector="#checkout>ul>li.opc-progress-bar-item._complete>span"/>
39+
<element name="orderSummarySubtotal" type="text" selector=".totals.sub span" />
3640
</section>
3741
</sections>

app/code/Magento/Checkout/Test/Mftf/Section/CheckoutShippingMethodsSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
<element name="shippingMethodRow" type="text" selector=".form.methods-shipping table tbody tr"/>
1515
<element name="checkShippingMethodByName" type="radio" selector="//div[@id='checkout-shipping-method-load']//td[contains(., '{{var1}}')]/..//input" parameterized="true"/>
1616
<element name="shippingMethodRowByName" type="text" selector="//div[@id='checkout-shipping-method-load']//td[contains(., '{{var1}}')]/.." parameterized="true"/>
17+
<element name="flatRate" type="radio" selector="#label_carrier_flatrate_flatrate"/>
1718
</section>
1819
</sections>

app/code/Magento/Checkout/Test/Mftf/Section/CheckoutShippingSection.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,13 @@
2323
<element name="selectedShippingAddress" type="text" selector=".shipping-address-item.selected-item"/>
2424
<element name="newAddressButton" type="button" selector="#checkout-step-shipping button"/>
2525
<element name="next" type="button" selector="[data-role='opc-continue']"/>
26+
<element name="newAdress" type="button" selector="button.action.action-show-popup"/>
27+
<element name="newAddressStreet" type="input" selector="#shipping-new-address-form input[name='street[0]']"/>
28+
<element name="newAddressCity" type="input" selector="#shipping-new-address-form input[name='city']"/>
29+
<element name="newAddressState" type="select" selector="#shipping-new-address-form select[name='region_id']"/>
30+
<element name="newAddressPostcode" type="input" selector="#shipping-new-address-form input[name='postcode']"/>
31+
<element name="newTelephone" type="input" selector="#shipping-new-address-form input[name='telephone']"/>
32+
<element name="newAddressCountry" type="select" selector="#shipping-new-address-form select[name='country_id']"/>
33+
<element name="saveButton" type="button" selector=".action.primary.action-save-address"/>
2634
</section>
2735
</sections>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
10+
<test name="StorefrontCustomerCheckoutWithTaxForVirtulQuoteTest">
11+
<annotations>
12+
<features value="Tax rules creation"/>
13+
<stories value="Create a Tax rules via Admin"/>
14+
<title value="Tax for virtual quote is recalculated according to inputted data on Checkout flow for Customer"/>
15+
<description value="Tax for virtual quote is recalculated according to inputted data on Checkout flow for Customer"/>
16+
<severity value="CRITICAL"/>
17+
<testCaseId value="MAGETWO-78902"/>
18+
<group value="recalculatedTaxVirtual"/>
19+
<group value="checkoutTax"/>
20+
</annotations>
21+
<before>
22+
<createData entity="SimpleTaxRule" stepKey="createTaxRule"/>
23+
<createData entity="TaxConfig" stepKey="configTaxSettings"/>
24+
<createData entity="VirtualProduct" stepKey="createVirtualProduct">
25+
<field key="price">40.00</field>
26+
</createData>
27+
<createData entity="Simple_US_NY_Customer" stepKey="simpleUsNyCustomer"/>
28+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/>
29+
<actionGroup ref="ClearCacheActionGroup" stepKey="clearCache"/>
30+
</before>
31+
<after>
32+
<createData entity="DefaultTaxConfig" stepKey="defaultTaxSettings"/>
33+
<deleteData createDataKey="createVirtualProduct" stepKey="deleteVirtualProduct"/>
34+
<deleteData createDataKey="simpleUsNyCustomer" stepKey="deleteCustomer"/>
35+
<deleteData createDataKey="createTaxRule" stepKey="deleteTaxRule"/>
36+
<actionGroup ref="logout" stepKey="logoutOfAdmin"/>
37+
</after>
38+
<!-- Step 1: Go to Storefront as Customer -->
39+
<actionGroup ref="CustomerLoginOnStorefront" stepKey="customerLogin">
40+
<argument name="customer" value="$$simpleUsNyCustomer$$" />
41+
</actionGroup>
42+
<!-- Step 2: Add virtual product to shopping cart -->
43+
<amOnPage url="{{StorefrontProductPage.url($$createVirtualProduct.name$$)}}" stepKey="viewProduct"/>
44+
<waitForPageLoad stepKey="waitForPageLoad"/>
45+
<actionGroup ref="StorefrontAddProductToCartActionGroup" stepKey="cartAddVirtualProductToCart">
46+
<argument name="product" value="$$createVirtualProduct$$"/>
47+
<argument name="productCount" value="1"/>
48+
</actionGroup>
49+
<!-- Step 3: Go to Checkout -->
50+
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicartActionGroup"/>
51+
<seeElement selector="{{CheckoutPaymentSection.isPaymentSection}}" stepKey="seePaymentStep"/>
52+
<see userInput="$40.00" selector="{{CheckoutPaymentSection.orderSummarySubtotal}}" stepKey="seeCartSubtotalCa" />
53+
<see userInput="$3.35" selector="{{CheckoutPaymentSection.tax}}" stepKey="seeTaxInfo" />
54+
<click selector="{{CheckoutPaymentSection.taxRateTab}}" stepKey="clickTaxTabsButton" />
55+
<see userInput="US-NY-*-Rate 1 (8.375%)" selector="{{CheckoutPaymentSection.taxRate}}" stepKey="seeTaxInfoRatesNy" />
56+
<see userInput="$43.35" selector="{{CheckoutPaymentSection.orderTotalInclTax}}" stepKey="seeTotalInclTaxNy"/>
57+
<see userInput="$40.00" selector="{{CheckoutPaymentSection.orderTotalExclTax}}" stepKey="seeTotalExclTaxNy"/>
58+
<!-- Step 4: Select payment -->
59+
<!-- Step 5: Click Edit for and select new address value -->
60+
<click selector="{{CheckoutPaymentSection.editAddressButton}}" stepKey="clickEditButton"/>
61+
<selectOption selector="{{CheckoutPaymentSection.newAddressSelect}}" userInput="New Address" stepKey="selectNewAddress"/>
62+
<!-- Step 6: Fill form with valid data and set: California -->
63+
<actionGroup ref="CustomerCheckoutFillNewBillingAddressActionGroup" stepKey="guestCheckoutFillingShippingAddress">
64+
<argument name="customerVar" value="CustomerEntityOne" />
65+
<argument name="customerAddressVar" value="US_Address_CA" />
66+
</actionGroup>
67+
<!-- Step 7: Click update -->
68+
<click selector="{{CheckoutPaymentSection.update}}" stepKey="clickUpdateButton"/>
69+
<waitForLoadingMaskToDisappear stepKey="waitForLoading4" />
70+
<see userInput="California" selector="{{CheckoutPaymentSection.billingAddress}}" stepKey="seeBillingCa"/>
71+
<click selector="{{CheckoutPaymentSection.taxRateTab}}" stepKey="clickTaxTabsButtonCa" />
72+
<see userInput="US-CA-*-Rate 1 (8.25%)" selector="{{CheckoutPaymentSection.taxRate}}" stepKey="seeTaxInfoRatesCa" />
73+
</test>
74+
</tests>
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
10+
<test name="StorefrontCustomerCheckoutWithTaxTest">
11+
<annotations>
12+
<features value="TaxIsRecalculatedAccordingToInputtedDataOnCheckoutFlowForGuestTest"/>
13+
<stories value="Create order in store front with taxes"/>
14+
<title value="Tax is recalculated according to inputted data on Checkout flow for Customer"/>
15+
<description value="Tax is recalculated according to inputted data on Checkout flow for Customer"/>
16+
<severity value="CRITICAL"/>
17+
<testCaseId value="MAGETWO-78903"/>
18+
<group value="recalculatedTax"/>
19+
<group value="checkoutTax"/>
20+
</annotations>
21+
<before>
22+
<createData entity="SimpleTaxRule" stepKey="createTaxRule"/>
23+
<createData entity="TaxConfig" stepKey="createConf"/>
24+
<createData entity="_defaultCategory" stepKey="createCategory"/>
25+
<createData entity="_defaultProduct" stepKey="createSimpleProduct">
26+
<field key="price">10.00</field>
27+
<requiredEntity createDataKey="createCategory"/>
28+
</createData>
29+
<createData entity="Simple_US_NY_Customer" stepKey="simpleUsNyCustomer"/>
30+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/>
31+
<actionGroup ref="ClearCacheActionGroup" stepKey="clearCache"/>
32+
</before>
33+
<after>
34+
<createData entity="DefaultTaxConfig" stepKey="defaultConf"/>
35+
<deleteData createDataKey="createCategory" stepKey="deleteMyNewCategory"/>
36+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
37+
<deleteData createDataKey="simpleUsNyCustomer" stepKey="deleteMyNewCustomer"/>
38+
<deleteData createDataKey="createTaxRule" stepKey="deleteTaxRule"/>
39+
<actionGroup ref="logout" stepKey="logoutOfAdmin"/>
40+
</after>
41+
<!-- Step 1: Go to Storefront as Customer -->
42+
<actionGroup ref="CustomerLoginOnStorefront" stepKey="customerLogin">
43+
<argument name="customer" value="$$simpleUsNyCustomer$$" />
44+
</actionGroup>
45+
<!-- Step 2: Add simple product to shopping cart -->
46+
<amOnPage url="{{StorefrontProductPage.url($$createSimpleProduct.name$$)}}" stepKey="viewProduct"/>
47+
<waitForPageLoad stepKey="waitForPageLoad"/>
48+
<actionGroup ref="StorefrontAddProductToCartActionGroup" stepKey="cartAddSimpleProductToCart">
49+
<argument name="product" value="$$createSimpleProduct$$"/>
50+
<argument name="productCount" value="1"/>
51+
</actionGroup>
52+
<!-- Step 3: Go to Checkout -->
53+
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicartActionGroup"/>
54+
<seeElement selector="{{CheckoutShippingSection.isShippingStep}}" stepKey="shippingStepIsOpened"/>
55+
<see stepKey="seeRegion" selector="{{CheckoutShippingSection.selectedShippingAddress}}" userInput="New York"/>
56+
<waitForElement selector="{{CheckoutShippingMethodsSection.next}}" time="30" stepKey="waitForNextButton"/>
57+
<!-- Step 4: Select Flat Rate as shipping -->
58+
<click selector="{{CheckoutShippingMethodsSection.flatRate}}" stepKey="selectShippingMethod"/>
59+
<!-- Step 5: Go Next -->
60+
<click selector="{{CheckoutShippingMethodsSection.next}}" stepKey="clickNext"/>
61+
<waitForPageLoad stepKey="waitPaymentStep"/>
62+
<seeInCurrentUrl url="{{CheckoutPage.url}}/#payment" stepKey="paymentStepIsOpened"/>
63+
<see userInput="$0.84" selector="{{CheckoutPaymentSection.tax}}" stepKey="seeTax"/>
64+
<click selector="{{CheckoutPaymentSection.taxRateTab}}" stepKey="clickTaxTabsButton" />
65+
<see userInput="US-NY-*-Rate 1 (8.375%)" selector="{{CheckoutPaymentSection.taxRate}}" stepKey="seeOrderTaxRate"/>
66+
<see userInput="$15.84" selector="{{CheckoutPaymentSection.orderTotalInclTax}}" stepKey="seeOrderPriceIncl"/>
67+
<see userInput="$15.00" selector="{{CheckoutPaymentSection.orderTotalExclTax}}" stepKey="seeOrderPriceExcl"/>
68+
<!-- Step 6: Go to the previous step - Shipping -->
69+
<click selector="{{CheckoutPaymentSection.goToShipping}}" stepKey="clickGoToShipping" />
70+
<waitForPageLoad stepKey="waitForPage"/>
71+
<!-- Step 7: Click New Address button -->
72+
<click selector="{{CheckoutShippingSection.newAdress}}" stepKey="clickAddNewAddress"/>
73+
<waitForPageLoad stepKey="waitForPagePopup"/>
74+
<!-- Step 8: Fill form with valid data and set: California -->
75+
<!-- Step 9: Click Save Address -->
76+
<actionGroup ref="LoggedInUserCheckoutAddNewAddressInShippingSectionActionGroup" stepKey="guestCheckoutFillingShippingAddress">
77+
<argument name="customerVar" value="CustomerEntityOne"/>
78+
<argument name="customerAddressVar" value="US_Address_CA"/>
79+
</actionGroup>
80+
<!-- Step 10: Go next -->
81+
<click selector="{{CheckoutShippingMethodsSection.next}}" stepKey="clickNext2"/>
82+
<waitForPageLoad stepKey="waitPaymentStep2"/>
83+
<seeInCurrentUrl url="{{CheckoutPage.url}}/#payment" stepKey="payment2StepIsOpened"/>
84+
<see userInput="$0.83" selector="{{CheckoutPaymentSection.tax}}" stepKey="seeTaxPrice2"/>
85+
<click selector="{{CheckoutPaymentSection.taxRateTab}}" stepKey="clickTaxTabsButton2" />
86+
<see userInput="US-CA-*-Rate 1 (8.25%)" selector="{{CheckoutPaymentSection.taxRate}}" stepKey="seeOrderTaxRate2"/>
87+
<see userInput="$15.83" selector="{{CheckoutPaymentSection.orderTotalInclTax}}" stepKey="seeOrderPriceIncl2"/>
88+
<see userInput="$15.00" selector="{{CheckoutPaymentSection.orderTotalExclTax}}" stepKey="seeOrderPriceExcl2"/>
89+
</test>
90+
</tests>

0 commit comments

Comments
 (0)