From 55c9ee4b414751dd691384ed2ecd298cd3fc892c Mon Sep 17 00:00:00 2001 From: Alex Calandra Date: Tue, 24 Jul 2018 10:47:30 -0500 Subject: [PATCH 1/2] MQE-1153: ExecuteJS javascript escaping matches persisted data - Updated Regular expression for executeJS to be stricter for escaping characters --- dev/tests/verification/Resources/ExecuteJsEscapingTest.txt | 2 ++ dev/tests/verification/TestModule/Test/ExecuteJsTest.xml | 2 ++ src/Magento/FunctionalTestingFramework/Util/TestGenerator.php | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dev/tests/verification/Resources/ExecuteJsEscapingTest.txt b/dev/tests/verification/Resources/ExecuteJsEscapingTest.txt index 94dc2cbdb..d1fe0fd2f 100644 --- a/dev/tests/verification/Resources/ExecuteJsEscapingTest.txt +++ b/dev/tests/verification/Resources/ExecuteJsEscapingTest.txt @@ -31,5 +31,7 @@ class ExecuteJsEscapingTestCest { $javaVariableEscape = $I->executeJS("return \$javascriptVariable"); $mftfVariableNotEscaped = $I->executeJS("return {$doNotEscape}"); + $persistedDataNotEscaped = $I->executeJS("return " . $persisted->getCreatedDataByName('data')); + $hookPersistedDataNotEscaped = $I->executeJS("return " . $this->persisted->getCreatedDataByName('data')); } } diff --git a/dev/tests/verification/TestModule/Test/ExecuteJsTest.xml b/dev/tests/verification/TestModule/Test/ExecuteJsTest.xml index 2429fa484..2fdafd792 100644 --- a/dev/tests/verification/TestModule/Test/ExecuteJsTest.xml +++ b/dev/tests/verification/TestModule/Test/ExecuteJsTest.xml @@ -11,5 +11,7 @@ + + diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index af39f6ad1..281603322 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -620,7 +620,7 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " } // turn $javaVariable => \$javaVariable but not {$mftfVariable} if ($actionObject->getType() == "executeJS") { - $function = preg_replace('/(? Date: Tue, 31 Jul 2018 15:02:41 -0500 Subject: [PATCH 2/2] MQE-1153: ExecuteJS javascript escaping matches persisted data - Updated regex to support an additional use case - Added test for additional use case --- dev/tests/verification/Resources/ExecuteJsEscapingTest.txt | 1 + dev/tests/verification/TestModule/Test/ExecuteJsTest.xml | 1 + src/Magento/FunctionalTestingFramework/Util/TestGenerator.php | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dev/tests/verification/Resources/ExecuteJsEscapingTest.txt b/dev/tests/verification/Resources/ExecuteJsEscapingTest.txt index d1fe0fd2f..371eb3d0d 100644 --- a/dev/tests/verification/Resources/ExecuteJsEscapingTest.txt +++ b/dev/tests/verification/Resources/ExecuteJsEscapingTest.txt @@ -33,5 +33,6 @@ class ExecuteJsEscapingTestCest $mftfVariableNotEscaped = $I->executeJS("return {$doNotEscape}"); $persistedDataNotEscaped = $I->executeJS("return " . $persisted->getCreatedDataByName('data')); $hookPersistedDataNotEscaped = $I->executeJS("return " . $this->persisted->getCreatedDataByName('data')); + $addNewAttributeForRule = $I->executeJS("document.querySelector('entity option[value=" . $this->productAttribute->getCreatedDataByName('attribute_code') . "]').setAttribute('selected', 'selected')"); } } diff --git a/dev/tests/verification/TestModule/Test/ExecuteJsTest.xml b/dev/tests/verification/TestModule/Test/ExecuteJsTest.xml index 2fdafd792..b361cdd28 100644 --- a/dev/tests/verification/TestModule/Test/ExecuteJsTest.xml +++ b/dev/tests/verification/TestModule/Test/ExecuteJsTest.xml @@ -13,5 +13,6 @@ + diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index 281603322..13cba9675 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -620,7 +620,7 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " } // turn $javaVariable => \$javaVariable but not {$mftfVariable} if ($actionObject->getType() == "executeJS") { - $function = preg_replace('/(?