File tree Expand file tree Collapse file tree 5 files changed +211
-8
lines changed
app/code/Magento/Checkout/view/frontend/web/js/view
dev/tests/functional/tests/app/Magento/Checkout/Test Expand file tree Collapse file tree 5 files changed +211
-8
lines changed Original file line number Diff line number Diff line change @@ -179,7 +179,7 @@ define(
179
179
newShippingAddress ;
180
180
181
181
this . source . set ( 'params.invalid' , false ) ;
182
- this . source . trigger ( 'shippingAddress.data.validate' ) ;
182
+ this . triggerShippingDataValidateEvent ( ) ;
183
183
184
184
if ( ! this . source . get ( 'params.invalid' ) ) {
185
185
addressData = this . source . get ( 'shippingAddress' ) ;
@@ -254,12 +254,7 @@ define(
254
254
255
255
if ( this . isFormInline ) {
256
256
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 ( ) ;
263
258
if ( emailValidationResult &&
264
259
this . source . get ( 'params.invalid' ) ||
265
260
! quote . shippingMethod ( ) . method_code ||
@@ -304,6 +299,18 @@ define(
304
299
}
305
300
306
301
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
+ }
307
314
}
308
315
} ) ;
309
316
}
Original file line number Diff line number Diff line change 6
6
7
7
namespace Magento \Checkout \Test \Block \Onepage ;
8
8
9
+ use Magento \Checkout \Test \Block \Onepage \Shipping \AddressModal ;
9
10
use Magento \Mtf \Block \Form ;
11
+ use Magento \Mtf \Client \Locator ;
10
12
11
13
/**
12
14
* Checkout shipping address block.
13
15
*/
14
16
class Shipping extends Form
15
17
{
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
+ }
17
62
}
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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 >
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments