Skip to content

Commit 32d7fdc

Browse files
authored
Merge branch 'develop' into MQE-501
2 parents 4ede533 + 2bdc905 commit 32d7fdc

File tree

11 files changed

+83
-54
lines changed

11 files changed

+83
-54
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,36 @@ public function testResolveDataInUserInput()
255255
$this->assertEquals($expected, $actionObject->getCustomActionAttributes());
256256
}
257257

258+
/**
259+
* {{EntityDataObject.values}} should be replaced with ["value1","value2"]
260+
*/
261+
public function testResolveArrayData()
262+
{
263+
// Set up mocks
264+
$actionObject = new ActionObject('merge123', 'fillField', [
265+
'selector' => '#selector',
266+
'userInput' => '{{EntityDataObject.values}}'
267+
]);
268+
$entityDataObject = new EntityDataObject('EntityDataObject', 'test', [
269+
'values' => [
270+
'value1',
271+
'value2',
272+
'"My" Value'
273+
]
274+
], [], '', '');
275+
$this->mockDataHandlerWithData($entityDataObject);
276+
277+
// Call the method under test
278+
$actionObject->resolveReferences();
279+
280+
// Verify
281+
$expected = [
282+
'selector' => '#selector',
283+
'userInput' => '["value1","value2","\"My\" Value"]'
284+
];
285+
$this->assertEquals($expected, $actionObject->getCustomActionAttributes());
286+
}
287+
258288
/**
259289
* Action object should throw an exception if a reference to a parameterized selector has too few given args.
260290
*/

dev/tests/verification/Resources/ActionGroupWithPassedArgumentAndStringSelectorParam.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ class ActionGroupWithPassedArgumentAndStringSelectorParamCest
2929
*/
3030
public function ActionGroupWithPassedArgumentAndStringSelectorParam(AcceptanceTester $I)
3131
{
32-
$I->see("John".msq("UniquePerson"), "#element .test1");
32+
$I->see("John" . msq("UniquePerson"), "#element .test1");
3333
}
3434
}

dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromPassedArgument.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ class ActionGroupWithSingleParameterSelectorFromPassedArgumentCest
2929
*/
3030
public function ActionGroupWithSingleParameterSelectorFromPassedArgument(AcceptanceTester $I)
3131
{
32-
$I->see("Doe", "#element .John".msq("UniquePerson"));
32+
$I->see("Doe", "#element .John" . msq("UniquePerson"));
3333
}
3434
}

