Skip to content

Commit 15d7407

Browse files
authored
Merge pull request #126 from magento/MQE-812
MQE-812: Tests/Action Groups should infer order based on the top level argument
2 parents 48bbdb6 + b28252d commit 15d7407

20 files changed

+345
-9
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
namespace Magento\AcceptanceTest\_default\Backend;
3+
4+
use Magento\FunctionalTestingFramework\AcceptanceTester;
5+
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;
6+
use Magento\FunctionalTestingFramework\DataGenerator\Persist\DataPersistenceHandler;
7+
use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
8+
use \Codeception\Util\Locator;
9+
use Yandex\Allure\Adapter\Annotation\Features;
10+
use Yandex\Allure\Adapter\Annotation\Stories;
11+
use Yandex\Allure\Adapter\Annotation\Title;
12+
use Yandex\Allure\Adapter\Annotation\Description;
13+
use Yandex\Allure\Adapter\Annotation\Parameter;
14+
use Yandex\Allure\Adapter\Annotation\Severity;
15+
use Yandex\Allure\Adapter\Model\SeverityLevel;
16+
use Yandex\Allure\Adapter\Annotation\TestCaseId;
17+
18+
/**
19+
*/
20+
class ActionGroupMergedViaInsertAfterCest
21+
{
22+
/**
23+
* @Features({"TestModule"})
24+
* @Parameter(name = "AcceptanceTester", value="$I")
25+
* @param AcceptanceTester $I
26+
* @return void
27+
* @throws \Exception
28+
*/
29+
public function ActionGroupMergedViaInsertAfter(AcceptanceTester $I)
30+
{
31+
$I->fillField("#foo", "foo");
32+
$I->fillField("#bar", "bar");
33+
$I->click("#foo2");
34+
$I->click("#bar2");
35+
$I->click("#baz2");
36+
$I->fillField("#baz", "baz");
37+
}
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
namespace Magento\AcceptanceTest\_default\Backend;
3+
4+
use Magento\FunctionalTestingFramework\AcceptanceTester;
5+
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;
6+
use Magento\FunctionalTestingFramework\DataGenerator\Persist\DataPersistenceHandler;
7+
use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
8+
use \Codeception\Util\Locator;
9+
use Yandex\Allure\Adapter\Annotation\Features;
10+
use Yandex\Allure\Adapter\Annotation\Stories;
11+
use Yandex\Allure\Adapter\Annotation\Title;
12+
use Yandex\Allure\Adapter\Annotation\Description;
13+
use Yandex\Allure\Adapter\Annotation\Parameter;
14+
use Yandex\Allure\Adapter\Annotation\Severity;
15+
use Yandex\Allure\Adapter\Model\SeverityLevel;
16+
use Yandex\Allure\Adapter\Annotation\TestCaseId;
17+
18+
/**
19+
*/
20+
class ActionGroupMergedViaInsertBeforeCest
21+
{
22+
/**
23+
* @Features({"TestModule"})
24+
* @Parameter(name = "AcceptanceTester", value="$I")
25+
* @param AcceptanceTester $I
26+
* @return void
27+
* @throws \Exception
28+
*/
29+
public function ActionGroupMergedViaInsertBefore(AcceptanceTester $I)
30+
{
31+
$I->fillField("#foo", "foo");
32+
$I->click("#foo2");
33+
$I->click("#bar2");
34+
$I->click("#baz2");
35+
$I->fillField("#bar", "bar");
36+
$I->fillField("#baz", "baz");
37+
}
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
namespace Magento\AcceptanceTest\_default\Backend;
3+
4+
use Magento\FunctionalTestingFramework\AcceptanceTester;
5+
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;
6+
use Magento\FunctionalTestingFramework\DataGenerator\Persist\DataPersistenceHandler;
7+
use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
8+
use \Codeception\Util\Locator;
9+
use Yandex\Allure\Adapter\Annotation\Features;
10+
use Yandex\Allure\Adapter\Annotation\Stories;
11+
use Yandex\Allure\Adapter\Annotation\Title;
12+
use Yandex\Allure\Adapter\Annotation\Description;
13+
use Yandex\Allure\Adapter\Annotation\Parameter;
14+
use Yandex\Allure\Adapter\Annotation\Severity;
15+
use Yandex\Allure\Adapter\Model\SeverityLevel;
16+
use Yandex\Allure\Adapter\Annotation\TestCaseId;
17+
18+
/**
19+
*/
20+
class MergeMassViaInsertAfterCest
21+
{
22+
/**
23+
* @Features({"TestModule"})
24+
* @Parameter(name = "AcceptanceTester", value="$I")
25+
* @param AcceptanceTester $I
26+
* @return void
27+
* @throws \Exception
28+
*/
29+
public function MergeMassViaInsertAfter(AcceptanceTester $I)
30+
{
31+
$I->fillField("#foo", "foo");
32+
$I->fillField("#bar", "bar");
33+
$I->click("#mergeOne");
34+
$I->click("#mergeTwo");
35+
$I->click("#mergeThree");
36+
$I->fillField("#baz", "baz");
37+
}
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
namespace Magento\AcceptanceTest\_default\Backend;
3+
4+
use Magento\FunctionalTestingFramework\AcceptanceTester;
5+
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;
6+
use Magento\FunctionalTestingFramework\DataGenerator\Persist\DataPersistenceHandler;
7+
use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
8+
use \Codeception\Util\Locator;
9+
use Yandex\Allure\Adapter\Annotation\Features;
10+
use Yandex\Allure\Adapter\Annotation\Stories;
11+
use Yandex\Allure\Adapter\Annotation\Title;
12+
use Yandex\Allure\Adapter\Annotation\Description;
13+
use Yandex\Allure\Adapter\Annotation\Parameter;
14+
use Yandex\Allure\Adapter\Annotation\Severity;
15+
use Yandex\Allure\Adapter\Model\SeverityLevel;
16+
use Yandex\Allure\Adapter\Annotation\TestCaseId;
17+
18+
/**
19+
*/
20+
class MergeMassViaInsertBeforeCest
21+
{
22+
/**
23+
* @Features({"TestModule"})
24+
* @Parameter(name = "AcceptanceTester", value="$I")
25+
* @param AcceptanceTester $I
26+
* @return void
27+
* @throws \Exception
28+
*/
29+
public function MergeMassViaInsertBefore(AcceptanceTester $I)
30+
{
31+
$I->fillField("#foo", "foo");
32+
$I->click("#mergeOne");
33+
$I->click("#mergeTwo");
34+
$I->click("#mergeThree");
35+
$I->fillField("#bar", "bar");
36+
$I->fillField("#baz", "baz");
37+
}
38+
}

dev/tests/verification/Resources/MergedActionGroupTest.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ class MergedActionGroupTestCest
7070
*/
7171
public function MergedActionGroupTest(AcceptanceTester $I)
7272
{
73-
$I->see("#element .Jane");
7473
$I->see(".merge .Jane");
75-
$I->click(".merge .Dane");
74+
$I->see("#element .Jane");
7675
$I->amOnPage("/Jane/Dane.html");
76+
$I->click(".merge .Dane");
7777
}
7878
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@
5050
<grabTextFrom selector=".class" stepKey="grabTextData"/>
5151
<fillField stepKey="fill1" selector=".{$grabTextData}" userInput="$createSimpleData.field$"/>
5252
</actionGroup>
53+
<actionGroup name="FunctionalActionGroupForMassMergeBefore">
54+
<fillField selector="#foo" userInput="foo" stepKey="fillField1"/>
55+
<fillField selector="#bar" userInput="bar" stepKey="fillField2"/>
56+
<fillField selector="#baz" userInput="baz" stepKey="fillField3"/>
57+
</actionGroup>
58+
<actionGroup name="FunctionalActionGroupForMassMergeAfter">
59+
<fillField selector="#foo" userInput="foo" stepKey="fillField1"/>
60+
<fillField selector="#bar" userInput="bar" stepKey="fillField2"/>
61+
<fillField selector="#baz" userInput="baz" stepKey="fillField3"/>
62+
</actionGroup>
5363
<actionGroup name="FunctionalActionGroupWithXmlAndPersistedData">
5464
<arguments>
5565
<argument name="xmlData" defaultValue="uniqueData"/>

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,16 @@
1313
<click stepKey="myMergedClick" selector=".merge .{{myArg.lastname}}" after="amOnPage1"/>
1414
<remove keyForRemoval="deleteMe"/>
1515
</actionGroup>
16+
17+
<actionGroup name="FunctionalActionGroupForMassMergeBefore" insertBefore="fillField2">
18+
<click stepKey="mergeBeforeBar" selector="#foo2"/>
19+
<click stepKey="mergeAfterFoo2" selector="#bar2"/>
20+
<click stepKey="mergeAfterBar2" selector="#baz2"/>
21+
</actionGroup>
22+
23+
<actionGroup name="FunctionalActionGroupForMassMergeAfter" insertAfter="fillField2">
24+
<click stepKey="mergeAfterBar" selector="#foo2"/>
25+
<click stepKey="mergeAfterFoo2" selector="#bar2"/>
26+
<click stepKey="mergeAfterBar2" selector="#baz2"/>
27+
</actionGroup>
1628
</actionGroups>

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,12 @@
182182
<actionGroup ref="FunctionalActionGroup" stepKey="afterGroup"/>
183183
</after>
184184
</test>
185+
<test name="ActionGroupMergedViaInsertBefore">
186+
<actionGroup ref="FunctionalActionGroupForMassMergeBefore" stepKey="keyone"/>
187+
</test>
188+
<test name="ActionGroupMergedViaInsertAfter">
189+
<actionGroup ref="FunctionalActionGroupForMassMergeAfter" stepKey="keyone"/>
190+
</test>
185191
<test name="PersistedAndXmlEntityArguments">
186192
<actionGroup ref="FunctionalActionGroupWithXmlAndPersistedData" stepKey="afterGroup">
187193
<argument name="persistedData" value="$persistedInTest$"/>

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,14 @@
119119
<waitForJS function="someJsFunction" time="30" stepKey="waitForJSKey1" />
120120
<waitForText selector=".functionalTestSelector" userInput="someInput" time="30" stepKey="waitForText1"/>
121121
</test>
122+
<test name="MergeMassViaInsertBefore">
123+
<fillField selector="#foo" userInput="foo" stepKey="fillField1"/>
124+
<fillField selector="#bar" userInput="bar" stepKey="fillField2"/>
125+
<fillField selector="#baz" userInput="baz" stepKey="fillField3"/>
126+
</test>
127+
<test name="MergeMassViaInsertAfter">
128+
<fillField selector="#foo" userInput="foo" stepKey="fillField1"/>
129+
<fillField selector="#bar" userInput="bar" stepKey="fillField2"/>
130+
<fillField selector="#baz" userInput="baz" stepKey="fillField3"/>
131+
</test>
122132
</tests>

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,14 @@
4545
<fillField stepKey="fillField1" selector="{{SampleSection.mergeElement}}" userInput="{{DefaultPerson.mergedField}}"/>
4646
<fillField stepKey="fillField2" selector="{{SampleSection.newElement}}" userInput="{{DefaultPerson.newField}}" />
4747
</test>
48+
<test name="MergeMassViaInsertBefore" insertBefore="fillField2">
49+
<click stepKey="clickOne" selector="#mergeOne"/>
50+
<click stepKey="clickTwo" selector="#mergeTwo"/>
51+
<click stepKey="clickThree" selector="#mergeThree"/>
52+
</test>
53+
<test name="MergeMassViaInsertAfter" insertAfter="fillField2">
54+
<click stepKey="clickOne" selector="#mergeOne"/>
55+
<click stepKey="clickTwo" selector="#mergeTwo"/>
56+
<click stepKey="clickThree" selector="#mergeThree"/>
57+
</test>
4858
</tests>

dev/tests/verification/Tests/ActionGroupMergeGenerationTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,26 @@ public function testArgumentWithSameNameAsElement()
108108
{
109109
$this->generateAndCompareTest('ArgumentWithSameNameAsElement');
110110
}
111+
112+
/**
113+
* Test an action group with a merge counterpart that's merged via insertBefore
114+
*
115+
* @throws \Exception
116+
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
117+
*/
118+
public function testMergedActionGroupViaInsertBefore()
119+
{
120+
$this->generateAndCompareTest('ActionGroupMergedViaInsertBefore');
121+
}
122+
123+
/**
124+
* Test an action group with a merge counterpart that's merged via insertAfter
125+
*
126+
* @throws \Exception
127+
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
128+
*/
129+
public function testMergedActionGroupViaInsertAfter()
130+
{
131+
$this->generateAndCompareTest('ActionGroupMergedViaInsertAfter');
132+
}
111133
}

dev/tests/verification/Tests/MergedGenerationTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,26 @@ public function testParsedArray()
4040
$entity = DataObjectHandler::getInstance()->getObject('testEntity');
4141
$this->assertCount(3, $entity->getLinkedEntities());
4242
}
43+
44+
/**
45+
* Tests generation of a test merge file via insertBefore
46+
*
47+
* @throws \Exception
48+
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
49+
*/
50+
public function testMergeMassViaInsertBefore()
51+
{
52+
$this->generateAndCompareTest('MergeMassViaInsertBefore');
53+
}
54+
55+
/**
56+
* Tests generation of a test merge file via insertBefore
57+
*
58+
* @throws \Exception
59+
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
60+
*/
61+
public function testMergeMassViaInsertAfter()
62+
{
63+
$this->generateAndCompareTest('MergeMassViaInsertAfter');
64+
}
4365
}

