Skip to content

Commit c37280f

Browse files
authored
Merge branch 'develop' into MQE-1582
2 parents 51fc64f + 4e259a0 commit c37280f

File tree

8 files changed

+86
-6
lines changed

8 files changed

+86
-6
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
namespace Magento\AcceptanceTest\_default\Backend;
3+
4+
use Magento\FunctionalTestingFramework\AcceptanceTester;
5+
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore;
6+
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler;
7+
use \Codeception\Util\Locator;
8+
use Yandex\Allure\Adapter\Annotation\Features;
9+
use Yandex\Allure\Adapter\Annotation\Stories;
10+
use Yandex\Allure\Adapter\Annotation\Title;
11+
use Yandex\Allure\Adapter\Annotation\Description;
12+
use Yandex\Allure\Adapter\Annotation\Parameter;
13+
use Yandex\Allure\Adapter\Annotation\Severity;
14+
use Yandex\Allure\Adapter\Model\SeverityLevel;
15+
use Yandex\Allure\Adapter\Annotation\TestCaseId;
16+
17+
/**
18+
*/
19+
class ActionGroupWithParameterizedElementsWithStepKeyReferencesCest
20+
{
21+
/**
22+
* @Features({"TestModule"})
23+
* @Parameter(name = "AcceptanceTester", value="$I")
24+
* @param AcceptanceTester $I
25+
* @return void
26+
* @throws \Exception
27+
*/
28+
public function ActionGroupWithParameterizedElementsWithStepKeyReferences(AcceptanceTester $I)
29+
{
30+
$I->comment("Entering Action Group [actionGroup] actionGroupWithParametrizedSelectors");
31+
$testVariableActionGroup = $I->executeJS("return 1"); // stepKey: testVariableActionGroup
32+
$testVariable2ActionGroup = $I->executeJS("return 'test'"); // stepKey: testVariable2ActionGroup
33+
$I->comment("[createSimpleDataActionGroup] create 'simpleData' entity");
34+
PersistedObjectHandler::getInstance()->createEntity(
35+
"createSimpleDataActionGroup",
36+
"test",
37+
"simpleData",
38+
[],
39+
[]
40+
);
41+
42+
$I->click("#{$testVariable2ActionGroup} .John"); // stepKey: click1ActionGroup
43+
$I->click("#Doe-" . msq("simpleParamData") . "prename .{$testVariableActionGroup}"); // stepKey: click2ActionGroup
44+
$I->seeElement("//div[@name='Tiberius'][@class={$testVariableActionGroup}][@data-element='{$testVariable2ActionGroup}'][" . PersistedObjectHandler::getInstance()->retrieveEntityField('createSimpleData', 'name', 'test') . "]"); // stepKey: see1ActionGroup
45+
$I->comment("Exiting Action Group [actionGroup] actionGroupWithParametrizedSelectors");
46+
}
47+
}

dev/tests/verification/TestModule/ActionGroup/FunctionalActionGroup.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,16 @@
9191
</arguments>
9292
<executeJS function="{{section.oneParamElement('full-width')}}" stepKey="keyone"/>
9393
</actionGroup>
94+
<actionGroup name="actionGroupWithParametrizedSelectors">
95+
<arguments>
96+
<argument name="param" type="entity"/>
97+
<argument name="param2" type="entity" defaultValue="simpleParamData"/>
98+
</arguments>
99+
<executeJS function="return 1" stepKey="testVariable"/>
100+
<executeJS function="return 'test'" stepKey="testVariable2"/>
101+
<createData entity="simpleData" stepKey="createSimpleData"/>
102+
<click selector="{{SampleSection.twoParamElement({$testVariable2}, param.firstname)}}" stepKey="click1"/>
103+
<click selector="{{SampleSection.threeParamElement(param.lastname, param2.uniqueNamePre, {$testVariable})}}" stepKey="click2"/>
104+
<seeElement selector="{{SampleSection.fourParamElement(param.middlename, {$testVariable}, {$testVariable2}, $$createSimpleData.name$$)}}" stepKey="see1"/>
105+
</actionGroup>
94106
</actionGroups>

