Skip to content

Commit a77434e

Browse files
committed
MAGETWO-65656: [Backport] - When logged in customer edits a new shipping address during checkout they are unable to place the order - for 2.1
- MAGETWO-70727: [GitHub] Shipping method randomly dissapear when page refreshed for 2.1 #7497
1 parent 7501514 commit a77434e

File tree

2 files changed

+82
-7
lines changed

2 files changed

+82
-7
lines changed

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

+81-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88

99
use Magento\Checkout\Test\Page\CheckoutOnepage;
1010
use Magento\Customer\Test\Fixture\Address;
11+
use Magento\Mtf\Fixture\FixtureFactory;
1112
use Magento\Mtf\TestStep\TestStepInterface;
13+
use Magento\Customer\Test\Fixture\Customer;
14+
use Magento\Mtf\ObjectManager;
1215

1316
/**
1417
* Fill shipping address step.
@@ -20,37 +23,109 @@ class FillShippingAddressStep implements TestStepInterface
2023
*
2124
* @var CheckoutOnepage
2225
*/
23-
protected $checkoutOnepage;
26+
private $checkoutOnepage;
2427

2528
/**
2629
* Address fixture.
2730
*
2831
* @var Address
2932
*/
30-
protected $shippingAddress;
33+
private $shippingAddress;
34+
35+
/**
36+
* Customer fixture.
37+
*
38+
* @var Customer
39+
*/
40+
private $customer;
41+
42+
/**
43+
* Customer shipping address data for select.
44+
*
45+
* @var array
46+
*/
47+
private $shippingAddressCustomer;
48+
49+
/**
50+
* Object manager instance.
51+
*
52+
* @var ObjectManager
53+
*/
54+
private $objectManager;
55+
56+
/**
57+
* Fixture factory.
58+
*
59+
* @var FixtureFactory
60+
*/
61+
private $fixtureFactory;
3162

3263
/**
3364
* @constructor
3465
* @param CheckoutOnepage $checkoutOnepage
35-
* @param Address $shippingAddress
66+
* @param Customer $customer
67+
* @param ObjectManager $objectManager
68+
* @param FixtureFactory $fixtureFactory
69+
* @param Address|null $shippingAddress
70+
* @param array|null $shippingAddressCustomer
3671
*/
3772
public function __construct(
3873
CheckoutOnepage $checkoutOnepage,
39-
Address $shippingAddress = null
74+
Customer $customer,
75+
ObjectManager $objectManager,
76+
FixtureFactory $fixtureFactory,
77+
Address $shippingAddress = null,
78+
$shippingAddressCustomer = null
4079
) {
4180
$this->checkoutOnepage = $checkoutOnepage;
81+
$this->customer = $customer;
82+
$this->objectManager = $objectManager;
83+
$this->fixtureFactory = $fixtureFactory;
4284
$this->shippingAddress = $shippingAddress;
85+
$this->shippingAddressCustomer = $shippingAddressCustomer;
4386
}
4487

4588
/**
4689
* Fill shipping address.
4790
*
48-
* @return void
91+
* @return array
4992
*/
5093
public function run()
5194
{
95+
$shippingAddress = null;
5296
if ($this->shippingAddress) {
53-
$this->checkoutOnepage->getShippingBlock()->fill($this->shippingAddress);
97+
$shippingBlock = $this->checkoutOnepage->getShippingBlock();
98+
if ($shippingBlock->isPopupNewAddressButtonVisible()) {
99+
$shippingBlock->clickPopupNewAddressButton();
100+
$this->checkoutOnepage->getShippingAddressPopupBlock()
101+
->fill($this->shippingAddress)
102+
->clickSaveAddressButton();
103+
} else {
104+
$shippingBlock->fill($this->shippingAddress);
105+
}
106+
$shippingAddress = $this->shippingAddress;
107+
}
108+
if (isset($this->shippingAddressCustomer['new'])) {
109+
$shippingAddress = $this->fixtureFactory->create(
110+
'address',
111+
['dataset' => $this->shippingAddressCustomer['new']]
112+
);
113+
$this->checkoutOnepage->getShippingBlock()->clickPopupNewAddressButton();
114+
$this->checkoutOnepage->getShippingAddressPopupBlock()->fill($shippingAddress)->clickSaveAddressButton();
54115
}
116+
if (isset($this->shippingAddressCustomer['added'])) {
117+
$addressIndex = $this->shippingAddressCustomer['added'];
118+
$shippingAddress = $this->customer->getDataFieldConfig('address')['source']->getAddresses()[$addressIndex];
119+
$address = $this->objectManager->create(
120+
\Magento\Customer\Test\Block\Address\Renderer::class,
121+
['address' => $shippingAddress, 'type' => 'html_without_company']
122+
)->render();
123+
$shippingBlock = $this->checkoutOnepage->getShippingBlock();
124+
$shippingBlock->selectAddress($address);
125+
}
126+
127+
return [
128+
'shippingAddress' => $shippingAddress,
129+
];
55130
}
56131
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function deleteAdditionalAddress(Address $address)
6262
->find($this->deleteAddressLink)->click();
6363
$element = $this->browser->find($this->confirmModal);
6464
/** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */
65-
$modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]);
65+
$modal = $this->blockFactory->create(\Magento\Ui\Test\Block\Adminhtml\Modal::class, ['element' => $element]);
6666
$modal->acceptAlert();
6767
}
6868

0 commit comments

Comments
 (0)