Skip to content

Commit 78d318f

Browse files
author
Dmytro Aponasenko
committed
MTA-2350: Add wait to form element before filling a value
- fixed install test
1 parent d9c224b commit 78d318f

File tree

11 files changed

+181
-171
lines changed

11 files changed

+181
-171
lines changed

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

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,55 +11,61 @@
1111
use Magento\Mtf\Client\Locator;
1212

1313
/**
14-
* Class Shipping
15-
* Cart shipping block
14+
* Cart shipping block.
1615
*/
1716
class Shipping extends Form
1817
{
1918
/**
20-
* Form wrapper selector
19+
* Form wrapper selector.
2120
*
2221
* @var string
2322
*/
2423
protected $formWrapper = '.content';
2524

2625
/**
27-
* Open shipping form selector
26+
* Open shipping form selector.
2827
*
2928
* @var string
3029
*/
3130
protected $openForm = '.title';
3231

3332
/**
34-
* Get quote selector
33+
* Get quote selector.
3534
*
3635
* @var string
3736
*/
3837
protected $getQuote = '.action.quote';
3938

4039
/**
41-
* Update total selector
40+
* Update total selector.
4241
*
4342
* @var string
4443
*/
4544
protected $updateTotalSelector = '.action.update';
4645

4746
/**
48-
* Selector to access the shipping carrier method
47+
* Selector to access the shipping carrier method.
4948
*
5049
* @var string
5150
*/
5251
protected $shippingMethod = '//span[text()="%s"]/following::*//*[contains(text(), "%s")]';
5352

5453
/**
55-
* From with shipping available shipping methods
54+
* From with shipping available shipping methods.
5655
*
5756
* @var string
5857
*/
5958
protected $shippingMethodForm = '#co-shipping-method-form';
6059

6160
/**
62-
* Open estimate shipping and tax form
61+
* Fields that are used in estimation shipping form.
62+
*
63+
* @var array
64+
*/
65+
protected $estimationFields = ['country_id', 'region_id', 'region', 'postcode'];
66+
67+
/**
68+
* Open estimate shipping and tax form.
6369
*
6470
* @return void
6571
*/
@@ -71,7 +77,7 @@ public function openEstimateShippingAndTax()
7177
}
7278

7379
/**
74-
* Click Get quote button
80+
* Click Get quote button.
7581
*
7682
* @return void
7783
*/
@@ -81,7 +87,7 @@ public function clickGetQuote()
8187
}
8288

8389
/**
84-
* Select shipping method
90+
* Select shipping method.
8591
*
8692
* @param array $shipping
8793
* @return void
@@ -97,20 +103,22 @@ public function selectShippingMethod(array $shipping)
97103
}
98104

99105
/**
100-
* Fill shipping and tax form
106+
* Fill shipping and tax form.
101107
*
102108
* @param Address $address
103109
* @return void
104110
*/
105111
public function fillEstimateShippingAndTax(Address $address)
106112
{
107113
$this->openEstimateShippingAndTax();
108-
$this->fill($address);
114+
$data = $address->getData();
115+
$mapping = $this->dataMapping(array_intersect_key($data, array_flip($this->estimationFields)));
116+
$this->_fill($mapping, $this->_rootElement);
109117
$this->clickGetQuote();
110118
}
111119

112120
/**
113-
* Determines if the specified shipping carrier/method is visible on the cart
121+
* Determines if the specified shipping carrier/method is visible on the cart.
114122
*
115123
* @param $carrier
116124
* @param $method

dev/tests/functional/tests/app/Magento/Install/Test/Block/CreateAdmin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* See COPYING.txt for license details.
66
*/
77
-->
8-
<mapping strict="0">
8+
<mapping strict="1">
99
<fields>
1010
<username>
1111
<selector>[name='adminUsername']</selector>

dev/tests/functional/tests/app/Magento/Install/Test/Block/CustomizeStore.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ class CustomizeStore extends Form
2424
protected $next = "[ng-click*='checkModuleConstraints']";
2525

