Skip to content

Commit

Permalink
1164: OnePageCheckoutOfflinePaymentMethodsTest rework to support MSI …
Browse files Browse the repository at this point in the history
…reservation mechanism.
  • Loading branch information
nmalevanec committed Jun 15, 2018
1 parent 55256fa commit 25b3649
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class AssertMinicartEmpty extends AbstractConstraint
public function processAssert(
CmsIndex $cmsIndex
) {
$cmsIndex->open();
\PHPUnit\Framework\Assert::assertEquals(
self::TEXT_EMPTY_MINICART,
$cmsIndex->getCartSidebarBlock()->getEmptyMessage(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<data name="shipping/shipping_method" xsi:type="string">Fixed</data>
<data name="payment/method" xsi:type="string">checkmo</data>
<data name="configData" xsi:type="string">checkmo, disable_guest_checkout, disable_customer_redirect_after_logging</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
<constraint name="Magento\Shipping\Test\Constraint\AssertShipmentSuccessCreateMessage" />
</variation>
<variation name="OnePageCheckoutUsingRegisterLink" summary="Customer is redirected to checkout on login if guest is disabled, flow with registration new Customer" ticketId="MAGETWO-49917">
<data name="issue" xsi:type="string">MAGETWO-59816: Redirect works improperly in a browser incognito mode</data>
Expand All @@ -35,7 +35,7 @@
<data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data>
<data name="payment/method" xsi:type="string">checkmo</data>
<data name="configData" xsi:type="string">checkmo, disable_guest_checkout, disable_customer_redirect_after_logging, enable_https_frontend_only</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
<constraint name="Magento\Shipping\Test\Constraint\AssertShipmentSuccessCreateMessage" />
</variation>
<variation name="OnePageCheckoutTestVariation1" summary="Checkout as UK guest with virtual product and downloadable product using coupon for not logged in customers">
<data name="tag" xsi:type="string">severity:S0</data>
Expand All @@ -51,7 +51,6 @@
<data name="status" xsi:type="string">Pending</data>
<data name="orderButtonsAvailable" xsi:type="string">Back, Send Email, Cancel, Hold, Invoice, Edit</data>
<data name="configData" xsi:type="string">checkmo_specificcountry_gb</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
<constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderButtonsAvailable" />
Expand All @@ -70,10 +69,10 @@
<item name="grandTotal" xsi:type="string">285.00</item>
</data>
<data name="payment/method" xsi:type="string">banktransfer</data>
<data name="status" xsi:type="string">Pending</data>
<data name="orderButtonsAvailable" xsi:type="string">Back, Send Email, Cancel, Hold, Ship, Invoice, Edit</data>
<data name="status" xsi:type="string">Processing</data>
<data name="orderButtonsAvailable" xsi:type="string">Back, Send Email, Cancel, Hold, Invoice, Edit</data>
<data name="configData" xsi:type="string">banktransfer</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
<constraint name="Magento\Shipping\Test\Constraint\AssertShipmentSuccessCreateMessage" />
<constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderButtonsAvailable" />
Expand All @@ -93,10 +92,10 @@
<item name="grandTotal" xsi:type="string">375.00</item>
</data>
<data name="payment/method" xsi:type="string">banktransfer</data>
<data name="status" xsi:type="string">Pending</data>
<data name="orderButtonsAvailable" xsi:type="string">Back, Send Email, Cancel, Hold, Ship, Invoice, Edit</data>
<data name="status" xsi:type="string">Precessing</data>
<data name="orderButtonsAvailable" xsi:type="string">Back, Send Email, Cancel, Hold, Invoice, Edit</data>
<data name="configData" xsi:type="string">banktransfer_specificcountry_gb, can_subtract_and_can_back_in_stock</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
<constraint name="Magento\Shipping\Test\Constraint\AssertShipmentSuccessCreateMessage" />
<constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" />
<constraint name="Magento\Catalog\Test\Constraint\AssertProductsOutOfStock" />
<constraint name="Magento\Catalog\Test\Constraint\AssertProductsQtyAndStockStatusInAdminPanel" />
Expand All @@ -123,7 +122,7 @@
<data name="billingCheckboxState" xsi:type="string">Yes</data>
<data name="payment/method" xsi:type="string">checkmo</data>
<data name="configData" xsi:type="string">checkmo</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
<constraint name="Magento\Shipping\Test\Constraint\AssertShipmentSuccessCreateMessage" />
<constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal"/>
</variation>
Expand All @@ -149,7 +148,7 @@
<data name="refresh" xsi:type="boolean">true</data>
<data name="payment/method" xsi:type="string">checkmo</data>
<data name="configData" xsi:type="string">checkmo, freeshipping_minimum_order_amount_100</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
<constraint name="Magento\Shipping\Test\Constraint\AssertShipmentSuccessCreateMessage" />
<constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderAddresses" />
Expand All @@ -168,7 +167,6 @@
<data name="status" xsi:type="string">Pending</data>
<data name="orderButtonsAvailable" xsi:type="string">Back, Cancel, Send Email, Hold, Invoice, Edit</data>
<data name="configData" xsi:type="string">zero_subtotal_checkout</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
<constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderButtonsAvailable" />
Expand All @@ -185,9 +183,9 @@
<item name="grandTotal" xsi:type="string">375</item>
</data>
<data name="payment/method" xsi:type="string">checkmo</data>
<data name="status" xsi:type="string">Pending</data>
<data name="status" xsi:type="string">Processing</data>
<data name="orderButtonsAvailable" xsi:type="string">Back, Send Email, Cancel, Hold, Invoice, Edit</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
<constraint name="Magento\Shipping\Test\Constraint\AssertShipmentSuccessCreateMessage" />
<constraint name="Magento\Checkout\Test\Constraint\AssertCartIsEmpty" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderButtonsAvailable" />
Expand All @@ -208,7 +206,7 @@
<item name="grandTotal" xsi:type="string">565.00</item>
</data>
<data name="payment/method" xsi:type="string">checkmo</data>
<constraint name="Magento\Customer\Test\Constraint\AssertCustomerRedirectToDashboard" />
<constraint name="Magento\Shipping\Test\Constraint\AssertShipmentSuccessCreateMessage" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" />
</variation>
<variation name="OnePageCheckoutTestVariation9" summary="One Page Checkout Products with different shipping/billing address and Tier Prices" ticketId="MAGETWO-42604">
Expand All @@ -225,7 +223,7 @@
</data>
<data name="payment/method" xsi:type="string">banktransfer</data>
<data name="configData" xsi:type="string">banktransfer_specificcountry_gb</data>
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
<constraint name="Magento\Shipping\Test\Constraint\AssertShipmentSuccessCreateMessage" />
<constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" />
<constraint name="Magento\Customer\Test\Constraint\AssertCustomerDefaultAddressFrontendAddressBook" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace Magento\Checkout\Test\TestStep;

use Magento\Checkout\Test\Constraint\AssertGrandTotalOrderReview;
use Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage;
use Magento\Checkout\Test\Page\CheckoutOnepage;
use Magento\Checkout\Test\Page\CheckoutOnepageSuccess;
use Magento\Mtf\Fixture\FixtureFactory;
Expand All @@ -32,6 +33,13 @@ class PlaceOrderStep implements TestStepInterface
*/
private $assertGrandTotalOrderReview;

/**
* Assert that order success message is correct.
*
* @var AssertOrderSuccessPlacedMessage
*/
private $assertOrderSuccessPlacedMessage;

/**
* One page checkout success page.
*
Expand Down Expand Up @@ -70,6 +78,7 @@ class PlaceOrderStep implements TestStepInterface
/**
* @param CheckoutOnepage $checkoutOnepage
* @param AssertGrandTotalOrderReview $assertGrandTotalOrderReview
* @param AssertOrderSuccessPlacedMessage $assertOrderSuccessPlacedMessage
* @param CheckoutOnepageSuccess $checkoutOnepageSuccess
* @param FixtureFactory $fixtureFactory
* @param array $products
Expand All @@ -79,6 +88,7 @@ class PlaceOrderStep implements TestStepInterface
public function __construct(
CheckoutOnepage $checkoutOnepage,
AssertGrandTotalOrderReview $assertGrandTotalOrderReview,
AssertOrderSuccessPlacedMessage $assertOrderSuccessPlacedMessage,
CheckoutOnepageSuccess $checkoutOnepageSuccess,
FixtureFactory $fixtureFactory,
array $products = [],
Expand All @@ -87,6 +97,7 @@ public function __construct(
) {
$this->checkoutOnepage = $checkoutOnepage;
$this->assertGrandTotalOrderReview = $assertGrandTotalOrderReview;
$this->assertOrderSuccessPlacedMessage = $assertOrderSuccessPlacedMessage;
$this->checkoutOnepageSuccess = $checkoutOnepageSuccess;
$this->fixtureFactory = $fixtureFactory;
$this->products = $products;
Expand All @@ -105,6 +116,7 @@ public function run()
$this->assertGrandTotalOrderReview->processAssert($this->checkoutOnepage, $this->prices['grandTotal']);
}
$this->checkoutOnepage->getPaymentBlock()->getSelectedPaymentMethodBlock()->clickPlaceOrder();
$this->assertOrderSuccessPlacedMessage->processAssert($this->checkoutOnepageSuccess);
$orderId = $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId();
$data = [
'id' => $orderId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
<step name="fillBillingInformation" module="Magento_Checkout" next="refreshPage" />
<step name="refreshPage" module="Magento_Checkout" next="placeOrder" />
<step name="placeOrder" module="Magento_Checkout" next="createCustomerAccount" />
<step name="createCustomerAccount" module="Magento_Checkout" />
<step name="createCustomerAccount" module="Magento_Checkout" next="createShipment" />
<step name="createShipment" module="Magento_Sales"/>
</scenario>
<scenario name="OnePageCheckoutJsValidationTest" firstStep="setupConfiguration">
<step name="setupConfiguration" module="Magento_Config" next="createProducts" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ class Actions extends Block
*/
protected $confirmModal = '.confirm._show[data-role=modal]';

/**
* Is shipment can be created.
*
* @return bool
*/
public function canShip()
{
return $this->_rootElement->find($this->ship)->isVisible();
}

/**
* Ship order.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,21 @@ public function run()
{
$this->orderIndex->open();
$this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $this->order->getId()]);
$this->salesOrderView->getPageActions()->ship();
if (!empty($this->data)) {
$this->orderShipmentNew->getFormBlock()->fillData($this->data, $this->order->getEntityId()['products']);
$shipmentIds = [];
/**
* As this step is used in general scenarios and not all test cases has shippable items(ex: virtual product)
* we need to check, if it possible to create shipment for given order.
*/
if ($this->salesOrderView->getPageActions()->canShip()) {
$this->salesOrderView->getPageActions()->ship();
if (!empty($this->data)) {
$this->orderShipmentNew->getFormBlock()->fillData($this->data, $this->order->getEntityId()['products']);
}
$this->orderShipmentNew->getFormBlock()->submit();
$shipmentIds = $this->getShipmentIds();
}
$this->orderShipmentNew->getFormBlock()->submit();

return ['shipmentIds' => $this->getShipmentIds()];
return ['shipmentIds' => $shipmentIds];
}

/**
Expand Down

0 comments on commit 25b3649

Please sign in to comment.