dev/tests/verification/TestModule/Section/SampleSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<element name="oneParamElement" type="button" selector="#element .{{var1}}" parameterized="true"/>
1616
<element name="twoParamElement" type="button" selector="#{{var1}} .{{var2}}" parameterized="true"/>
1717
<element name="threeParamElement" type="button" selector="#{{var1}}-{{var2}} .{{var3}}" parameterized="true"/>
18+
<element name="fourParamElement" type="input" selector="//div[@name='{{arg1}}'][@class={{arg2}}][@data-element='{{arg3}}'][{{arg4}}]" parameterized="true"/>
1819
<element name="threeOneDuplicateParamElement" type="button" selector="#{{var1}}-{{var2}} .{{var1}} [{{var3}}]" parameterized="true"/>
1920
<element name="timeoutElement" type="button" selector="#foo" timeout="30"/>
2021
<element name="mergeElement" type="button" selector="#unMerge"/>

dev/tests/verification/TestModule/Test/ActionGroupTest.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,11 @@
171171
<argument name="section" value="SampleSection"/>
172172
</actionGroup>
173173
</test>
174+
175+
<test name="ActionGroupWithParameterizedElementsWithStepKeyReferences">
176+
<actionGroup ref="actionGroupWithParametrizedSelectors" stepKey="actionGroup">
177+
<argument name="param" value="simpleData"/>
178+
<argument name="param2" value="simpleParamData"/>
179+
</actionGroup>
180+
</test>
174181
</tests>

dev/tests/verification/Tests/ActionGroupGenerationTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,15 @@ public function testActionGroupWithXmlComments()
217217
{
218218
$this->generateAndCompareTest('XmlCommentedActionGroupTest');
219219
}
220+
221+
/**
222+
* Test generation of a test referencing an action group with selectors referencing stepKeys.
223+
*
224+
* @throws \Exception
225+
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
226+
*/
227+
public function testActionGroupWithActionStepKeyReferencesInSelectors()
228+
{
229+
$this->generateAndCompareTest('ActionGroupWithParameterizedElementsWithStepKeyReferences');
230+
}
220231
}

etc/config/functional.suite.dist.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ modules:
2828
username: "%MAGENTO_ADMIN_USERNAME%"
2929
password: "%MAGENTO_ADMIN_PASSWORD%"
3030
pageload_timeout: 30
31-
host: %SELENIUM_HOST%
32-
port: %SELENIUM_PORT%
33-
protocol: %SELENIUM_PROTOCOL%
34-
path: %SELENIUM_PATH%
31+
host: "%SELENIUM_HOST%"
32+
port: "%SELENIUM_PORT%"
33+
protocol: "%SELENIUM_PROTOCOL%"
34+
path: "%SELENIUM_PATH%"
3535
capabilities:
3636
chromeOptions:
3737
args: ["--window-size=1280,1024", "--disable-extensions", "--enable-automation", "--disable-gpu", "--enable-Passthrough"]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ private function resolveAttributesWithArguments($arguments, $attributes)
226226
// $regexPattern match on: $matches[0] {{section.element(arg.field)}}
227227
// $matches[1] = section.element
228228
// $matches[2] = arg.field
229-
$regexPattern = '/{{([^(}]+)\(*([^)}]+)*\)*}}/';
229+
$regexPattern = '/{{([^(}]+)\(*([^)]+)*?\)*}}/';
230230

231231
$newActionAttributes = [];
232232
foreach ($attributes as $attributeKey => $attributeValue) {

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1483,8 +1483,10 @@ private function resolveStepKeyReferences($input, $actionGroupOrigin, $matchAll
14831483
$persistedVarRefInvoked = "PersistedObjectHandler::getInstance()->retrieveEntityField('"
14841484
. $stepKey . $testInvocationKey . "', 'field', 'test')";
14851485

1486+
// only replace when whole word matches exactly
1487+
// e.g. testVar => $testVar but not $testVar2
14861488
if (strpos($output, $stepKeyVarRef) !== false) {
1487-
$output = str_replace($stepKeyVarRef, $stepKeyVarRef . $testInvocationKey, $output);
1489+
$output = preg_replace('/\B\\' .$stepKeyVarRef. '\b/', $stepKeyVarRef . $testInvocationKey, $output);
14881490
}
14891491

14901492
if (strpos($output, $persistedVarRef) !== false) {

0 commit comments

Comments
 (0)