Skip to content

Commit 846fd11

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-59227' into troll_bugfix
2 parents 440c1ff + afed43b commit 846fd11

File tree

5 files changed

+211
-8
lines changed

5 files changed

+211
-8
lines changed

app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ define(
179179
newShippingAddress;
180180

181181
this.source.set('params.invalid', false);
182-
this.source.trigger('shippingAddress.data.validate');
182+
this.triggerShippingDataValidateEvent();
183183

184184
if (!this.source.get('params.invalid')) {
185185
addressData = this.source.get('shippingAddress');
@@ -254,12 +254,7 @@ define(
254254

255255
if (this.isFormInline) {
256256
this.source.set('params.invalid', false);
257-
this.source.trigger('shippingAddress.data.validate');
258-
259-
if (this.source.get('shippingAddress.custom_attributes')) {
260-
this.source.trigger('shippingAddress.custom_attributes.data.validate');
261-
}
262-
257+
this.triggerShippingDataValidateEvent();
263258
if (emailValidationResult &&
264259
this.source.get('params.invalid') ||
265260
!quote.shippingMethod().method_code ||
@@ -304,6 +299,18 @@ define(
304299
}
305300

306301
return true;
302+
},
303+
304+
/**
305+
* Trigger Shipping data Validate Event.
306+
*
307+
* @return {void}
308+
*/
309+
triggerShippingDataValidateEvent: function () {
310+
this.source.trigger('shippingAddress.data.validate');
311+
if (this.source.get('shippingAddress.custom_attributes')) {
312+
this.source.trigger('shippingAddress.custom_attributes.data.validate');
313+
}
307314
}
308315
});
309316
}

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

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,57 @@
66

77
namespace Magento\Checkout\Test\Block\Onepage;
88

9+
use Magento\Checkout\Test\Block\Onepage\Shipping\AddressModal;
910
use Magento\Mtf\Block\Form;
11+
use Magento\Mtf\Client\Locator;
1012

1113
/**
1214
* Checkout shipping address block.
1315
*/
1416
class Shipping extends Form
1517
{
16-
//
18+
/**
19+
* CSS Selector for "New Address" button
20+
*
21+
* @var string
22+
*/
23+
private $newAddressButton = '[data-bind*="isNewAddressAdded"]';
24+
25+
/**
26+
* Wait element.
27+
*
28+
* @var string
29+
*/
30+
private $waitElement = '.loading-mask';
31+
32+
/**
33+
* SCC Selector for Address Modal block.
34+
*
35+
* @var string
36+
*/
37+
private $addressModalBlock = '//*[@id="opc-new-shipping-address"]/../..';
38+
39+
/**
40+
* Click on "New Address" button.
41+
*
42+
* @return void
43+
*/
44+
public function clickOnNewAddressButton()
45+
{
46+
$this->waitForElementNotVisible($this->waitElement);
47+
$this->_rootElement->find($this->newAddressButton)->click();
48+
}
49+
50+
/**
51+
* Get Address Modal Block.
52+
*
53+
* @return AddressModal
54+
*/
55+
public function getAddressModalBlock()
56+
{
57+
return $this->blockFactory->create(
58+
AddressModal::class,
59+
['element' => $this->browser->find($this->addressModalBlock, Locator::SELECTOR_XPATH)]
60+
);
61+
}
1762
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Checkout\Test\Block\Onepage\Shipping;
8+
9+
use Magento\Mtf\Block\Form;
10+
11+
/**
12+
* Checkout shipping address modal block.
13+
*/
14+
class AddressModal extends Form
15+
{
16+
/**
17+
* CSS Selector for Save button.
18+
*
19+
* @var string
20+
*/
21+
private $saveButton = '.action-save-address';
22+
23+
/**
24+
* Selector for field's error message.
25+
*
26+
* @var string
27+
*/
28+
private $errorMessage = '.field-error';
29+
30+
/**
31+
* Selector for error fields.
32+
*
33+
* @var string
34+
*/
35+
private $errorField = '._error';
36+
37+
/**
38+
* Selector for field label that have error message.
39+
*
40+
* @var string
41+
*/
42+
private $fieldLabel = '.label';
43+
44+
/**
45+
* Click on 'Save Address' button.
46+
*
47+
* @return void
48+
*/
49+
public function save()
50+
{
51+
$this->_rootElement->find($this->saveButton)->click();
52+
}
53+
54+
/**
55+
* Get Error messages for attributes.
56+
*
57+
* @return array
58+
*/
59+
public function getErrorMessages()
60+
{
61+
$result = [];
62+
foreach ($this->_rootElement->getElements($this->errorField) as $item) {
63+
$result[$item->find($this->fieldLabel)->getText()] = $item->find($this->errorMessage)->getText();
64+
}
65+
66+
return $result;
67+
}
68+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" ?>
2+
<!--
3+
/**
4+
* Copyright © 2016 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<mapping strict="0">
9+
<fields>
10+
<firstname />
11+
<lastname />
12+
<company />
13+
<street>
14+
<selector>input[name="street[0]"]</selector>
15+
</street>
16+
<city />
17+
<region_id>
18+
<input>select</input>
19+
</region_id>
20+
<country_id>
21+
<input>select</input>
22+
</country_id>
23+
<telephone />
24+
<postcode />
25+
</fields>
26+
</mapping>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Checkout\Test\TestStep;
8+
9+
use Magento\Checkout\Test\Page\CheckoutOnepage;
10+
use Magento\Customer\Test\Fixture\Address;
11+
use Magento\Mtf\TestStep\TestStepInterface;
12+
13+
/**
14+
* Create customer custom attribute step.
15+
*/
16+
class AddNewShippingAddressStep implements TestStepInterface
17+
{
18+
/**
19+
* Checkout One page.
20+
*
21+
* @var CheckoutOnepage
22+
*/
23+
private $checkoutOnepage;
24+
25+
/**
26+
* Shipping Address fixture.
27+
*
28+
* @var Address
29+
*/
30+
private $address;
31+
32+
/**
33+
* @constructor
34+
* @param CheckoutOnepage $checkoutOnepage
35+
* @param Address|null $address [optional]
36+
*/
37+
public function __construct(CheckoutOnepage $checkoutOnepage, Address $address = null)
38+
{
39+
$this->checkoutOnepage = $checkoutOnepage;
40+
$this->address = $address;
41+
}
42+
43+
/**
44+
* Create customer account.
45+
*
46+
* @return void
47+
*/
48+
public function run()
49+
{
50+
$shippingBlock = $this->checkoutOnepage->getShippingBlock();
51+
$shippingBlock->clickOnNewAddressButton();
52+
if ($this->address) {
53+
$shippingBlock->getAddressModalBlock()->fill($this->address);
54+
}
55+
$shippingBlock->getAddressModalBlock()->save();
56+
}
57+
}

0 commit comments

Comments
 (0)