2626
/**
27-
* First field selector
27+
* Module configuration section.
2828
*
2929
* @var string
3030
*/
31-
protected $firstField = '[ng-model*="language"]';
31+
protected $moduleConfiguration = '.customize-your-store-advanced';
3232

3333
/**
3434
* Click on 'Next' button.
@@ -49,7 +49,17 @@ public function clickNext()
4949
*/
5050
public function fill(FixtureInterface $fixture, SimpleElement $element = null)
5151
{
52-
$this->waitForElementVisible($this->firstField);
53-
return parent::fill($fixture, $element);
52+
$this->waitForElementVisible($this->moduleConfiguration);
53+
$data = $fixture->getData();
54+
$storeData = [];
55+
foreach ($data as $key => $value) {
56+
if (strpos($key, 'store') === 0) {
57+
$storeData[$key] = $value;
58+
}
59+
}
60+
$mapping = $this->dataMapping($storeData);
61+
$this->_fill($mapping, $element);
62+
63+
return $this;
5464
}
5565
}

dev/tests/functional/tests/app/Magento/Install/Test/Block/CustomizeStore.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
-->
88
<mapping strict="0">
99
<fields>
10-
<currency>
11-
<selector>[ng-model*='currency']</selector>
10+
<storeCurrency>
11+
<selector>#storeCurrency</selector>
1212
<input>select</input>
13-
</currency>
14-
<language>
15-
<selector>[ng-model*='language']</selector>
13+
</storeCurrency>
14+
<storeLanguage>
15+
<selector>#storeLanguage</selector>
1616
<input>select</input>
17-
</language>
17+
</storeLanguage>
1818
</fields>
1919
</mapping>

dev/tests/functional/tests/app/Magento/Install/Test/Block/Database.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
use Magento\Mtf\Block\Form;
1010
use Magento\Mtf\Client\Locator;
11+
use Magento\Mtf\Fixture\FixtureInterface;
12+
use Magento\Mtf\Client\Element\SimpleElement;
1113

1214
/**
1315
* Database form.
@@ -28,6 +30,28 @@ class Database extends Form
2830
*/
2931
protected $next = "[ng-click*='testConnection']";
3032

33+
/**
34+
* Fill database form.
35+
*
36+
* @param FixtureInterface $fixture
37+
* @param SimpleElement|null $element
38+
* @return $this
39+
*/
40+
public function fill(FixtureInterface $fixture, SimpleElement $element = null)
41+
{
42+
$data = $fixture->getData();
43+
$dbData = [];
44+
foreach ($data as $key => $value) {
45+
if (strpos($key, 'db') === 0) {
46+
$dbData[$key] = $value;
47+
}
48+
}
49+
$mapping = $this->dataMapping($dbData);
50+
$this->_fill($mapping, $element);
51+
52+
return $this;
53+
}
54+
3155
/**
3256
* Get 'Test connection successful.' message.
3357
*

dev/tests/functional/tests/app/Magento/Install/Test/Block/WebConfiguration.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
namespace Magento\Install\Test\Block;
88

99
use Magento\Mtf\Block\Form;
10+
use Magento\Mtf\Fixture\FixtureInterface;
11+
use Magento\Mtf\Client\Element\SimpleElement;
1012

1113
/**
1214
* Web configuration block.
@@ -27,6 +29,28 @@ class WebConfiguration extends Form
2729
*/
2830
protected $advancedOptions = "[ng-click*='advanced']";
2931