dev/tests/verification/Resources/DataReplacementTest.txt

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,22 @@ class DataReplacementTestCest
3333
$I->conditionalClick("Doe", "#John", true);
3434
$I->amOnUrl("John.html");
3535
$I->searchAndMultiSelectOption("#selector", ["John", "Doe"]);
36-
$I->fillField("#selector", "StringBefore ".msq("uniqueData")."John StringAfter");
37-
$I->fillField("#".msq("uniqueData")."John", "input");
38-
$I->dragAndDrop("#".msq("uniqueData")."John", msq("uniqueData")."John");
39-
$I->conditionalClick(msq("uniqueData")."John", "#".msq("uniqueData")."John", true);
40-
$I->amOnUrl(msq("uniqueData")."John.html");
41-
$I->searchAndMultiSelectOption("#selector", [msq("uniqueData")."John", "Doe"]);
42-
$I->fillField("#selector", "StringBefore Doe".msq("uniqueData")." StringAfter");
43-
$I->fillField("#Doe".msq("uniqueData"), "input");
44-
$I->dragAndDrop("#Doe".msq("uniqueData"), "Doe".msq("uniqueData"));
45-
$I->conditionalClick("Doe".msq("uniqueData"), "#Doe".msq("uniqueData"), true);
46-
$I->amOnUrl("Doe".msq("uniqueData").".html");
47-
$I->searchAndMultiSelectOption("#selector", ["John", "Doe".msq("uniqueData")]);
48-
$I->searchAndMultiSelectOption("#selector", [msq("uniqueData")."John", "Doe".msq("uniqueData")]);
49-
$I->selectMultipleOptions("#Doe".msq("uniqueData"), "#element", [msq("uniqueData")."John", "Doe".msq("uniqueData")]);
36+
$I->fillField("#selector", "StringBefore " . msq("uniqueData") . "John StringAfter");
37+
$I->fillField("#" . msq("uniqueData") . "John", "input");
38+
$I->dragAndDrop("#" . msq("uniqueData") . "John", msq("uniqueData") . "John");
39+
$I->conditionalClick(msq("uniqueData") . "John", "#" . msq("uniqueData") . "John", true);
40+
$I->amOnUrl(msq("uniqueData") . "John.html");
41+
$I->searchAndMultiSelectOption("#selector", [msq("uniqueData") . "John", "Doe"]);
42+
$I->click("#" . msq("uniqueData") . "John#" . msq("uniqueData") . "John");
43+
$I->click("#Doe" . msq("uniqueData") . "#Doe" . msq("uniqueData"));
44+
$I->fillField("#selector", "StringBefore Doe" . msq("uniqueData") . " StringAfter");
45+
$I->fillField("#Doe" . msq("uniqueData"), "input");
46+
$I->dragAndDrop("#Doe" . msq("uniqueData"), "Doe" . msq("uniqueData"));
47+
$I->conditionalClick("Doe" . msq("uniqueData"), "#Doe" . msq("uniqueData"), true);
48+
$I->amOnUrl("Doe" . msq("uniqueData") . ".html");
49+
$I->searchAndMultiSelectOption("#selector", ["John", "Doe" . msq("uniqueData")]);
50+
$I->searchAndMultiSelectOption("#selector", [msq("uniqueData") . "John", "Doe" . msq("uniqueData")]);
51+
$I->selectMultipleOptions("#Doe" . msq("uniqueData"), "#element", [msq("uniqueData") . "John", "Doe" . msq("uniqueData")]);
5052
$I->fillField(".selector", "0");
5153
}
5254
}

dev/tests/verification/Resources/ParameterArrayTest.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ class ParameterArrayTestCest
3232
$simpleDataKey = new DataPersistenceHandler($simpleParamData, []);
3333
$simpleDataKey->createEntity();
3434
$I->searchAndMultiSelectOption("#selector", ["name"]);
35-
$I->searchAndMultiSelectOption("#selector", [msq("simpleParamData")."prename"]);
36-
$I->searchAndMultiSelectOption("#selector", ["postname".msq("simpleParamData")]);
35+
$I->searchAndMultiSelectOption("#selector", [msq("simpleParamData") . "prename"]);
36+
$I->searchAndMultiSelectOption("#selector", ["postname" . msq("simpleParamData")]);
3737
$I->searchAndMultiSelectOption("#selector", [$simpleDataKey->getCreatedDataByName('name')]);
3838
$I->searchAndMultiSelectOption("#selector", ["name", $simpleDataKey->getCreatedDataByName('name')]);
3939
$I->searchAndMultiSelectOption("#selector", ['someKey' => $simpleDataKey->getCreatedDataByName('name')]);
4040
$I->searchAndMultiSelectOption("#selector", ['someKey' => "name"]);
41-
$I->searchAndMultiSelectOption("#selector", ['someKey' => msq("simpleParamData")."prename"]);
42-
$I->searchAndMultiSelectOption("#selector", ['someKey' => "postname".msq("simpleParamData")]);
41+
$I->searchAndMultiSelectOption("#selector", ['someKey' => msq("simpleParamData") . "prename"]);
42+
$I->searchAndMultiSelectOption("#selector", ['someKey' => "postname" . msq("simpleParamData")]);
4343
$I->unselectOption("#selector", ['foo']);
4444
$I->unselectOption("#selector", ['foo', 'bar']);
4545
$I->unselectOption("#selector", ["name"]);
46-
$I->unselectOption("#selector", [msq("simpleParamData")."prename"]);
47-
$I->unselectOption("#selector", ["postname".msq("simpleParamData")]);
46+
$I->unselectOption("#selector", [msq("simpleParamData") . "prename"]);
47+
$I->unselectOption("#selector", ["postname" . msq("simpleParamData")]);
4848
$I->unselectOption("#selector", [$simpleDataKey->getCreatedDataByName('name')]);
4949
$I->unselectOption("#selector", ["name", $simpleDataKey->getCreatedDataByName('name')]);
5050
}