src/Magento/FunctionalTestingFramework/Test/Config/ActionGroupDom.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,25 @@ public function initDom($xml, $filename = null, $exceptionCollector = null)
3030
/** @var \DOMElement $actionGroupNode */
3131
$actionGroupNode->setAttribute(self::TEST_META_FILENAME_ATTRIBUTE, $filename);
3232
$this->validateDomStepKeys($actionGroupNode, $filename, 'Action Group', $exceptionCollector);
33+
if ($actionGroupNode->getAttribute(self::TEST_MERGE_POINTER_AFTER) !== "") {
34+
$this->appendMergePointerToActions(
35+
$actionGroupNode,
36+
self::TEST_MERGE_POINTER_AFTER,
37+
$actionGroupNode->getAttribute(self::TEST_MERGE_POINTER_AFTER),
38+
$filename,
39+
$exceptionCollector
40+
);
41+
} elseif ($actionGroupNode->getAttribute(self::TEST_MERGE_POINTER_BEFORE) !== "") {
42+
$this->appendMergePointerToActions(
43+
$actionGroupNode,
44+
self::TEST_MERGE_POINTER_BEFORE,
45+
$actionGroupNode->getAttribute(self::TEST_MERGE_POINTER_BEFORE),
46+
$filename,
47+
$exceptionCollector
48+
);
49+
}
3350
}
3451
}
35-
3652
return $dom;
3753
}
3854
}

0 commit comments

Comments
 (0)