Skip to content

Commit 1be0caa

Browse files
author
Elena Marchenko
committed
MAGETWO-46343: Create functional tests for using vault on storefront
1 parent ef783db commit 1be0caa

File tree

9 files changed

+272
-4
lines changed

9 files changed

+272
-4
lines changed

app/code/Magento/Vault/Model/Ui/TokensConfigProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function getConfig()
123123

124124
foreach ($this->paymentTokenRepository->getList($searchCriteria)->getItems() as $index => $token) {
125125
$component = $componentProvider->getComponentForToken($token);
126-
$vaultPayments[VaultPaymentInterface::CODE . $index] = [
126+
$vaultPayments[VaultPaymentInterface::CODE . '_item_' . $index] = [
127127
'config' => $component->getConfig(),
128128
'component' => $component->getName()
129129
];

dev/tests/functional/tests/app/Magento/Braintree/Test/Repository/ConfigData.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,5 +190,21 @@
190190
<item name="value" xsi:type="number">0</item>
191191
</field>
192192
</dataset>
193+
<dataset name="braintreetwo_use_vault">
194+
<field name="payment/vault/vault_payment" xsi:type="array">
195+
<item name="scope" xsi:type="string">payment</item>
196+
<item name="scope_id" xsi:type="number">1</item>
197+
<item name="label" xsi:type="string">Braintree</item>
198+
<item name="value" xsi:type="string">braintreetwo</item>
199+
</field>
200+
</dataset>
201+
<dataset name="braintreetwo_use_vault_rollback">
202+
<field name="payment/vault/vault_payment" xsi:type="array">
203+
<item name="scope" xsi:type="string">payment</item>
204+
<item name="scope_id" xsi:type="number">1</item>
205+
<item name="label" xsi:type="string">Select vault provider</item>
206+
<item name="value" xsi:type="string">null</item>
207+
</field>
208+
</dataset>
193209
</repository>
194210
</config>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2015 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/etc/variations.xsd">
9+
<testCase name="Magento\Vault\Test\TestCase\UseVaultOnCheckoutTest" summary="Use saved for Braintree credit card on checkout.">
10+
<variation name="UseVaultOnCheckoutBraintreeTestVariation1" summary="Use saved for Braintree credit card on checkout" ticketId="MAGETWO-46530">
11+
<data name="description" xsi:type="string">Use saved for Braintree credit card on checkout</data>
12+
<data name="products" xsi:type="string">catalogProductSimple::product_10_dollar</data>
13+
<data name="customer/dataset" xsi:type="string">default</data>
14+
<data name="taxRule" xsi:type="string">us_ca_ny_rule</data>
15+
<data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data>
16+
<data name="checkoutMethod" xsi:type="string">login</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">braintreetwo</data>
20+
<data name="creditCardClass" xsi:type="string">credit_card_braintree</data>
21+
<data name="creditCard/dataset" xsi:type="string">visa_braintree</data>
22+
<data name="creditCardSave" xsi:type="string">Yes</data>
23+
<data name="configData" xsi:type="string">braintreetwo, braintreetwo_use_vault</data>
24+
<data name="status" xsi:type="string">Processing</data>
25+
<data name="tag" xsi:type="string">test_type:3rd_party_test</data>
26+
<constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" />
27+
</variation>
28+
</testCase>
29+
</config>

dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Payment extends Block
2020
*
2121
* @var string
2222
*/
23-
protected $paymentMethodInput = '#%s';
23+
protected $paymentMethodInput = '[id^="%s"]';
2424

2525
/**
2626
* Labels for payment methods.
@@ -34,7 +34,7 @@ class Payment extends Block
3434
*
3535
* @var string
3636
*/
37-
protected $paymentMethodLabel = '[for="%s"]';
37+
protected $paymentMethodLabel = '[for^="%s"]';
3838

3939
/**
4040
* Continue checkout button.
@@ -71,7 +71,6 @@ class Payment extends Block
7171
*/
7272
protected $activePaymentMethodSelector = '.payment-method._active';
7373

74-
7574
/**
7675
* Select payment method.
7776
*

dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment/Method.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\Checkout\Test\Block\Onepage\Payment;
88

99
use Magento\Mtf\Block\Block;
10+
use Magento\Mtf\Client\Locator;
1011

1112
/**
1213
* Checkout payment method block.
@@ -34,6 +35,13 @@ class Method extends Block
3435
*/
3536
protected $billingAddressSelector = '.payment-method-billing-address';
3637

38+
/**
39+
* Save credit card check box.
40+
*
41+
* @var string
42+
*/
43+
protected $vaultCheckbox = '#%s_vault_enabler';
44+
3745
/**
3846
* Place order.
3947
*
@@ -59,4 +67,17 @@ public function getBillingBlock()
5967
['element' => $element]
6068
);
6169
}
70+
71+
/**
72+
* Save credit card.
73+
*
74+
* @param string $paymentMethod
75+
* @param string $creditCardSave
76+
* @return void
77+
*/
78+
public function saveCreditCard($paymentMethod, $creditCardSave)
79+
{
80+
$saveCard = sprintf($this->vaultCheckbox, $paymentMethod);
81+
$this->_rootElement->find($saveCard, Locator::SELECTOR_CSS, 'checkbox')->setValue($creditCardSave);
82+
}
6283
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Vault\Test\TestCase;
8+
9+
use Magento\Mtf\TestCase\Scenario;
10+
11+
/**
12+
* Preconditions:
13+
* 1. Configure shipping method.
14+
* 2. Configure payment method.
15+
* 3. Create products.
16+
* 4. Create and setup customer.
17+
* 5. Configure taxes.
18+
*
19+
* Steps:
20+
* 1. Log in Storefront.
21+
* 2. Add products to the cart.
22+
* 3. Click the 'Proceed to Checkout' button.
23+
* 4. Select shipping method.
24+
* 5. Select payment method (use reward points and store credit if available).
25+
* 6. Enter credit card data and select *Save credit card* checkbox.
26+
* 7. Click Place Order button.
27+
* 8. Add products to the cart.
28+
* 9. Click the 'Proceed to Checkout' button.
29+
* 10. Select shipping method.
30+
* 11. Select saved credit card as a payment.
31+
* 12. Click Place Order button.
32+
* 13. Perform assertions.
33+
*
34+
* @group One_Page_Checkout_(CS)
35+
* @ZephyrId MAGETWO-46530
36+
*/
37+
class UseVaultOnCheckoutTest extends Scenario
38+
{
39+
/* tags */
40+
const MVP = 'yes';
41+
const DOMAIN = 'CS';
42+
const TEST_TYPE = '3rd_party_test';
43+
/* end tags */
44+
45+
/**
46+
* Runs one page checkout test.
47+
*
48+
* @return void
49+
*/
50+
public function test()
51+
{
52+
$this->executeScenario();
53+
}
54+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Vault\Test\TestStep;
8+
9+
use Magento\Checkout\Test\Page\CheckoutOnepage;
10+
use Magento\Mtf\TestStep\TestStepInterface;
11+
12+
/**
13+
* Save credit card during checkout.
14+
*/
15+
class SaveCreditCardStep implements TestStepInterface
16+
{
17+
/**
18+
* Onepage checkout page.
19+
*
20+
* @var CheckoutOnepage
21+
*/
22+
protected $checkoutOnepage;
23+
24+
/**
25+
* Payment information.
26+
*
27+
* @var string
28+
*/
29+
protected $payment;
30+
31+
/**
32+
* Determines whether credit card should be saved.
33+
*
34+
* @var string
35+
*/
36+
protected $creditCardSave;
37+
38+
/**
39+
* @constructor
40+
* @param CheckoutOnepage $checkoutOnepage
41+
* @param array $payment
42+
* @param string $creditCardSave;
43+
*/
44+
public function __construct(
45+
CheckoutOnepage $checkoutOnepage,
46+
array $payment,
47+
$creditCardSave = 'No'
48+
) {
49+
$this->checkoutOnepage = $checkoutOnepage;
50+
$this->payment = $payment;
51+
$this->creditCardSave = $creditCardSave;
52+
}
53+
54+
/**
55+
* Run step that saves credit card.
56+
*
57+
* @return void
58+
*/
59+
public function run()
60+
{
61+
$this->checkoutOnepage->getPaymentBlock()->getSelectedPaymentMethodBlock()->saveCreditCard(
62+
$this->payment['method'],
63+
$this->creditCardSave
64+
);
65+
}
66+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Vault\Test\TestStep;
8+
9+
use Magento\Checkout\Test\Page\CheckoutOnepage;
10+
use Magento\Mtf\TestStep\TestStepInterface;
11+
12+
/**
13+
* Select saved credit card.
14+
*/
15+
class UseSavedCreditCardStep implements TestStepInterface
16+
{
17+
/**
18+
* Onepage checkout page.
19+
*
20+
* @var CheckoutOnepage
21+
*/
22+
protected $checkoutOnepage;
23+
24+
/**
25+
* Payment information.
26+
*
27+
* @var array
28+
*/
29+
protected $payment;
30+
31+
/**
32+
* @constructor
33+
* @param CheckoutOnepage $checkoutOnepage
34+
* @param array $payment
35+
*/
36+
public function __construct (CheckoutOnepage $checkoutOnepage, array $payment)
37+
{
38+
$this->checkoutOnepage = $checkoutOnepage;
39+
$this->payment = $payment;
40+
}
41+
42+
/**
43+
* Run step that selects saved credit card.
44+
*
45+
* @return void
46+
*/
47+
public function run()
48+
{
49+
$this->payment['method'] .= '_vault_item_';
50+
$this->checkoutOnepage->getPaymentBlock()->selectPaymentMethod($this->payment);
51+
}
52+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © 2015 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/TestCase/etc/testcase.xsd">
9+
<scenario name="UseVaultOnCheckoutTest" firstStep="setupConfiguration">
10+
<step name="setupConfiguration" module="Magento_Config" next="createProducts"/>
11+
<step name="createProducts" module="Magento_Catalog" next="createTaxRule"/>
12+
<step name="createTaxRule" module="Magento_Tax" next="addProductsToTheCart"/>
13+
<step name="addProductsToTheCart" module="Magento_Checkout" next="estimateShippingAndTax"/>
14+
<step name="estimateShippingAndTax" module="Magento_Checkout" next="clickProceedToCheckout"/>
15+
<step name="clickProceedToCheckout" module="Magento_Checkout" next="createCustomer"/>
16+
<step name="createCustomer" module="Magento_Customer" next="selectCheckoutMethod"/>
17+
<step name="selectCheckoutMethod" module="Magento_Checkout" next="fillShippingAddress"/>
18+
<step name="fillShippingAddress" module="Magento_Checkout" next="fillShippingMethod"/>
19+
<step name="fillShippingMethod" module="Magento_Checkout" next="selectPaymentMethod"/>
20+
<step name="selectPaymentMethod" module="Magento_Checkout" next="saveCreditCard"/>
21+
<step name="saveCreditCard" module="Magento_Vault" next="fillBillingInformation"/>
22+
<step name="fillBillingInformation" module="Magento_Checkout" next="placeOrder"/>
23+
<step name="placeOrder" module="Magento_Checkout" next="addProductsToTheCartVault"/>
24+
<step name="addProductsToTheCartVault" alias="addProductsToTheCart" module="Magento_Checkout" next="estimateShippingAndTaxVault"/>
25+
<step name="estimateShippingAndTaxVault" alias="estimateShippingAndTax" module="Magento_Checkout" next="clickProceedToCheckoutVault"/>
26+
<step name="clickProceedToCheckoutVault" alias="clickProceedToCheckout" module="Magento_Checkout" next="fillShippingMethodVault"/>
27+
<step name="fillShippingMethodVault" alias="fillShippingMethod" module="Magento_Checkout" next="useSavedCreditCard"/>
28+
<step name="useSavedCreditCard" module="Magento_Vault" next="placeOrderVault"/>
29+
<step name="placeOrderVault" alias="placeOrder" module="Magento_Checkout"/>
30+
</scenario>
31+
</config>

0 commit comments

Comments
 (0)