32+
/**
33+
* Fill web configuration form.
34+
*
35+
* @param FixtureInterface $fixture
36+
* @param SimpleElement|null $element
37+
* @return $this
38+
*/
39+
public function fill(FixtureInterface $fixture, SimpleElement $element = null)
40+
{
41+
$data = $fixture->getData();
42+
$webConfiguration = [];
43+
foreach ($data as $key => $value) {
44+
if (strpos($key, 'db') !== 0 && strpos($key, 'store') !== 0) {
45+
$webConfiguration[$key] = $value;
46+
}
47+
}
48+
$mapping = $this->dataMapping($webConfiguration);
49+
$this->_fill($mapping, $element);
50+
51+
return $this;
52+
}
53+
3054
/**
3155
* Click on 'Next' button.
3256
*

dev/tests/functional/tests/app/Magento/Install/Test/Block/WebConfiguration.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
-->
88
<mapping strict="0">
99
<fields>
10-
<web />
10+
<baseUrl>
11+
<selector>[name="base_url"]</selector>
12+
</baseUrl>
1113
<admin />
1214
<keyOwn>
1315
<selector>[value="user"]</selector>

dev/tests/functional/tests/app/Magento/Install/Test/Constraint/AssertSuccessInstall.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class AssertSuccessInstall extends AbstractConstraint
2424
protected $adminFieldsList = [
2525
['pageData' => 'username', 'fixture' => 'username'],
2626
['pageData' => 'e-mail', 'fixture' => 'email'],
27-
['pageData' => 'your_store_address', 'fixture' => 'web'],
27+
['pageData' => 'your_store_address', 'fixture' => 'baseUrl'],
2828
['pageData' => 'magento_admin_address', 'fixture' => 'admin']
2929
];
3030

@@ -57,8 +57,8 @@ public function processAssert(Install $installPage, InstallConfig $installConfig
5757
$allData[$key] = isset($value['value']) ? $value['value'] : $value;
5858
}
5959

60-
$allData['web'] = (isset($allData['https']) ? $allData['https'] : $allData['web']);
61-
$allData['admin'] = $allData['web'] . $allData['admin'] . '/';
60+
$allData['baseUrl'] = (isset($allData['https']) ? $allData['https'] : $allData['baseUrl']);
61+
$allData['admin'] = $allData['baseUrl'] . $allData['admin'] . '/';
6262

6363
foreach ($this->adminFieldsList as $field) {
6464
\PHPUnit_Framework_Assert::assertEquals(

dev/tests/functional/tests/app/Magento/Install/Test/Fixture/Install.xml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/fixture.xsd">
9-
<fixture name="install" module="Magento_Install" type="virtual" entity_type="install" repository_class="Magento\Install\Test\Repository\Install" handler_interface="Magento\Install\Test\Handler\Install\InstallInterface" class="Magento\Install\Test\Fixture\Install">
10-
<field name="dbHost"/>
11-
<field name="dbUser"/>
12-
<field name="dbPassword"/>
13-
<field name="dbName"/>
14-
<field name="web"/>
15-
<field name="admin"/>
16-
<field name="adminUsername"/>
17-
<field name="adminEmail"/>
18-
<field name="adminPassword"/>
19-
<field name="adminConfirm"/>
20-
<field name="apacheRewrites"/>
21-
<field name="dbTablePrefix"/>
22-
<field name="keyOwn"/>
23-
<field name="httpsAdmin"/>
24-
<field name="https"/>
25-
<field name="httpsFront"/>
26-
<field name="keyValue"/>
27-
<field name="language"/>
28-
<field name="currency"/>
29-
</fixture>
9+
<fixture name="install" module="Magento_Install" type="virtual" entity_type="install" repository_class="Magento\Install\Test\Repository\Install" handler_interface="Magento\Install\Test\Handler\Install\InstallInterface" class="Magento\Install\Test\Fixture\Install">
10+
<field name="dbHost" />
11+
<field name="dbUser" />
12+
<field name="dbPassword" />
13+
<field name="dbName" />
14+
<field name="dbTablePrefix" />
15+
<field name="baseUrl" />
16+
<field name="admin" />
17+
<field name="adminUsername" />
18+
<field name="adminEmail" />
19+
<field name="adminPassword" />
20+
<field name="adminConfirm" />
21+
<field name="apacheRewrites" />
22+
<field name="keyOwn" />
23+
<field name="httpsAdmin" />
24+
<field name="https" />
25+
<field name="httpsFront" />
26+
<field name="keyValue" />
27+
<field name="storeLanguage" />
28+
<field name="storeCurrency" />
29+
</fixture>
3030
</config>

0 commit comments

Comments
 (0)