Skip to content

Commit cc90e72

Browse files
MTO-78: [Variation] Customer is redirected to checkout on login if guest is disabled
- Functional test implemented.
1 parent b56df96 commit cc90e72

File tree

7 files changed

+155
-4
lines changed

7 files changed

+155
-4
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © 2016 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd">
9+
<repository class="Magento\Config\Test\Repository\ConfigData">
10+
<dataset name="disable_guest_checkout">
11+
<field name="checkout/options/guest_checkout" xsi:type="array">
12+
<item name="scope" xsi:type="string">checkout</item>
13+
<item name="scope_id" xsi:type="number">1</item>
14+
<item name="label" xsi:type="string">No</item>
15+
<item name="value" xsi:type="string">0</item>
16+
</field>
17+
</dataset>
18+
<dataset name="disable_guest_checkout_rollback">
19+
<field name="checkout/options/guest_checkout" xsi:type="array">
20+
<item name="scope" xsi:type="string">checkout</item>
21+
<item name="scope_id" xsi:type="number">1</item>
22+
<item name="label" xsi:type="string">Yes</item>
23+
<item name="value" xsi:type="string">1</item>
24+
</field>
25+
</dataset>
26+
<dataset name="disable_customer_redirect_after_logging">
27+
<field name="customer/startup/redirect_dashboard" xsi:type="array">
28+
<item name="scope" xsi:type="string">customer</item>
29+
<item name="scope_id" xsi:type="number">1</item>
30+
<item name="label" xsi:type="string">No</item>
31+
<item name="value" xsi:type="string">0</item>
32+
</field>
33+
</dataset>
34+
<dataset name="disable_customer_redirect_after_logging_rollback">
35+
<field name="customer/startup/redirect_dashboard" xsi:type="array">
36+
<item name="scope" xsi:type="string">customer</item>
37+
<item name="scope_id" xsi:type="number">1</item>
38+
<item name="label" xsi:type="string">Yes</item>
39+
<item name="value" xsi:type="string">1</item>
40+
</field>
41+
</dataset>
42+
</repository>
43+
</config>

dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* 14. Perform assertions.
3434
*
3535
* @group One_Page_Checkout
36-
* @ZephyrId MAGETWO-27485, MAGETWO-12412, MAGETWO-12429
36+
* @ZephyrId MAGETWO-27485, MAGETWO-12412, MAGETWO-12429, MAGETWO-49917, MAGETWO-27485
3737
* @ZephyrId MAGETWO-12444, MAGETWO-12848, MAGETWO-12849, MAGETWO-12850
3838
*/
3939
class OnePageCheckoutTest extends Scenario

dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutTest.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,34 @@
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd">
99
<testCase name="Magento\Checkout\Test\TestCase\OnePageCheckoutTest" summary="OnePageCheckout within Offline Payment Methods" ticketId="MAGETWO-27485">
10+
<variation name="OnePageCheckoutUsingLoginPopup" summary="Customer is redirected to checkout on login if guest is disabled, flow for existed Customer" ticketId="MAGETWO-49916">
11+
<data name="products/0" xsi:type="string">catalogProductSimple::default</data>
12+
<data name="customer/dataset" xsi:type="string">johndoe_with_addresses</data>
13+
<data name="checkoutMethod" xsi:type="string">login</data>
14+
<data name="prices" xsi:type="array">
15+
<item name="grandTotal" xsi:type="string">565.00</item>
16+
</data>
17+
<data name="shipping/shipping_service" xsi:type="string">Flat Rate</data>
18+
<data name="shipping/shipping_method" xsi:type="string">Fixed</data>
19+
<data name="payment/method" xsi:type="string">checkmo</data>
20+
<data name="configData" xsi:type="string">checkmo, disable_guest_checkout, disable_customer_redirect_after_logging</data>
21+
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
22+
</variation>
23+
<variation name="OnePageCheckoutUsingRegisterLink" summary="Customer is redirected to checkout on login if guest is disabled, flow with registration new Customer" ticketId="MAGETWO-49917">
24+
<data name="issue" xsi:type="string">MAGETWO-59816: Redirect works improperly in a browser incognito mode</data>
25+
<data name="products/0" xsi:type="string">catalogProductSimple::default</data>
26+
<data name="customer/dataset" xsi:type="string">register_customer</data>
27+
<data name="checkoutMethod" xsi:type="string">register_before_checkout</data>
28+
<data name="prices" xsi:type="array">
29+
<item name="grandTotal" xsi:type="string">565.00</item>
30+
</data>
31+
<data name="shipping/shipping_service" xsi:type="string">Flat Rate</data>
32+
<data name="shipping/shipping_method" xsi:type="string">Fixed</data>
33+
<data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data>
34+
<data name="payment/method" xsi:type="string">checkmo</data>
35+
<data name="configData" xsi:type="string">checkmo, disable_guest_checkout, disable_customer_redirect_after_logging, enable_https_frontend_only</data>
36+
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
37+
</variation>
1038
<variation name="OnePageCheckoutTestVariation1" summary="Checkout as UK guest with virtual product and downloadable product using coupon for not logged in customers">
1139
<data name="products/0" xsi:type="string">catalogProductVirtual::default</data>
1240
<data name="products/1" xsi:type="string">downloadableProduct::with_two_separately_links</data>

dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/SelectCheckoutMethodStep.php

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
use Magento\Mtf\TestStep\TestStepInterface;
1010
use Magento\Customer\Test\Fixture\Customer;
11+
use Magento\Customer\Test\Page\CustomerAccountCreate;
1112
use Magento\Checkout\Test\Page\CheckoutOnepage;
1213
use Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep;
1314

@@ -51,22 +52,32 @@ class SelectCheckoutMethodStep implements TestStepInterface
5152
*/
5253
private $clickProceedToCheckoutStep;
5354

55+
/**
56+
* Customer account create page instance.
57+
*
58+
* @var CustomerAccountCreate
59+
*/
60+
private $customerAccountCreatePage;
61+
5462
/**
5563
* @constructor
5664
* @param CheckoutOnepage $checkoutOnepage
65+
* @param CustomerAccountCreate $customerAccountCreatePage
5766
* @param Customer $customer
5867
* @param LogoutCustomerOnFrontendStep $logoutCustomerOnFrontend
5968
* @param ClickProceedToCheckoutStep $clickProceedToCheckoutStep
6069
* @param string $checkoutMethod
6170
*/
6271
public function __construct(
6372
CheckoutOnepage $checkoutOnepage,
73+
CustomerAccountCreate $customerAccountCreatePage,
6474
Customer $customer,
6575
LogoutCustomerOnFrontendStep $logoutCustomerOnFrontend,
6676
ClickProceedToCheckoutStep $clickProceedToCheckoutStep,
6777
$checkoutMethod
6878
) {
6979
$this->checkoutOnepage = $checkoutOnepage;
80+
$this->customerAccountCreatePage = $customerAccountCreatePage;
7081
$this->customer = $customer;
7182
$this->logoutCustomerOnFrontend = $logoutCustomerOnFrontend;
7283
$this->clickProceedToCheckoutStep = $clickProceedToCheckoutStep;
@@ -80,7 +91,18 @@ public function __construct(
8091
*/
8192
public function run()
8293
{
83-
if ($this->checkoutMethod === 'login') {
94+
$this->processLogin();
95+
$this->processRegister();
96+
}
97+
98+
/**
99+
* Process login action.
100+
*
101+
* @return void
102+
*/
103+
private function processLogin()
104+
{
105+
if ($this->checkoutMethod == 'login') {
84106
if ($this->checkoutOnepage->getAuthenticationPopupBlock()->isVisible()) {
85107
$this->checkoutOnepage->getAuthenticationPopupBlock()->loginCustomer($this->customer);
86108
$this->clickProceedToCheckoutStep->run();
@@ -90,14 +112,27 @@ public function run()
90112
}
91113
}
92114

115+
/**
116+
* Process customer register action.
117+
*
118+
* @return void
119+
*/
120+
private function processRegister()
121+
{
122+
if ($this->checkoutMethod === 'register_before_checkout') {
123+
$this->checkoutOnepage->getAuthenticationPopupBlock()->createAccount();
124+
$this->customerAccountCreatePage->getRegisterForm()->registerCustomer($this->customer);
125+
}
126+
}
127+
93128
/**
94129
* Logout customer on fronted.
95130
*
96131
* @return void
97132
*/
98133
public function cleanup()
99134
{
100-
if ($this->checkoutMethod === 'login') {
135+
if ($this->checkoutMethod === 'login' || $this->checkoutMethod === 'register_before_checkout') {
101136
$this->logoutCustomerOnFrontend->run();
102137
}
103138
}

dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/AuthenticationPopup.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,23 @@ class AuthenticationPopup extends Form
2727
*/
2828
private $loadingMask = '.loading-mask';
2929

30+
/**
31+
* 'Create an Account' button.
32+
*
33+
* @var string
34+
*/
35+
protected $createAccountButton = '.action.action-register.primary';
36+
37+
/**
38+
* Click 'Create an Account' button.
39+
*
40+
* @return void
41+
*/
42+
public function createAccount()
43+
{
44+
$this->_rootElement->find($this->createAccountButton)->click();
45+
}
46+
3047
/**
3148
* Login customer on authentication popup.
3249
*

dev/tests/functional/tests/app/Magento/Customer/Test/TestStep/CreateCustomerStep.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ public function __construct(LogoutCustomerOnFrontendStep $logout, Customer $cust
4646
{
4747
$this->logoutCustomerOnFrontend = $logout;
4848
$this->customer = $customer;
49-
if ($checkoutMethod === 'register' || $checkoutMethod === 'guest') {
49+
if ($checkoutMethod === 'register'
50+
|| $checkoutMethod === 'guest'
51+
|| $checkoutMethod === 'register_before_checkout') {
5052
$this->persistCustomer = false;
5153
}
5254
}

dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/CreateSalesRuleEntityTest.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,5 +399,31 @@
399399
<constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleSuccessSaveMessage" />
400400
<constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleForm" />
401401
</variation>
402+
<variation name="CreateSalesRuleEntityTestVariation16" summary="Variation to check free shipping">
403+
<data name="salesRule/data/name" xsi:type="string">Cart Price Rule1 %isolation%</data>
404+
<data name="salesRule/data/description" xsi:type="string">Cart Price Rule Description %isolation%</data>
405+
<data name="salesRule/data/is_active" xsi:type="string">Yes</data>
406+
<data name="salesRule/data/website_ids/0" xsi:type="string">Main Website</data>
407+
<data name="salesRule/data/customer_group_ids/0" xsi:type="string">NOT LOGGED IN</data>
408+
<data name="salesRule/data/coupon_type" xsi:type="string">No Coupon</data>
409+
<data name="salesRule/data/simple_action" xsi:type="string">Percent of product price discount</data>
410+
<data name="salesRule/data/conditions_serialized" xsi:type="string">[Subtotal|greater than|0]</data>
411+
<data name="salesRule/data/discount_amount" xsi:type="string">50</data>
412+
<data name="salesRule/data/apply_to_shipping" xsi:type="string">No</data>
413+
<data name="salesRule/data/simple_free_shipping" xsi:type="string">For matching items only</data>
414+
<data name="salesRule/data/store_labels/0" xsi:type="string">Sales Cart Rule labels</data>
415+
<data name="cartPrice/sub_total" xsi:type="string">100.00</data>
416+
<data name="cartPrice/grand_total" xsi:type="string">50.00</data>
417+
<data name="cartPrice/discount" xsi:type="string">50.00</data>
418+
<data name="address/data/country_id" xsi:type="string">United States</data>
419+
<data name="address/data/region_id" xsi:type="string">California</data>
420+
<data name="address/data/postcode" xsi:type="string">95814</data>
421+
<data name="shipping/shipping_service" xsi:type="string">Flat Rate</data>
422+
<data name="productForSalesRule1/dataset" xsi:type="string">simple_for_salesrule_1</data>
423+
<data name="productQuantity/productForSalesRule1" xsi:type="string">1</data>
424+
<constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleSuccessSaveMessage" />
425+
<constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleConditionIsApplied" />
426+
<constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleFreeShippingIsApplied" />
427+
</variation>
402428
</testCase>
403429
</config>

0 commit comments

Comments
 (0)