Skip to content

Commit 59862c9

Browse files
committed
MQE-1153: ExecuteJS javascript escaping matches persisted data
- Updated regex to support an additional use case - Added test for additional use case
1 parent 55c9ee4 commit 59862c9

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

dev/tests/verification/Resources/ExecuteJsEscapingTest.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ class ExecuteJsEscapingTestCest
3333
$mftfVariableNotEscaped = $I->executeJS("return {$doNotEscape}");
3434
$persistedDataNotEscaped = $I->executeJS("return " . $persisted->getCreatedDataByName('data'));
3535
$hookPersistedDataNotEscaped = $I->executeJS("return " . $this->persisted->getCreatedDataByName('data'));
36+
$addNewAttributeForRule = $I->executeJS("document.querySelector('entity option[value=" . $this->productAttribute->getCreatedDataByName('attribute_code') . "]').setAttribute('selected', 'selected')");
3637
}
3738
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
<executeJS function="return {$doNotEscape}" stepKey="mftfVariableNotEscaped"/>
1414
<executeJS function="return $persisted.data$" stepKey="persistedDataNotEscaped"/>
1515
<executeJS function="return $$persisted.data$$" stepKey="hookPersistedDataNotEscaped"/>
16+
<executeJS function="document.querySelector('entity option[value=$$productAttribute.attribute_code$$]').setAttribute('selected', 'selected')" stepKey="addNewAttributeForRule"/>
1617
</test>
1718
</tests>

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = "
620620
}
621621
// turn $javaVariable => \$javaVariable but not {$mftfVariable}
622622
if ($actionObject->getType() == "executeJS") {
623-
$function = preg_replace('/(?<!{)(\$[A-z._]+)(?![A-z.]*+\$)/', '\\\\$1', $function);
623+
$function = preg_replace('/(?<!{)(\$[A-Za-z._]+)(?![A-z.]*+\$)/', '\\\\$1', $function);
624624
}
625625
}
626626

0 commit comments

Comments
 (0)