dev/tests/verification/Resources/SectionReplacementTest.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ class SectionReplacementTestCest
3838
$I->click("#John .Doe");
3939
$I->click("#John-Doe .Tiberius");
4040
$I->click("#John-Doe .John [Tiberius]");
41-
$I->click("#element .".msq("uniqueData")."John");
42-
$I->click("#".msq("uniqueData")."John .stringLiteral2");
43-
$I->click("#".msq("uniqueData")."John-stringLiteral2 .stringLiteral3");
44-
$I->click("#".msq("uniqueData")."John-stringLiteral2 .");
45-
$I->click("#element .Doe".msq("uniqueData"));
46-
$I->click("#Doe".msq("uniqueData")." .stringLiteral2");
47-
$I->click("#Doe".msq("uniqueData")."-stringLiteral2 .stringLiteral3");
48-
$I->click("#Doe".msq("uniqueData")."-stringLiteral2 .Doe");
41+
$I->click("#element ." . msq("uniqueData") . "John");
42+
$I->click("#" . msq("uniqueData") . "John .stringLiteral2");
43+
$I->click("#" . msq("uniqueData") . "John-stringLiteral2 .stringLiteral3");
44+
$I->click("#" . msq("uniqueData") . "John-stringLiteral2 ." . msq("uniqueData") . "John [stringLiteral3]");
45+
$I->click("#element .Doe" . msq("uniqueData"));
46+
$I->click("#Doe" . msq("uniqueData") . " .stringLiteral2");
47+
$I->click("#Doe" . msq("uniqueData") . "-stringLiteral2 .stringLiteral3");
48+
$I->click("#Doe" . msq("uniqueData") . "-stringLiteral2 .Doe" . msq("uniqueData") . " [stringLiteral3]");
4949
$I->amGoingTo("create entity that has the stepKey: createdData");
5050
$simpleData = DataObjectHandler::getInstance()->getObject("simpleData");
5151
$createdData = new DataPersistenceHandler($simpleData, []);
@@ -60,7 +60,7 @@ class SectionReplacementTestCest
6060
$I->click("#John-Doe .John [Tiberius]");
6161
$I->click("#stringLiteral1-" . $createdData->getCreatedDataByName('firstname') . " .John");
6262
$I->click("#stringLiteral1-" . $createdData->getCreatedDataByName('firstname') . " .{$data}");
63-
$I->click("#stringLiteral1-" . $createdData->getCreatedDataByName('firstname') . " .".msq("uniqueData")."John");
64-
$I->click("#stringLiteral1-" . $createdData->getCreatedDataByName('firstname') . " .Doe".msq("uniqueData"));
63+
$I->click("#stringLiteral1-" . $createdData->getCreatedDataByName('firstname') . " ." . msq("uniqueData") . "John");
64+
$I->click("#stringLiteral1-" . $createdData->getCreatedDataByName('firstname') . " .Doe" . msq("uniqueData"));
6565
}
6666
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
<conditionalClick stepKey="dependentSelectorReplaceMSQPrefix" dependentSelector="#{{uniqueData.firstname}}" selector="{{uniqueData.firstname}}" visible="true"/>
2323
<amOnUrl stepKey="urlReplaceMSQPrefix" url="{{uniqueData.firstname}}.html"/>
2424
<searchAndMultiSelectOption stepKey="parameterArrayReplacementMSQPrefix" selector="#selector" parameterArray="[{{uniqueData.firstname}}, {{simpleData.lastname}}]"/>
25+
<click stepKey="selectorReplaceDupedMSQPrefix" selector="#{{uniqueData.firstname}}#{{uniqueData.firstname}}"/>
26+
<click stepKey="selectorReplaceDupedMSQSuffix" selector="#{{uniqueData.lastname}}#{{uniqueData.lastname}}"/>
2527

