Skip to content

Commit de1ab89

Browse files
authored
MQE-1222: Selector Fails To Resolve Correctly in Action Group
- Added support for passing in data into arguments as `{{mydata.value}}`
1 parent 95bcb1d commit de1ab89

File tree

5 files changed

+66
-2
lines changed

5 files changed

+66
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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 ActionGroupWithSectionAndDataAsArgumentsCest
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 ActionGroupWithSectionAndDataAsArguments(AcceptanceTester $I)
29+
{
30+
$I->waitForElementVisible("#element .John");
31+
}
32+
}

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

+8
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,12 @@
118118
<actionGroup name="actionGroupWithSkipReadinessActions">
119119
<comment userInput="ActionGroupSkipReadiness" stepKey="skip" skipReadiness="true"/>
120120
</actionGroup>
121+
122+
<actionGroup name="actionGroupWithSectionAndData">
123+
<arguments>
124+
<argument name="content" type="string"/>
125+
<argument name="section"/>
126+
</arguments>
127+
<waitForElementVisible selector="{{section.oneParamElement(content)}}" stepKey="arg1"/>
128+
</actionGroup>
121129
</actionGroups>

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

+8
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,14 @@
158158
<argument name="sameStepKeyAsArg" value="arg1"/>
159159
</actionGroup>
160160
</test>
161+
162+
<test name="ActionGroupWithSectionAndDataAsArguments">
163+
<actionGroup ref="actionGroupWithSectionAndData" stepKey="actionGroup">
164+
<argument name="content" value="{{simpleData.firstname}}"/>
165+
<argument name="section" value="SampleSection"/>
166+
</actionGroup>
167+
</test>
168+
161169
<test name="ActionGroupWithParameterizedElementWithHyphen">
162170
<actionGroup ref="SectionArgumentWithParameterizedSelector" stepKey="actionGroup">
163171
<argument name="section" value="SampleSection"/>

dev/tests/verification/Tests/ActionGroupGenerationTest.php

+11
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,17 @@ public function testActionGroupWithSkipReadiness()
196196
$this->generateAndCompareTest('ActionGroupSkipReadiness');
197197
}
198198

199+
/**
200+
* Test an action group with an arg containing stepKey text
201+
*
202+
* @throws \Exception
203+
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
204+
*/
205+
public function testActionGroupWithSectionAndDataArguments()
206+
{
207+
$this->generateAndCompareTest('ActionGroupWithSectionAndDataAsArguments');
208+
}
209+
199210
/**
200211
* Test an action group with an arg that resolves into section.element with a hyphen in the parameter
201212
*

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

+7-2
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ public function getResolvedValue($isInnerArgument)
104104
* Takes in boolean to determine if the replacement is being done with an inner argument (as in if it's a parameter)
105105
*
106106
* Example Type Non Inner Inner
107-
* {{XML.DATA}}: {{XML.DATA}} XML.DATA
108-
* $TEST.DATA$: $TEST.DATA$ $TEST.DATA$
107+
* {{XML.DATA}} {{XML.DATA}} XML.DATA
108+
* $TEST.DATA$ $TEST.DATA$ $TEST.DATA$
109109
* stringLiteral stringLiteral 'stringLiteral'
110110
*
111111
* @param boolean $isInnerArgument
@@ -114,6 +114,11 @@ public function getResolvedValue($isInnerArgument)
114114
private function resolveStringArgument($isInnerArgument)
115115
{
116116
if ($isInnerArgument) {
117+
if (preg_match('/{{[\w.\[\]]+}}/', $this->value)) {
118+
return ltrim(rtrim($this->value, "}"), "{");
119+
} elseif (preg_match('/\${1,2}[\w.\[\]]+\${1,2}/', $this->value)) {
120+
return $this->value;
121+
}
117122
return "'" . $this->value . "'";
118123
} else {
119124
return $this->value;

0 commit comments

Comments
 (0)