From 25b364917705d6507bff2162cdee379a8eaa02bd Mon Sep 17 00:00:00 2001 From: nmalevanec Date: Fri, 15 Jun 2018 16:17:15 +0300 Subject: [PATCH 1/3] 1164: OnePageCheckoutOfflinePaymentMethodsTest rework to support MSI reservation mechanism. --- .../Test/Constraint/AssertMinicartEmpty.php | 1 + ...ePageCheckoutOfflinePaymentMethodsTest.xml | 30 +++++++++---------- .../Checkout/Test/TestStep/PlaceOrderStep.php | 12 ++++++++ .../Magento/Checkout/Test/etc/testcase.xml | 3 +- .../Test/Block/Adminhtml/Order/Actions.php | 10 +++++++ .../Test/TestStep/CreateShipmentStep.php | 18 +++++++---- 6 files changed, 52 insertions(+), 22 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertMinicartEmpty.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertMinicartEmpty.php index 65a2b7879af8a..bb1f68c2d1278 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertMinicartEmpty.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertMinicartEmpty.php @@ -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(), diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutOfflinePaymentMethodsTest.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutOfflinePaymentMethodsTest.xml index 5e08ad3097ed3..b999900042c37 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutOfflinePaymentMethodsTest.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutOfflinePaymentMethodsTest.xml @@ -19,7 +19,7 @@ Fixed checkmo checkmo, disable_guest_checkout, disable_customer_redirect_after_logging - + MAGETWO-59816: Redirect works improperly in a browser incognito mode @@ -35,7 +35,7 @@ US_address_1_without_email checkmo checkmo, disable_guest_checkout, disable_customer_redirect_after_logging, enable_https_frontend_only - + severity:S0 @@ -51,7 +51,6 @@ Pending Back, Send Email, Cancel, Hold, Invoice, Edit checkmo_specificcountry_gb - @@ -70,10 +69,10 @@ 285.00 banktransfer - Pending - Back, Send Email, Cancel, Hold, Ship, Invoice, Edit + Processing + Back, Send Email, Cancel, Hold, Invoice, Edit banktransfer - + @@ -93,10 +92,10 @@ 375.00 banktransfer - Pending - Back, Send Email, Cancel, Hold, Ship, Invoice, Edit + Precessing + Back, Send Email, Cancel, Hold, Invoice, Edit banktransfer_specificcountry_gb, can_subtract_and_can_back_in_stock - + @@ -123,7 +122,7 @@ Yes checkmo checkmo - + @@ -149,7 +148,7 @@ true checkmo checkmo, freeshipping_minimum_order_amount_100 - + @@ -168,7 +167,6 @@ Pending Back, Cancel, Send Email, Hold, Invoice, Edit zero_subtotal_checkout - @@ -185,9 +183,9 @@ 375 checkmo - Pending + Processing Back, Send Email, Cancel, Hold, Invoice, Edit - + @@ -208,7 +206,7 @@ 565.00 checkmo - + @@ -225,7 +223,7 @@ banktransfer banktransfer_specificcountry_gb - + diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php index 13b8b9a1405fa..6840c25ed2956 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php @@ -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; @@ -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. * @@ -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 @@ -79,6 +88,7 @@ class PlaceOrderStep implements TestStepInterface public function __construct( CheckoutOnepage $checkoutOnepage, AssertGrandTotalOrderReview $assertGrandTotalOrderReview, + AssertOrderSuccessPlacedMessage $assertOrderSuccessPlacedMessage, CheckoutOnepageSuccess $checkoutOnepageSuccess, FixtureFactory $fixtureFactory, array $products = [], @@ -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; @@ -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, diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/etc/testcase.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/etc/testcase.xml index 0c8fbd5f03f9e..f0b0194039a34 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/etc/testcase.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/etc/testcase.xml @@ -38,7 +38,8 @@ - + + diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Actions.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Actions.php index 573f28f09b78c..7a6903ef47aac 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Actions.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Actions.php @@ -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. * diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateShipmentStep.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateShipmentStep.php index 79abd438a1f2e..dcee66b44646e 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateShipmentStep.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateShipmentStep.php @@ -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]; } /** From 6be8f8c0c18b4bee69e87b7c48c0253edcd88d07 Mon Sep 17 00:00:00 2001 From: nmalevanec Date: Tue, 19 Jun 2018 17:34:04 +0300 Subject: [PATCH 2/3] 1164: OnePageCheckoutOfflinePaymentMethodsTest rework to support MSI reservation mechanism. --- .../tests/app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php index 6840c25ed2956..ccf4ca35c2ffa 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php @@ -116,8 +116,8 @@ 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(); + $this->assertOrderSuccessPlacedMessage->processAssert($this->checkoutOnepageSuccess); $data = [ 'id' => $orderId, 'entity_id' => ['products' => $this->products] From a8178be70ebd502fb62ee210709b536524eea4ae Mon Sep 17 00:00:00 2001 From: nmalevanec Date: Mon, 25 Jun 2018 13:59:23 +0300 Subject: [PATCH 3/3] 1164: OnePageCheckoutOfflinePaymentMethodsTest rework to support MSI reservation mechanism. --- .../Magento/Checkout/Test/TestStep/PlaceOrderStep.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php index ccf4ca35c2ffa..964f8f366f223 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php @@ -11,6 +11,7 @@ use Magento\Checkout\Test\Page\CheckoutOnepage; use Magento\Checkout\Test\Page\CheckoutOnepageSuccess; use Magento\Mtf\Fixture\FixtureFactory; +use Magento\Mtf\ObjectManager; use Magento\Mtf\TestStep\TestStepInterface; use Magento\Sales\Test\Fixture\OrderInjectable; @@ -78,31 +79,32 @@ class PlaceOrderStep implements TestStepInterface /** * @param CheckoutOnepage $checkoutOnepage * @param AssertGrandTotalOrderReview $assertGrandTotalOrderReview - * @param AssertOrderSuccessPlacedMessage $assertOrderSuccessPlacedMessage * @param CheckoutOnepageSuccess $checkoutOnepageSuccess * @param FixtureFactory $fixtureFactory * @param array $products * @param array $prices * @param OrderInjectable|null $order + * @param AssertOrderSuccessPlacedMessage $assertOrderSuccessPlacedMessage */ public function __construct( CheckoutOnepage $checkoutOnepage, AssertGrandTotalOrderReview $assertGrandTotalOrderReview, - AssertOrderSuccessPlacedMessage $assertOrderSuccessPlacedMessage, CheckoutOnepageSuccess $checkoutOnepageSuccess, FixtureFactory $fixtureFactory, array $products = [], array $prices = [], - OrderInjectable $order = null + OrderInjectable $order = null, + AssertOrderSuccessPlacedMessage $assertOrderSuccessPlacedMessage = null ) { $this->checkoutOnepage = $checkoutOnepage; $this->assertGrandTotalOrderReview = $assertGrandTotalOrderReview; - $this->assertOrderSuccessPlacedMessage = $assertOrderSuccessPlacedMessage; $this->checkoutOnepageSuccess = $checkoutOnepageSuccess; $this->fixtureFactory = $fixtureFactory; $this->products = $products; $this->prices = $prices; $this->order = $order; + $this->assertOrderSuccessPlacedMessage = $assertOrderSuccessPlacedMessage + ?: ObjectManager::getInstance()->create(AssertOrderSuccessPlacedMessage::class); } /**