2628
<fillField stepKey="inputReplaceMSQSuffix" selector="#selector" userInput="StringBefore {{uniqueData.lastname}} StringAfter"/>
2729
<fillField stepKey="selectorReplaceMSQSuffix" selector="#{{uniqueData.lastname}}" userInput="input"/>

src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ public function conditionalClick($selector, $dependentSelector, $visible)
472472
{
473473
$el = $this->_findElements($dependentSelector);
474474
if (sizeof($el) > 1) {
475-
throw new \Exception("more than one element matches selector " . $selector);
475+
throw new \Exception("more than one element matches selector " . $dependentSelector);
476476
}
477477

478478
$clickCondition = null;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,10 @@ private function findAndReplaceReferences($objectHandler, $inputString)
495495
$this->setTimeout($obj->getElement($objField)->getTimeout());
496496
} elseif (get_class($obj) == EntityDataObject::class) {
497497
$replacement = $this->resolveEntityDataObjectReference($obj, $match);
498+
499+
if (is_array($replacement)) {
500+
$replacement = '["' . implode('","', array_map('addSlashes', $replacement)) . '"]';
501+
}
498502
}
499503

500504
if ($replacement === null) {

src/Magento/FunctionalTestingFramework/Util/ModuleResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,9 @@ private function aggregateTestModulePaths()
236236
. 'vendor' . DIRECTORY_SEPARATOR;
237237

238238
$codePathsToPattern = [
239-
$appCodePath => '/Test/Acceptance',
240239
$modulePath => '',
241-
$vendorCodePath => '/Test/Acceptance'
240+
$appCodePath => '/Test/MFTF',
241+
$vendorCodePath => '/Test/MFTF'
242242
];
243243

244244
foreach ($codePathsToPattern as $codePath => $pattern) {

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,26 +1576,17 @@ private function addUniquenessToParamArray($input)
15761576
*/
15771577
private function addUniquenessFunctionCall($input)
15781578
{
1579-
$output = '';
1580-
1581-
preg_match('/' . EntityDataObject::CEST_UNIQUE_FUNCTION . '\("[\w]+"\)/', $input, $matches);
1582-
if (!empty($matches)) {
1583-
$parts = preg_split('/' . EntityDataObject::CEST_UNIQUE_FUNCTION . '\("[\w]+"\)/', $input, -1);
1584-
for ($i = 0; $i < count($parts); $i++) {
1585-
$parts[$i] = $this->stripWrappedQuotes($parts[$i]);
1586-
}
1587-
if (!empty($parts[0])) {
1588-
$output = $this->wrapWithDoubleQuotes($parts[0]);
1589-
}
1590-
$output .= $output === '' ? $matches[0] : '.' . $matches[0];
1591-
if (!empty($parts[1])) {
1592-
$output .= '.' . $this->wrapWithDoubleQuotes($parts[1]);
1593-
}
1594-
} else {
1595-
$output = $this->wrapWithDoubleQuotes($input);
1579+
$output = $this->wrapWithDoubleQuotes($input);
1580+
1581+
//Match on msq(\"entityName\")
1582+
preg_match_all('/' . EntityDataObject::CEST_UNIQUE_FUNCTION . '\(\\\\"[\w]+\\\\"\)/', $output, $matches);
1583+
foreach (array_unique($matches[0]) as $match) {
1584+
preg_match('/\\\\"([\w]+)\\\\"/', $match, $entityMatch);
1585+
$entity = $entityMatch[1];
1586+
$output = str_replace($match, '" . msq("' . $entity . '") . "', $output);
15961587
}
1597-
1598-
return $output;
1588+
// trim unnecessary "" . and . ""
1589+
return preg_replace('/(?(?<![\\\\])"" \. )| \. ""/', "", $output);
15991590
}
16001591

16011592
/**

0 commit comments

Comments
 (0)