Skip to content

Commit b8f7667

Browse files
committed
MQE-1234: Allow XML Parser to read XML comment into comment action
1 parent 45ceeda commit b8f7667

File tree

9 files changed

+18
-4
lines changed

9 files changed

+18
-4
lines changed

dev/tests/functional/tests/MFTF/DevDocs/Test/DevDocsTest.xml

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
xsi:noNamespaceSchemaLocation="../../../../../../../src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
1111
<test name="DevDocsTest">
1212
<annotations>
13-
<!-- Hwello -->
13+
<!-- Comment in Annotations for DevDocs Test are not affecting test generation -->
1414
<features value="DevDocs available"/>
1515
<stories value="MFTF DevDocs available"/>
1616
<title value="Magento Functional Testing Framework Documentation is available."/>
@@ -21,7 +21,6 @@
2121

2222
<!-- Open MFTF DevDocs Page -->
2323
<amOnPage stepKey="openMFTFDevDocPage" url="{{MFTFDocPage.url}}" />
24-
<!--< > & $abc " abc ' <click stepKey="click" userInput="$$createDataHook.firstname$$" selector="#id">/-->
2524
<actionGroup ref="AdminNavigateMenuActionGroup" stepKey="asdf" />
2625
<see stepKey="verifyPageIntroText" selector="{{contentSection.pageIntro}}" userInput="Introduction to the Magento Functional Testing Framework" />
2726
</test>

dev/tests/verification/Resources/ActionGroupWithDefaultArgumentAndStringSelectorParam.txt

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class ActionGroupWithDefaultArgumentAndStringSelectorParamCest
3030
public function ActionGroupWithDefaultArgumentAndStringSelectorParam(AcceptanceTester $I)
3131
{
3232
$I->comment("Entering Action Group [actionGroup] actionGroupWithDefaultArgumentAndStringSelectorParam");
33+
$I->comment("< > & \$abc \" abc ' <click stepKey=\"click\" userInput=\"\$\$createDataHook.firstname\$\$\" selector=\"#id\">/");
3334
$I->see("John", "#element .test1"); // stepKey: seeFirstNameActionGroup
3435
$I->comment("Exiting Action Group [actionGroup] actionGroupWithDefaultArgumentAndStringSelectorParam");
3536
}

dev/tests/verification/Resources/ActionGroupWithPassedArgumentAndStringSelectorParam.txt

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class ActionGroupWithPassedArgumentAndStringSelectorParamCest
3030
public function ActionGroupWithPassedArgumentAndStringSelectorParam(AcceptanceTester $I)
3131
{
3232
$I->comment("Entering Action Group [actionGroup] actionGroupWithDefaultArgumentAndStringSelectorParam");
33+
$I->comment("< > & \$abc \" abc ' <click stepKey=\"click\" userInput=\"\$\$createDataHook.firstname\$\$\" selector=\"#id\">/");
3334
$I->see("John" . msq("UniquePerson"), "#element .test1"); // stepKey: seeFirstNameActionGroup
3435
$I->comment("Exiting Action Group [actionGroup] actionGroupWithDefaultArgumentAndStringSelectorParam");
3536
}

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

+3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313

1414
<actionGroup name="actionGroupWithDefaultArgumentAndStringSelectorParam">
1515
<arguments>
16+
<!-- Comments in arguments are not affecting test generation -->
17+
<!-- <argument name="someArgument" defaultValue="ReplacementPerson" /> -->
1618
<argument name="someArgument" defaultValue="ReplacementPerson" />
1719
</arguments>
1820

21+
<!--< > & $abc " abc ' <click stepKey="click" userInput="$$createDataHook.firstname$$" selector="#id">/-->
1922
<see selector="{{SampleSection.oneParamElement('test1')}}" userInput="{{someArgument.firstname}}" stepKey="seeFirstName" />
2023
</actionGroup>
2124

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

+3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
<actionGroup ref="actionGroupWithoutArguments" stepKey="actionGroup"/>
1616
</test>
1717

18+
<!--< > & $abc " abc ' <click stepKey="click" userInput="$$createDataHook.firstname$$" selector="#id">/-->
1819
<test name="ActionGroupWithDefaultArgumentAndStringSelectorParam">
1920
<annotations>
21+
<!-- Comments in Test annotations are not affecting test generation -->
22+
<!-- <severity value="BLOCKER"/> -->
2023
<severity value="BLOCKER"/>
2124
<title value="Action Group With Default Argument Value and Hardcoded Value in Param"/>
2225
</annotations>

src/Magento/FunctionalTestingFramework/Test/Config/Converter/Dom/Flat.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function convertXml(\DOMNode $source, $basePath = '')
125125
$value = $node->nodeValue;
126126
break;
127127
} elseif ($node->nodeType == XML_COMMENT_NODE) {
128-
$uniqid = uniqid(str_replace("#", "", $node->nodeName));
128+
$uniqid = uniqid($node->nodeName);
129129
$value[$uniqid] = [
130130
'value' => trim($node->nodeValue),
131131
'nodeName' => $node->nodeName,

src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\FunctionalTestingFramework\Data\Argument\Interpreter\Argument;
1010
use Magento\FunctionalTestingFramework\Exceptions\XmlException;
1111
use Magento\FunctionalTestingFramework\Test\Objects\ActionGroupObject;
12+
use Magento\FunctionalTestingFramework\Test\Objects\ActionObject;
1213
use Magento\FunctionalTestingFramework\Test\Objects\ArgumentObject;
1314

1415
/**
@@ -117,6 +118,10 @@ private function extractArguments($arguments)
117118
self::NODE_NAME
118119
);
119120

121+
$argData = array_filter($argData, function ($key) {
122+
return strpos($key, ActionObject::COMMENT_ACTION) === false;
123+
}, ARRAY_FILTER_USE_KEY);
124+
120125
foreach ($argData as $argName => $argValue) {
121126
$parsedArguments[] = new ArgumentObject(
122127
$argValue[ArgumentObject::ARGUMENT_NAME],

src/Magento/FunctionalTestingFramework/Test/Util/ActionObjectExtractor.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@ public function extractActions($testActions, $testName = null)
5858
$stepKeyRefs = [];
5959

6060
foreach ($testActions as $actionName => $actionData) {
61+
// Removing # from nodeName to match stepKey requirements
6162
$stepKey = strpos($actionData[self::NODE_NAME], ActionObject::COMMENT_ACTION) === false
6263
? $actionData[self::TEST_STEP_MERGE_KEY]
63-
: $actionName;
64+
: str_replace("#", "", $actionName);
6465
$actionType = $actionData[self::NODE_NAME];
6566

6667
if (empty($stepKey)) {

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

+1
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato
13061306
$testSteps .= $this->wrapFunctionCall($actor, $actionObject, $customActionAttributes['state']);
13071307
break;
13081308
case "comment":
1309+
// Combining userInput from native XML comment and <comment /> action and fall-through 'default' case.
13091310
$input = $input === null ? strtr($value, ['$' => '\$', '{' => '\{', '}' => '\}']) : $input;
13101311
default:
13111312
$testSteps .= $this->wrapFunctionCall(

0 commit comments

Comments
 (0)