Skip to content

Commit 5f5d3d9

Browse files
authored
Merge pull request #71 from vasylmalanka/issue-54
#54: Set a global value for timeouts that's used across all wait related actions
2 parents 2109b0d + 8ceca86 commit 5f5d3d9

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

.env.example

+3
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,7 @@ MODULE_WHITELIST=Magento_Framework,Magento_ConfigurableProductWishlist,Magento_C
3737

3838
#*** Bool property which allows the user to toggle debug output during test execution
3939
#MFTF_DEBUG=
40+
41+
#*** Default timeout for wait actions
42+
WAIT_TIMEOUT=10
4043
#*** End of .env ***#

dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionObjectTest.php

+13
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,19 @@ public function testTooManyArgumentException()
291291
$actionObject->resolveReferences();
292292
}
293293

294+
/**
295+
* Method should return either .env file value or constant value
296+
*/
297+
public function testGetDefaultWaitTimeout()
298+
{
299+
$this->assertEquals(ActionObject::getDefaultWaitTimeout(), ActionObject::DEFAULT_WAIT_TIMEOUT);
300+
301+
$envFile = new \Dotenv\Dotenv(__DIR__ . '/../../../../../../../', '.env.example');
302+
$envFile->load();
303+
304+
$this->assertEquals(ActionObject::getDefaultWaitTimeout(), getenv('WAIT_TIMEOUT'));
305+
}
306+
294307
private function mockSectionHandlerWithElement($elementObject)
295308
{
296309
$sectionObject = new SectionObject('SectionObject', ['elementObject' => $elementObject]);

src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php

+11
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class ActionObject
4141
const ACTION_ATTRIBUTE_SELECTOR = 'selector';
4242
const ACTION_ATTRIBUTE_VARIABLE_REGEX_PARAMETER = '/\(.+\)/';
4343
const ACTION_ATTRIBUTE_VARIABLE_REGEX_PATTERN = '/({{[\w]+\.[\w\[\]]+}})|({{[\w]+\.[\w]+\(.+\)}})/';
44+
const DEFAULT_WAIT_TIMEOUT = 10;
4445

4546
/**
4647
* The unique identifier for the action
@@ -127,6 +128,16 @@ public function __construct(
127128
}
128129
}
129130

131+
/**
132+
* Retrieve default timeout in seconds for 'wait*' actions
133+
*
134+
* @return int
135+
*/
136+
public static function getDefaultWaitTimeout()
137+
{
138+
return getenv('WAIT_TIMEOUT') ?: self::DEFAULT_WAIT_TIMEOUT;
139+
}
140+
130141
/**
131142
* This function returns the string property stepKey.
132143
*

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

+1
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = "
539539
if (isset($customActionAttributes['timeout'])) {
540540
$time = $customActionAttributes['timeout'];
541541
}
542+
$time = $time ?? ActionObject::getDefaultWaitTimeout();
542543

543544
if (isset($customActionAttributes['parameterArray']) && $actionObject->getType() != 'pressKey') {
544545
// validate the param array is in the correct format

0 commit comments

Comments
 (0)