Skip to content

Commit

Permalink
Merged PR 58448: Order place MFTF tests
Browse files Browse the repository at this point in the history
## What's being changed

This PR adds three new MFTF tests for order placement when this module is enabled. There's a test for a customer order with and without an active Dotdigital account connection, and a test for a subscribed guest order.

## Why it's being changed

Checkout is critical and we want to be sure we haven't accidentally broken it.

## How to review / test this change

- See the tests pass in the build (the whole thing may not be 100% green)
- Run PlaceOrderAsSubscribedGuestTest locally, first changing `Dotdigitalgroup\Email\Model\Subscriber::TOPIC_NEWSLETTER_SUBSCRIPTION` to something bad
- Confirm the test fails

## Notes

Testing of automation enrolment following an order has been pretty thoroughly tested in a new integration test for the OrderSaveAfter observer, so I haven't added automation config / testing here.

I initially had some extra steps in PlaceOrderAsSubscribedGuestTest, to check the contact report and look for a matching subscriber marked as imported. It worked locally, but it refused to in the pipeline. I tried many different things, and ran the MFTF suite against this PR probably about 100 times. In the end I've given up and omitted these steps. I think this is fine because a) our report row filter tests aren't actually very good (they check for the presence of the string 'Imported' in any table cell in the grid) and b) the test still fails if the topic is bad, which is the original scenario we wanted to protect against.

Related work items: #265647
  • Loading branch information
sta1r committed Oct 7, 2024
1 parent 9fccc9d commit 5a12150
Show file tree
Hide file tree
Showing 5 changed files with 193 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="ResetReportFilters">
<annotations>
<description>Resets report filters.</description>
</annotations>

<conditionalClick selector="{{AdminFilterOptionsSection.clearFilters}}" dependentSelector="{{AdminFilterOptionsSection.clearFilters}}" visible="true" stepKey="clickClearFilters"/>
<conditionalClick selector="{{AdminFilterOptionsSection.filters}}" dependentSelector="{{AdminFilterOptionsSection.filterFormContainer}}" visible="false" stepKey="openFilters2"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
<page name="AdminOrderReportPage" url="dotdigitalgroup_email/order/index/" area="admin" module="Dotdigitalgroup_Email">
<section name="AdminOrderReportPageSection"/>
</page>
</pages>
62 changes: 62 additions & 0 deletions Test/Mftf/Test/PlaceOrderAsCustomerAccountNotEnabledTest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="PlaceOrderAsCustomerAccountNotEnabledTest">
<annotations>
<features value="Dotdigital module"/>
<stories value="Dotdigital order flow test"/>
<title value="Test order place as customer with no active connection to Dotdigital"/>
<description value="Validate that an order can be placed as a customer even if the account connection is not yet active."/>
<severity value="CRITICAL"/>
<group value="dotmailer"/>
</annotations>

<before>
<actionGroup ref="AdminLoginActionGroup" stepKey="AdminLoginActionGroup1"/>
<comment userInput="Set default flat rate shipping method settings" stepKey="setDefaultFlatRateShippingMethodComment"/>
<createData entity="FlatRateShippingMethodDefault" stepKey="setDefaultFlatRateShippingMethod"/>
<!-- Create simple customer -->
<comment userInput="Create simple customer" stepKey="createSimpleCustomerComment"/>
<createData entity="Simple_US_Customer_CA" stepKey="simpleCustomer"/>
<!-- Create the category -->
<comment userInput="Create the category" stepKey="createCategoryComment"/>
<createData entity="ApiCategory" stepKey="createCategory"/>
<!-- Create Simple Product -->
<comment userInput="Create Simple Product" stepKey="createSimpleProductComment"/>
<createData entity="SimpleProductPrice10Qty1" stepKey="simpleProduct">
<requiredEntity createDataKey="createCategory"/>
</createData>
</before>

<after>
<deleteData createDataKey="simpleCustomer" stepKey="deleteSimpleCustomer"/>
<deleteData createDataKey="simpleProduct" stepKey="deleteSimpleProduct"/>
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
</after>

<actionGroup ref="CreateOrderActionGroup" stepKey="createNewOrder">
<argument name="product" value="$$simpleProduct$$"/>
<argument name="customer" value="$$simpleCustomer$$"/>
</actionGroup>
<grabFromCurrentUrl regex="~/order_id/(\d+)/~" stepKey="grabOrderId"/>

<!-- Check that order is created and marked as not processed. -->
<amOnPage url="{{AdminOrderReportPage.url}}" stepKey="amOnDotdigitalOrderReportPage"/>
<actionGroup ref="FilterReport" stepKey="filterOrder1">
<argument name="inputName" value="order_id"/>
<argument name="inputValue" value="{$grabOrderId}"/>
</actionGroup>
<seeElement selector="{{AdminDotdigitalReportColumnsSection.statusInGrid('Not processed')}}" stepKey="seeRecordFound"/>

<!-- Check that contact is not added to our table. -->
<amOnPage url="{{AdminContactReportPage.url}}" stepKey="amOnDotdigitalContactReportPage"/>
<actionGroup ref="FilterReport" stepKey="filterEmail1">
<argument name="inputName" value="email"/>
<argument name="inputValue" value="Simple_US_Customer_CA.email"/>
</actionGroup>
<dontSeeElement selector="{{AdminDotdigitalReportColumnsSection.statusInGrid('Not Imported')}}" stepKey="seeRecordNotFound"/>
</test>
</tests>


