From 9d7e4ceac9a7bcdb0b3bcb837cdd8a10c90e5180 Mon Sep 17 00:00:00 2001 From: KevinBKozan Date: Tue, 1 May 2018 14:25:31 -0500 Subject: [PATCH 1/8] MQE-812: Tests/Action Groups should infer order based on the top level argument - Test/Dom.php now checks for a test to have a before/after attribute, if found it appends the before/after to all child actions for merging down the line. --- .../Test/Config/Dom.php | 49 +++++++++++++++++++ .../Test/Util/ActionMergeUtil.php | 2 +- .../Test/Util/TestObjectExtractor.php | 6 ++- .../Test/etc/mergedTestSchema.xsd | 2 + 4 files changed, 56 insertions(+), 3 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Test/Config/Dom.php b/src/Magento/FunctionalTestingFramework/Test/Config/Dom.php index 24710243f..3d8c2c4ba 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Config/Dom.php +++ b/src/Magento/FunctionalTestingFramework/Test/Config/Dom.php @@ -17,6 +17,8 @@ class Dom extends \Magento\FunctionalTestingFramework\Config\Dom const TEST_META_FILENAME_ATTRIBUTE = 'filename'; const TEST_META_NAME_ATTRIBUTE = 'name'; const TEST_HOOK_NAMES = ["after", "before"]; + const TEST_MERGE_POINTER_BEFORE = "before"; + const TEST_MERGE_POINTER_AFTER = "after"; /** * TestDom constructor. @@ -63,6 +65,23 @@ public function initDom($xml, $filename = null, $exceptionCollector = null) /** @var \DOMElement $testNode */ $testNode->setAttribute(self::TEST_META_FILENAME_ATTRIBUTE, $filename); $this->validateDomStepKeys($testNode, $filename, 'Test', $exceptionCollector); + if ($testNode->getAttribute(self::TEST_MERGE_POINTER_AFTER) !== "") { + $this->appendMergePointerToActions( + $testNode, + self::TEST_MERGE_POINTER_AFTER, + $testNode->getAttribute(self::TEST_MERGE_POINTER_AFTER), + $filename, + $exceptionCollector + ); + } elseif ($testNode->getAttribute(self::TEST_MERGE_POINTER_BEFORE) !== "") { + $this->appendMergePointerToActions( + $testNode, + self::TEST_MERGE_POINTER_BEFORE, + $testNode->getAttribute(self::TEST_MERGE_POINTER_BEFORE), + $filename, + $exceptionCollector + ); + } } } @@ -83,6 +102,36 @@ public function merge($xml, $filename = null, $exceptionCollector = null) $this->mergeNode($dom->documentElement, ''); } + /** + * Parses DOM Structure's actions and appends a before/after attribute along with the parent's stepkey reference. + * + * @param \DOMElement $testNode + * @param string $pointerType + * @param string $pointerKey + * @param string $filename + * @param ExceptionCollector $exceptionCollector + * @return void + */ + protected function appendMergePointerToActions($testNode, $pointerType, $pointerKey, $filename, $exceptionCollector) + { + $childNodes = $testNode->childNodes; + for ($i = 0; $i < $childNodes->length; $i++) { + $currentNode = $childNodes->item($i); + if (!is_a($currentNode, \DOMElement::class)) { + continue; + } + if ($currentNode->hasAttribute('stepKey')) { + if ($currentNode->hasAttribute($pointerType) && $testNode->hasAttribute($pointerType)) { + $errorMsg = "Actions cannot have a before/after pointer if they are in a test that provides a merge pointer."; + $errorMsg .= "\n\tstepKey: {$currentNode->getAttribute('stepKey')}\tin file: {$filename}"; + $exceptionCollector->addError($filename, $errorMsg); + continue; + } + $currentNode->setAttribute($pointerType, $pointerKey); + } + } + } + /** * Parses an individual DOM structure for repeated stepKey attributes * diff --git a/src/Magento/FunctionalTestingFramework/Test/Util/ActionMergeUtil.php b/src/Magento/FunctionalTestingFramework/Test/Util/ActionMergeUtil.php index 8af5e3af0..51dea1893 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Util/ActionMergeUtil.php +++ b/src/Magento/FunctionalTestingFramework/Test/Util/ActionMergeUtil.php @@ -18,7 +18,7 @@ class ActionMergeUtil { const STEP_MISSING_ERROR_MSG = "Merge Error - Step could not be found in either TestXML or DeltaXML. - \t%s = '%s'\tTestStep='%s'\tLinkedStep'%s'"; + \t%s: '%s'\tTestStep: '%s'\tLinkedStep: '%s'"; const WAIT_ATTR = 'timeout'; const WAIT_ACTION_NAME = 'waitForPageLoad'; diff --git a/src/Magento/FunctionalTestingFramework/Test/Util/TestObjectExtractor.php b/src/Magento/FunctionalTestingFramework/Test/Util/TestObjectExtractor.php index be4e3c97c..cfe603a5f 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Util/TestObjectExtractor.php +++ b/src/Magento/FunctionalTestingFramework/Test/Util/TestObjectExtractor.php @@ -21,6 +21,8 @@ class TestObjectExtractor extends BaseObjectExtractor const TEST_BEFORE_HOOK = 'before'; const TEST_AFTER_HOOK = 'after'; const TEST_FAILED_HOOK = 'failed'; + const TEST_BEFORE_ATTRIBUTE = 'before'; + const TEST_AFTER_ATTRIBUTE = 'after'; /** * Action Object Extractor object @@ -85,7 +87,7 @@ public function extractTestData($testData) } // extract before - if (array_key_exists(self::TEST_BEFORE_HOOK, $testData)) { + if (array_key_exists(self::TEST_BEFORE_HOOK, $testData) && is_array($testData[self::TEST_BEFORE_HOOK])) { $testHooks[self::TEST_BEFORE_HOOK] = $this->testHookObjectExtractor->extractHook( $testData[self::NAME], 'before', @@ -93,7 +95,7 @@ public function extractTestData($testData) ); } - if (array_key_exists(self::TEST_AFTER_HOOK, $testData)) { + if (array_key_exists(self::TEST_AFTER_HOOK, $testData) && is_array($testData[self::TEST_AFTER_HOOK])) { // extract after $testHooks[self::TEST_AFTER_HOOK] = $this->testHookObjectExtractor->extractHook( $testData[self::NAME], diff --git a/src/Magento/FunctionalTestingFramework/Test/etc/mergedTestSchema.xsd b/src/Magento/FunctionalTestingFramework/Test/etc/mergedTestSchema.xsd index 012083ab8..125bd8baf 100644 --- a/src/Magento/FunctionalTestingFramework/Test/etc/mergedTestSchema.xsd +++ b/src/Magento/FunctionalTestingFramework/Test/etc/mergedTestSchema.xsd @@ -70,6 +70,8 @@ + + From ff0fbc2e6bdf1190d491cca3d5f2cb25cfd5d1a0 Mon Sep 17 00:00:00 2001 From: KevinBKozan Date: Tue, 1 May 2018 15:37:48 -0500 Subject: [PATCH 2/8] MQE-812: Tests/Action Groups should infer order based on the top level argument - static check fix. --- src/Magento/FunctionalTestingFramework/Test/Config/Dom.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Magento/FunctionalTestingFramework/Test/Config/Dom.php b/src/Magento/FunctionalTestingFramework/Test/Config/Dom.php index 3d8c2c4ba..4c2c9e4e0 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Config/Dom.php +++ b/src/Magento/FunctionalTestingFramework/Test/Config/Dom.php @@ -122,7 +122,7 @@ protected function appendMergePointerToActions($testNode, $pointerType, $pointer } if ($currentNode->hasAttribute('stepKey')) { if ($currentNode->hasAttribute($pointerType) && $testNode->hasAttribute($pointerType)) { - $errorMsg = "Actions cannot have a before/after pointer if they are in a test that provides a merge pointer."; + $errorMsg = "Actions cannot have merge pointers if contained in tests that has a merge pointer."; $errorMsg .= "\n\tstepKey: {$currentNode->getAttribute('stepKey')}\tin file: {$filename}"; $exceptionCollector->addError($filename, $errorMsg); continue; From c030dccb57d5b0ed91280635fcccce85e16965cb Mon Sep 17 00:00:00 2001 From: KevinBKozan Date: Wed, 2 May 2018 11:16:42 -0500 Subject: [PATCH 3/8] MQE-812: Tests/Action Groups should infer order based on the top level argument - updated ActionGroups to work with this - need verification tests still --- .../Test/Config/ActionGroupDom.php | 18 +++++++++++++++++- .../Test/Config/Dom.php | 4 ++-- .../Test/Util/ActionGroupObjectExtractor.php | 6 +++++- .../Test/Util/TestObjectExtractor.php | 7 ++++++- .../Test/etc/actionGroupSchema.xsd | 2 ++ .../Test/etc/mergedTestSchema.xsd | 4 ++-- 6 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Test/Config/ActionGroupDom.php b/src/Magento/FunctionalTestingFramework/Test/Config/ActionGroupDom.php index 794007dde..bfe1c243f 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Config/ActionGroupDom.php +++ b/src/Magento/FunctionalTestingFramework/Test/Config/ActionGroupDom.php @@ -30,9 +30,25 @@ public function initDom($xml, $filename = null, $exceptionCollector = null) /** @var \DOMElement $actionGroupNode */ $actionGroupNode->setAttribute(self::TEST_META_FILENAME_ATTRIBUTE, $filename); $this->validateDomStepKeys($actionGroupNode, $filename, 'Action Group', $exceptionCollector); + if ($actionGroupNode->getAttribute(self::TEST_MERGE_POINTER_AFTER) !== "") { + $this->appendMergePointerToActions( + $actionGroupNode, + self::TEST_MERGE_POINTER_AFTER, + $actionGroupNode->getAttribute(self::TEST_MERGE_POINTER_AFTER), + $filename, + $exceptionCollector + ); + } elseif ($actionGroupNode->getAttribute(self::TEST_MERGE_POINTER_BEFORE) !== "") { + $this->appendMergePointerToActions( + $actionGroupNode, + self::TEST_MERGE_POINTER_BEFORE, + $actionGroupNode->getAttribute(self::TEST_MERGE_POINTER_BEFORE), + $filename, + $exceptionCollector + ); + } } } - return $dom; } } diff --git a/src/Magento/FunctionalTestingFramework/Test/Config/Dom.php b/src/Magento/FunctionalTestingFramework/Test/Config/Dom.php index 4c2c9e4e0..ffb1e79be 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Config/Dom.php +++ b/src/Magento/FunctionalTestingFramework/Test/Config/Dom.php @@ -17,8 +17,8 @@ class Dom extends \Magento\FunctionalTestingFramework\Config\Dom const TEST_META_FILENAME_ATTRIBUTE = 'filename'; const TEST_META_NAME_ATTRIBUTE = 'name'; const TEST_HOOK_NAMES = ["after", "before"]; - const TEST_MERGE_POINTER_BEFORE = "before"; - const TEST_MERGE_POINTER_AFTER = "after"; + const TEST_MERGE_POINTER_BEFORE = "insertBefore"; + const TEST_MERGE_POINTER_AFTER = "insertAfter"; /** * TestDom constructor. diff --git a/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php b/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php index aeef21760..783fb1c5a 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php +++ b/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php @@ -18,6 +18,8 @@ class ActionGroupObjectExtractor extends BaseObjectExtractor const DEFAULT_VALUE = 'defaultValue'; const ACTION_GROUP_ARGUMENTS = 'arguments'; const FILENAME = 'filename'; + const ACTION_GROUP_INSERT_BEFORE = "insertBefore"; + const ACTION_GROUP_INSERT_AFTER = "insertAfter"; /** * Action Object Extractor for converting actions into objects @@ -49,7 +51,9 @@ public function extractActionGroup($actionGroupData) self::NODE_NAME, self::ACTION_GROUP_ARGUMENTS, self::NAME, - self::FILENAME + self::FILENAME, + self::ACTION_GROUP_INSERT_BEFORE, + self::ACTION_GROUP_INSERT_AFTER ); // TODO filename is now available to the ActionGroupObject, integrate this into debug and error statements diff --git a/src/Magento/FunctionalTestingFramework/Test/Util/TestObjectExtractor.php b/src/Magento/FunctionalTestingFramework/Test/Util/TestObjectExtractor.php index cfe603a5f..d96170c0d 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Util/TestObjectExtractor.php +++ b/src/Magento/FunctionalTestingFramework/Test/Util/TestObjectExtractor.php @@ -23,6 +23,9 @@ class TestObjectExtractor extends BaseObjectExtractor const TEST_FAILED_HOOK = 'failed'; const TEST_BEFORE_ATTRIBUTE = 'before'; const TEST_AFTER_ATTRIBUTE = 'after'; + const TEST_INSERT_BEFORE = 'insertBefore'; + const TEST_INSERT_AFTER = 'insertAfter'; + const TEST_FILENAME = 'filename'; /** * Action Object Extractor object @@ -79,7 +82,9 @@ public function extractTestData($testData) self::TEST_BEFORE_HOOK, self::TEST_AFTER_HOOK, self::TEST_FAILED_HOOK, - 'filename' + self::TEST_INSERT_BEFORE, + self::TEST_INSERT_AFTER, + self::TEST_FILENAME ); if (array_key_exists(self::TEST_ANNOTATIONS, $testData)) { diff --git a/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd b/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd index 74badd40c..5df793643 100644 --- a/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd +++ b/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd @@ -33,6 +33,8 @@ + + diff --git a/src/Magento/FunctionalTestingFramework/Test/etc/mergedTestSchema.xsd b/src/Magento/FunctionalTestingFramework/Test/etc/mergedTestSchema.xsd index 125bd8baf..ecd058581 100644 --- a/src/Magento/FunctionalTestingFramework/Test/etc/mergedTestSchema.xsd +++ b/src/Magento/FunctionalTestingFramework/Test/etc/mergedTestSchema.xsd @@ -70,8 +70,8 @@ - - + + From b350296881509879682a3147b56774f4ae94be5e Mon Sep 17 00:00:00 2001 From: KevinBKozan Date: Wed, 2 May 2018 14:34:08 -0500 Subject: [PATCH 4/8] MQE-812: Tests/Action Groups should infer order based on the top level argument - verification updates - dom.php refactor and fixes. --- .../Resources/MergeMassViaInsertAfter.txt | 37 +++++++++++++++++++ .../Resources/MergeMassViaInsertBefore.txt | 37 +++++++++++++++++++ .../ActionGroup/FunctionalActionGroup.xml | 10 +++++ .../MergeFunctionalActionGroup.xml | 12 ++++++ .../Test/ActionGroupFunctionalTest.xml | 6 +++ .../TestModule/Test/BasicFunctionalTest.xml | 10 +++++ .../TestModule/Test/MergeFunctionalTest.xml | 10 +++++ .../Tests/ActionGroupMergeGenerationTest.php | 22 +++++++++++ .../Tests/MergedGenerationTest.php | 22 +++++++++++ .../Test/Config/Dom.php | 20 +++++++--- 10 files changed, 180 insertions(+), 6 deletions(-) create mode 100644 dev/tests/verification/Resources/MergeMassViaInsertAfter.txt create mode 100644 dev/tests/verification/Resources/MergeMassViaInsertBefore.txt diff --git a/dev/tests/verification/Resources/MergeMassViaInsertAfter.txt b/dev/tests/verification/Resources/MergeMassViaInsertAfter.txt new file mode 100644 index 000000000..f44f58e42 --- /dev/null +++ b/dev/tests/verification/Resources/MergeMassViaInsertAfter.txt @@ -0,0 +1,37 @@ +fillField("#foo", "foo"); + $I->fillField("#bar", "bar"); + $I->click("#mergeOne"); + $I->click("#mergeTwo"); + $I->click("#mergeThree"); + $I->fillField("#baz", "baz"); + } +} diff --git a/dev/tests/verification/Resources/MergeMassViaInsertBefore.txt b/dev/tests/verification/Resources/MergeMassViaInsertBefore.txt new file mode 100644 index 000000000..2385eda39 --- /dev/null +++ b/dev/tests/verification/Resources/MergeMassViaInsertBefore.txt @@ -0,0 +1,37 @@ +fillField("#foo", "foo"); + $I->click("#mergeOne"); + $I->click("#mergeTwo"); + $I->click("#mergeThree"); + $I->fillField("#bar", "bar"); + $I->fillField("#baz", "baz"); + } +} diff --git a/dev/tests/verification/TestModule/ActionGroup/FunctionalActionGroup.xml b/dev/tests/verification/TestModule/ActionGroup/FunctionalActionGroup.xml index 843c66739..1afc847a6 100644 --- a/dev/tests/verification/TestModule/ActionGroup/FunctionalActionGroup.xml +++ b/dev/tests/verification/TestModule/ActionGroup/FunctionalActionGroup.xml @@ -50,4 +50,14 @@ + + + + + + + + + + diff --git a/dev/tests/verification/TestModule/ActionGroup/MergeFunctionalActionGroup.xml b/dev/tests/verification/TestModule/ActionGroup/MergeFunctionalActionGroup.xml index bd478e645..e993395c6 100644 --- a/dev/tests/verification/TestModule/ActionGroup/MergeFunctionalActionGroup.xml +++ b/dev/tests/verification/TestModule/ActionGroup/MergeFunctionalActionGroup.xml @@ -13,4 +13,16 @@ + + + + + + + + + + + + diff --git a/dev/tests/verification/TestModule/Test/ActionGroupFunctionalTest.xml b/dev/tests/verification/TestModule/Test/ActionGroupFunctionalTest.xml index ad372b838..03a71f056 100644 --- a/dev/tests/verification/TestModule/Test/ActionGroupFunctionalTest.xml +++ b/dev/tests/verification/TestModule/Test/ActionGroupFunctionalTest.xml @@ -182,4 +182,10 @@ + + + + + + diff --git a/dev/tests/verification/TestModule/Test/BasicFunctionalTest.xml b/dev/tests/verification/TestModule/Test/BasicFunctionalTest.xml index bd7c23522..92b04e0ad 100644 --- a/dev/tests/verification/TestModule/Test/BasicFunctionalTest.xml +++ b/dev/tests/verification/TestModule/Test/BasicFunctionalTest.xml @@ -119,4 +119,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/dev/tests/verification/TestModule/Test/MergeFunctionalTest.xml b/dev/tests/verification/TestModule/Test/MergeFunctionalTest.xml index 75c62b36f..553f3d251 100644 --- a/dev/tests/verification/TestModule/Test/MergeFunctionalTest.xml +++ b/dev/tests/verification/TestModule/Test/MergeFunctionalTest.xml @@ -45,4 +45,14 @@ + + + + + + + + + + diff --git a/dev/tests/verification/Tests/ActionGroupMergeGenerationTest.php b/dev/tests/verification/Tests/ActionGroupMergeGenerationTest.php index 9176f3955..0361bec75 100644 --- a/dev/tests/verification/Tests/ActionGroupMergeGenerationTest.php +++ b/dev/tests/verification/Tests/ActionGroupMergeGenerationTest.php @@ -108,4 +108,26 @@ public function testArgumentWithSameNameAsElement() { $this->generateAndCompareTest('ArgumentWithSameNameAsElement'); } + + /** + * Test an action group with a merge counterpart that's merged via insertBefore + * + * @throws \Exception + * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException + */ + public function testMergedActionGroupViaInsertBefore() + { + $this->generateAndCompareTest('ActionGroupMergedViaInsertBefore'); + } + + /** + * Test an action group with a merge counterpart that's merged via insertAfter + * + * @throws \Exception + * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException + */ + public function testMergedActionGroupViaInsertAfter() + { + $this->generateAndCompareTest('ActionGroupMergedViaInsertAfter'); + } } diff --git a/dev/tests/verification/Tests/MergedGenerationTest.php b/dev/tests/verification/Tests/MergedGenerationTest.php index fe2990b76..9ef22fe09 100644 --- a/dev/tests/verification/Tests/MergedGenerationTest.php +++ b/dev/tests/verification/Tests/MergedGenerationTest.php @@ -40,4 +40,26 @@ public function testParsedArray() $entity = DataObjectHandler::getInstance()->getObject('testEntity'); $this->assertCount(3, $entity->getLinkedEntities()); } + + /** + * Tests generation of a test merge file via insertBefore + * + * @throws \Exception + * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException + */ + public function testMergeMassViaInsertBefore() + { + $this->generateAndCompareTest('MergeMassViaInsertBefore'); + } + + /** + * Tests generation of a test merge file via insertBefore + * + * @throws \Exception + * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException + */ + public function testMergeMassViaInsertAfter() + { + $this->generateAndCompareTest('MergeMassViaInsertAfter'); + } } diff --git a/src/Magento/FunctionalTestingFramework/Test/Config/Dom.php b/src/Magento/FunctionalTestingFramework/Test/Config/Dom.php index ffb1e79be..ea516dd22 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Config/Dom.php +++ b/src/Magento/FunctionalTestingFramework/Test/Config/Dom.php @@ -10,6 +10,7 @@ use Magento\FunctionalTestingFramework\Exceptions\XmlException; use Magento\FunctionalTestingFramework\Config\Dom\NodeMergingConfig; use Magento\FunctionalTestingFramework\Config\Dom\NodePathMatcher; +use Magento\FunctionalTestingFramework\Test\Objects\ActionObject; class Dom extends \Magento\FunctionalTestingFramework\Config\Dom { @@ -106,28 +107,35 @@ public function merge($xml, $filename = null, $exceptionCollector = null) * Parses DOM Structure's actions and appends a before/after attribute along with the parent's stepkey reference. * * @param \DOMElement $testNode - * @param string $pointerType - * @param string $pointerKey + * @param string $insertType + * @param string $insertKey * @param string $filename * @param ExceptionCollector $exceptionCollector * @return void */ - protected function appendMergePointerToActions($testNode, $pointerType, $pointerKey, $filename, $exceptionCollector) + protected function appendMergePointerToActions($testNode, $insertType, $insertKey, $filename, $exceptionCollector) { $childNodes = $testNode->childNodes; + $previousStepKey = $insertKey; + $actionInsertType = ActionObject::MERGE_ACTION_ORDER_AFTER; + if ($insertType == self::TEST_MERGE_POINTER_BEFORE) { + $actionInsertType = ActionObject::MERGE_ACTION_ORDER_BEFORE; + } for ($i = 0; $i < $childNodes->length; $i++) { $currentNode = $childNodes->item($i); if (!is_a($currentNode, \DOMElement::class)) { continue; } if ($currentNode->hasAttribute('stepKey')) { - if ($currentNode->hasAttribute($pointerType) && $testNode->hasAttribute($pointerType)) { + if ($currentNode->hasAttribute($insertType) && $testNode->hasAttribute($insertType)) { $errorMsg = "Actions cannot have merge pointers if contained in tests that has a merge pointer."; $errorMsg .= "\n\tstepKey: {$currentNode->getAttribute('stepKey')}\tin file: {$filename}"; $exceptionCollector->addError($filename, $errorMsg); - continue; } - $currentNode->setAttribute($pointerType, $pointerKey); + $currentNode->setAttribute($actionInsertType, $previousStepKey); + $previousStepKey = $currentNode->getAttribute('stepKey'); + // All actions after the first need to insert AFTER. + $actionInsertType = ActionObject::MERGE_ACTION_ORDER_AFTER; } } } From a4249b50697a25b7be17239a210f586a5367051b Mon Sep 17 00:00:00 2001 From: KevinBKozan Date: Wed, 2 May 2018 15:23:55 -0500 Subject: [PATCH 5/8] MQE-812: Tests/Action Groups should infer order based on the top level argument - Fix to old verification tests, found and fixed a bug with old merging. - final test fixes. --- .../ActionGroupMergedViaInsertAfter.txt | 37 +++++++++++++++++++ .../ActionGroupMergedViaInsertBefore.txt | 37 +++++++++++++++++++ .../Resources/MergedActionGroupTest.txt | 4 +- .../Test/Objects/ActionGroupObject.php | 8 +++- 4 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 dev/tests/verification/Resources/ActionGroupMergedViaInsertAfter.txt create mode 100644 dev/tests/verification/Resources/ActionGroupMergedViaInsertBefore.txt diff --git a/dev/tests/verification/Resources/ActionGroupMergedViaInsertAfter.txt b/dev/tests/verification/Resources/ActionGroupMergedViaInsertAfter.txt new file mode 100644 index 000000000..63565d7f8 --- /dev/null +++ b/dev/tests/verification/Resources/ActionGroupMergedViaInsertAfter.txt @@ -0,0 +1,37 @@ +fillField("#foo", "foo"); + $I->fillField("#bar", "bar"); + $I->click("#mergeOne"); + $I->click("#mergeTwo"); + $I->click("#mergeThree"); + $I->fillField("#baz", "baz"); + } +} diff --git a/dev/tests/verification/Resources/ActionGroupMergedViaInsertBefore.txt b/dev/tests/verification/Resources/ActionGroupMergedViaInsertBefore.txt new file mode 100644 index 000000000..f44e15b4e --- /dev/null +++ b/dev/tests/verification/Resources/ActionGroupMergedViaInsertBefore.txt @@ -0,0 +1,37 @@ +fillField("#foo", "foo"); + $I->click("#mergeOne"); + $I->click("#mergeTwo"); + $I->click("#mergeThree"); + $I->fillField("#bar", "bar"); + $I->fillField("#baz", "baz"); + } +} diff --git a/dev/tests/verification/Resources/MergedActionGroupTest.txt b/dev/tests/verification/Resources/MergedActionGroupTest.txt index ab9b46f8d..cbaa87f7e 100644 --- a/dev/tests/verification/Resources/MergedActionGroupTest.txt +++ b/dev/tests/verification/Resources/MergedActionGroupTest.txt @@ -70,9 +70,9 @@ class MergedActionGroupTestCest */ public function MergedActionGroupTest(AcceptanceTester $I) { - $I->see("#element .Jane"); $I->see(".merge .Jane"); - $I->click(".merge .Dane"); + $I->see("#element .Jane"); $I->amOnPage("/Jane/Dane.html"); + $I->click(".merge .Dane"); } } diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php index fdef1107e..f1db6451a 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php @@ -136,6 +136,12 @@ private function getResolvedActionsWithArgs($arguments, $actionReferenceKey) ); } + // translate 0/1 back to before/after + $orderOffset = ActionObject::MERGE_ACTION_ORDER_BEFORE; + if ($action->getOrderOffset() === 1) { + $orderOffset = ActionObject::MERGE_ACTION_ORDER_AFTER; + } + // we append the action reference key to any linked action and the action's merge key as the user might // use this action group multiple times in the same test. $resolvedActions[$action->getStepKey() . ucfirst($actionReferenceKey)] = new ActionObject( @@ -143,7 +149,7 @@ private function getResolvedActionsWithArgs($arguments, $actionReferenceKey) $action->getType(), array_replace_recursive($action->getCustomActionAttributes(), $newActionAttributes), $action->getLinkedAction() == null ? null : $action->getLinkedAction() . ucfirst($actionReferenceKey), - $action->getOrderOffset(), + $orderOffset, [self::ACTION_GROUP_ORIGIN_NAME => $this->name, self::ACTION_GROUP_ORIGIN_TEST_REF => $actionReferenceKey] ); From ca7f802e74df22393ac472b0f5a93def50b9a78f Mon Sep 17 00:00:00 2001 From: KevinBKozan Date: Tue, 8 May 2018 08:48:45 -0500 Subject: [PATCH 6/8] MQE-812: Tests/Action Groups should infer order based on the top level argument - CR fixes --- .../ActionGroupMergedViaInsertAfter.txt | 6 +++--- .../ActionGroupMergedViaInsertBefore.txt | 6 +++--- .../MergeFunctionalActionGroup.xml | 12 +++++------ .../Test/Config/Dom.php | 20 +++++++++---------- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/dev/tests/verification/Resources/ActionGroupMergedViaInsertAfter.txt b/dev/tests/verification/Resources/ActionGroupMergedViaInsertAfter.txt index 63565d7f8..7422cbc26 100644 --- a/dev/tests/verification/Resources/ActionGroupMergedViaInsertAfter.txt +++ b/dev/tests/verification/Resources/ActionGroupMergedViaInsertAfter.txt @@ -29,9 +29,9 @@ class ActionGroupMergedViaInsertAfterCest { $I->fillField("#foo", "foo"); $I->fillField("#bar", "bar"); - $I->click("#mergeOne"); - $I->click("#mergeTwo"); - $I->click("#mergeThree"); + $I->click("#foo2"); + $I->click("#bar2"); + $I->click("#baz2"); $I->fillField("#baz", "baz"); } } diff --git a/dev/tests/verification/Resources/ActionGroupMergedViaInsertBefore.txt b/dev/tests/verification/Resources/ActionGroupMergedViaInsertBefore.txt index f44e15b4e..4a7dcf172 100644 --- a/dev/tests/verification/Resources/ActionGroupMergedViaInsertBefore.txt +++ b/dev/tests/verification/Resources/ActionGroupMergedViaInsertBefore.txt @@ -28,9 +28,9 @@ class ActionGroupMergedViaInsertBeforeCest public function ActionGroupMergedViaInsertBefore(AcceptanceTester $I) { $I->fillField("#foo", "foo"); - $I->click("#mergeOne"); - $I->click("#mergeTwo"); - $I->click("#mergeThree"); + $I->click("#foo2"); + $I->click("#bar2"); + $I->click("#baz2"); $I->fillField("#bar", "bar"); $I->fillField("#baz", "baz"); } diff --git a/dev/tests/verification/TestModule/ActionGroup/MergeFunctionalActionGroup.xml b/dev/tests/verification/TestModule/ActionGroup/MergeFunctionalActionGroup.xml index e993395c6..760853896 100644 --- a/dev/tests/verification/TestModule/ActionGroup/MergeFunctionalActionGroup.xml +++ b/dev/tests/verification/TestModule/ActionGroup/MergeFunctionalActionGroup.xml @@ -15,14 +15,14 @@ - - - + + + - - - + + + diff --git a/src/Magento/FunctionalTestingFramework/Test/Config/Dom.php b/src/Magento/FunctionalTestingFramework/Test/Config/Dom.php index ea516dd22..fb7b0a386 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Config/Dom.php +++ b/src/Magento/FunctionalTestingFramework/Test/Config/Dom.php @@ -123,20 +123,18 @@ protected function appendMergePointerToActions($testNode, $insertType, $insertKe } for ($i = 0; $i < $childNodes->length; $i++) { $currentNode = $childNodes->item($i); - if (!is_a($currentNode, \DOMElement::class)) { + if (!is_a($currentNode, \DOMElement::class) || !$currentNode->hasAttribute('stepKey')) { continue; } - if ($currentNode->hasAttribute('stepKey')) { - if ($currentNode->hasAttribute($insertType) && $testNode->hasAttribute($insertType)) { - $errorMsg = "Actions cannot have merge pointers if contained in tests that has a merge pointer."; - $errorMsg .= "\n\tstepKey: {$currentNode->getAttribute('stepKey')}\tin file: {$filename}"; - $exceptionCollector->addError($filename, $errorMsg); - } - $currentNode->setAttribute($actionInsertType, $previousStepKey); - $previousStepKey = $currentNode->getAttribute('stepKey'); - // All actions after the first need to insert AFTER. - $actionInsertType = ActionObject::MERGE_ACTION_ORDER_AFTER; + if ($currentNode->hasAttribute($insertType) && $testNode->hasAttribute($insertType)) { + $errorMsg = "Actions cannot have merge pointers if contained in tests that has a merge pointer."; + $errorMsg .= "\n\tstepKey: {$currentNode->getAttribute('stepKey')}\tin file: {$filename}"; + $exceptionCollector->addError($filename, $errorMsg); } + $currentNode->setAttribute($actionInsertType, $previousStepKey); + $previousStepKey = $currentNode->getAttribute('stepKey'); + // All actions after the first need to insert AFTER. + $actionInsertType = ActionObject::MERGE_ACTION_ORDER_AFTER; } } From c9fbac0ee15c2c3c19776ab62cf76001f920c7a1 Mon Sep 17 00:00:00 2001 From: KevinBKozan Date: Tue, 8 May 2018 09:44:08 -0500 Subject: [PATCH 7/8] MQE-812: Tests/Action Groups should infer order based on the top level argument - CR fix, data is now correct. --- .../TestModule/ActionGroup/MergeFunctionalActionGroup.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/tests/verification/TestModule/ActionGroup/MergeFunctionalActionGroup.xml b/dev/tests/verification/TestModule/ActionGroup/MergeFunctionalActionGroup.xml index 760853896..7d8585772 100644 --- a/dev/tests/verification/TestModule/ActionGroup/MergeFunctionalActionGroup.xml +++ b/dev/tests/verification/TestModule/ActionGroup/MergeFunctionalActionGroup.xml @@ -15,13 +15,13 @@ - + - + From b28252d9980df74fb7375e4919308c41cda8f01d Mon Sep 17 00:00:00 2001 From: aljcalandra Date: Mon, 14 May 2018 16:08:00 -0500 Subject: [PATCH 8/8] MQE-812: Tests/Action Groups should infer order based on the top level argument - Updated Verification Resources to reflect inclusion of Features annotation --- .../verification/Resources/ActionGroupMergedViaInsertAfter.txt | 1 + .../verification/Resources/ActionGroupMergedViaInsertBefore.txt | 1 + dev/tests/verification/Resources/MergeMassViaInsertAfter.txt | 1 + dev/tests/verification/Resources/MergeMassViaInsertBefore.txt | 1 + 4 files changed, 4 insertions(+) diff --git a/dev/tests/verification/Resources/ActionGroupMergedViaInsertAfter.txt b/dev/tests/verification/Resources/ActionGroupMergedViaInsertAfter.txt index 7422cbc26..a62548ccc 100644 --- a/dev/tests/verification/Resources/ActionGroupMergedViaInsertAfter.txt +++ b/dev/tests/verification/Resources/ActionGroupMergedViaInsertAfter.txt @@ -20,6 +20,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; class ActionGroupMergedViaInsertAfterCest { /** + * @Features({"TestModule"}) * @Parameter(name = "AcceptanceTester", value="$I") * @param AcceptanceTester $I * @return void diff --git a/dev/tests/verification/Resources/ActionGroupMergedViaInsertBefore.txt b/dev/tests/verification/Resources/ActionGroupMergedViaInsertBefore.txt index 4a7dcf172..504ca8120 100644 --- a/dev/tests/verification/Resources/ActionGroupMergedViaInsertBefore.txt +++ b/dev/tests/verification/Resources/ActionGroupMergedViaInsertBefore.txt @@ -20,6 +20,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; class ActionGroupMergedViaInsertBeforeCest { /** + * @Features({"TestModule"}) * @Parameter(name = "AcceptanceTester", value="$I") * @param AcceptanceTester $I * @return void diff --git a/dev/tests/verification/Resources/MergeMassViaInsertAfter.txt b/dev/tests/verification/Resources/MergeMassViaInsertAfter.txt index f44f58e42..9ffc3d452 100644 --- a/dev/tests/verification/Resources/MergeMassViaInsertAfter.txt +++ b/dev/tests/verification/Resources/MergeMassViaInsertAfter.txt @@ -20,6 +20,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; class MergeMassViaInsertAfterCest { /** + * @Features({"TestModule"}) * @Parameter(name = "AcceptanceTester", value="$I") * @param AcceptanceTester $I * @return void diff --git a/dev/tests/verification/Resources/MergeMassViaInsertBefore.txt b/dev/tests/verification/Resources/MergeMassViaInsertBefore.txt index 2385eda39..a830c218c 100644 --- a/dev/tests/verification/Resources/MergeMassViaInsertBefore.txt +++ b/dev/tests/verification/Resources/MergeMassViaInsertBefore.txt @@ -20,6 +20,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; class MergeMassViaInsertBeforeCest { /** + * @Features({"TestModule"}) * @Parameter(name = "AcceptanceTester", value="$I") * @param AcceptanceTester $I * @return void