57 changes: 57 additions & 0 deletions Test/Mftf/Test/PlaceOrderAsCustomerTest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="PlaceOrderAsCustomerTest">
<annotations>
<features value="Dotdigital module"/>
<stories value="Dotdigital order flow test"/>
<title value="Test order place as customer"/>
<description value="Validate that an order can be placed as a customer."/>
<severity value="CRITICAL"/>
<group value="dotmailer"/>
</annotations>

<before>
<actionGroup ref="AdminLoginActionGroup" stepKey="AdminLoginActionGroup1"/>
<actionGroup ref="SetDotmailerAccountData" stepKey="SetDotmailerAccountData"/>

<comment userInput="Set default flat rate shipping method settings" stepKey="setDefaultFlatRateShippingMethodComment"/>
<createData entity="FlatRateShippingMethodDefault" stepKey="setDefaultFlatRateShippingMethod"/>
<!-- Create simple customer -->
<comment userInput="Create simple customer" stepKey="createSimpleCustomerComment"/>
<createData entity="Simple_US_Customer_CA" stepKey="simpleCustomer"/>
<!-- Create the category -->
<comment userInput="Create the category" stepKey="createCategoryComment"/>
<createData entity="ApiCategory" stepKey="createCategory"/>
<!-- Create Simple Product -->
<comment userInput="Create Simple Product" stepKey="createSimpleProductComment"/>
<createData entity="SimpleProductPrice10Qty1" stepKey="simpleProduct">
<requiredEntity createDataKey="createCategory"/>
</createData>
<actionGroup ref="CreateOrderActionGroup" stepKey="createNewOrder">
<argument name="product" value="$$simpleProduct$$"/>
<argument name="customer" value="$$simpleCustomer$$"/>
</actionGroup>
</before>

<after>
<deleteData createDataKey="simpleCustomer" stepKey="deleteSimpleCustomer"/>
<deleteData createDataKey="simpleProduct" stepKey="deleteSimpleProduct"/>
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
<actionGroup ref="ResetDotmailerAccountData" stepKey="resetAccountData"/>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
</after>

<!-- Check that contact is created and marked as not imported. -->
<amOnPage url="{{AdminContactReportPage.url}}" stepKey="amOnDotdigitalContactReportPage1"/>

<actionGroup ref="FilterReport" stepKey="filterEmail1">
<argument name="inputName" value="email"/>
<argument name="inputValue" value="{{Simple_US_Customer_CA.email}}"/>
</actionGroup>

<seeElement selector="{{AdminDotdigitalReportColumnsSection.statusInGrid('Not Imported')}}" stepKey="seeRecordFound"/>
</test>
</tests>


55 changes: 55 additions & 0 deletions Test/Mftf/Test/PlaceOrderAsSubscribedGuest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="PlaceOrderAsSubscribedGuestTest">
<annotations>
<features value="Dotdigital module"/>
<stories value="Dotdigital order flow test"/>
<title value="Test order place as subscribed guest"/>
<description value="Validate that an order can be placed as a subscribed guest."/>
<severity value="CRITICAL"/>
<group value="dotmailer"/>
</annotations>

<before>
<actionGroup ref="AdminLoginActionGroup" stepKey="AdminLoginActionGroup1"/>
<actionGroup ref="SetDotmailerAccountData" stepKey="SetDotmailerAccountData"/>
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
<createData entity="SimpleProduct" stepKey="createSimpleProduct">
<requiredEntity createDataKey="createCategory"/>
</createData>
</before>

<after>
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
<actionGroup ref="ResetDotmailerAccountData" stepKey="resetAccountData"/>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
</after>

<!-- Subscribe to the newsletter -->
<actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="openStorefrontPage"/>
<actionGroup ref="StorefrontCreateNewsletterSubscriberActionGroup" stepKey="createSubscription">
<argument name="email" value="{{Simple_US_Customer.email}}"/>
</actionGroup>

<!-- Guest order (adapted from StorefrontReorderAsGuestTest). -->
<actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="openProductPageOnStorefront">
<argument name="product" value="$$createSimpleProduct$$"/>
</actionGroup>
<actionGroup ref="StorefrontAddToTheCartActionGroup" stepKey="addProductToCart"/>
<actionGroup ref="StorefrontOpenCheckoutPageActionGroup" stepKey="goToCheckoutPage"/>
<waitForPageLoad stepKey="waitForPaymentSelectionPageLoad"/>
<actionGroup ref="GuestCheckoutFillingShippingSectionActionGroup" stepKey="fillAddress">
<argument name="customerVar" value="Simple_US_Customer"/>
<argument name="customerAddressVar" value="US_Address_TX"/>
</actionGroup>
<comment userInput="BIC workaround" stepKey="waitForPlaceOrderButtonVisible"/>
<actionGroup ref="ClickPlaceOrderActionGroup" stepKey="placeOrder"/>
<comment userInput="BIC workaround" stepKey="waitUntilOrderPlaced"/>
<grabTextFrom selector="{{CheckoutSuccessMainSection.orderNumber}}" stepKey="getOrderId"/>
<assertNotEmpty stepKey="assertOrderIdIsNotEmpty" after="getOrderId">
<actualResult type="const">$getOrderId</actualResult>
</assertNotEmpty>
</test>
</tests>

0 comments on commit 5a12150

Please sign in to comment.