Skip to content

Commit 858bf21

Browse files
authored
Merge pull request #8 from magento-pangolin/bug-fixed-develop
[Pangolin] Requested bug fixes
2 parents 5232d92 + 892b1fb commit 858bf21

File tree

11 files changed

+322
-48
lines changed

11 files changed

+322
-48
lines changed

dev/tests/verification/Resources/BasicFunctionalCest.txt

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class BasicFunctionalCest
7575
$I->dragAndDrop(".functionalTestSelector", ".functionalTestSelector2");
7676
$I->executeJS("someJSFunction");
7777
$I->fillField(".functionalTestSelector", "someInput");
78+
$I->fillField(".functionalTestSelector", "0");
7879
$grabAttributeVar = $I->grabAttributeFrom(".functionalTestSelector", "someInput");
7980
$grabCookieVar = $I->grabCookie("grabCookieInput", ['domain' => 'www.google.com']);
8081
$grabUrlVar = $I->grabFromCurrentUrl("/grabCurrentUrl");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
namespace Magento\AcceptanceTest\_generated\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 Yandex\Allure\Adapter\Annotation\Features;
9+
use Yandex\Allure\Adapter\Annotation\Stories;
10+
use Yandex\Allure\Adapter\Annotation\Title;
11+
use Yandex\Allure\Adapter\Annotation\Description;
12+
use Yandex\Allure\Adapter\Annotation\Parameter;
13+
use Yandex\Allure\Adapter\Annotation\Severity;
14+
use Yandex\Allure\Adapter\Model\SeverityLevel;
15+
use Yandex\Allure\Adapter\Annotation\TestCaseId;
16+
17+
/**
18+
*/
19+
class PersistedReplacementCest
20+
{
21+
/**
22+
* @var DataPersistenceHandler $createData1;
23+
*/
24+
protected $createData1;
25+
26+
public function _before(AcceptanceTester $I)
27+
{
28+
$I->amGoingTo("create entity that has the mergeKey: createData1");
29+
$replacementPerson = DataObjectHandler::getInstance()->getObject("replacementPerson");
30+
$this->createData1 = new DataPersistenceHandler($replacementPerson);
31+
$this->createData1->createEntity();
32+
}
33+
34+
/**
35+
* @Parameter(name = "AcceptanceTester", value="$I")
36+
* @param AcceptanceTester $I
37+
* @return void
38+
*/
39+
public function PersistedReplacementTest(AcceptanceTester $I)
40+
{
41+
$I->amGoingTo("create entity that has the mergeKey: testScopeData");
42+
$replacementPerson = DataObjectHandler::getInstance()->getObject("replacementPerson");
43+
$testScopeData = new DataPersistenceHandler($replacementPerson);
44+
$testScopeData->createEntity();
45+
$I->amGoingTo("create entity that has the mergeKey: uniqueData");
46+
$uniquePerson = DataObjectHandler::getInstance()->getObject("uniquePerson");
47+
$uniqueData = new DataPersistenceHandler($uniquePerson);
48+
$uniqueData->createEntity();
49+
$I->amOnPage("/success/success2.html");
50+
$I->amOnPage($testScopeData->getCreatedDataByName('firstname') . ".html");
51+
$I->amOnPage($this->createData1->getCreatedDataByName('firstname') . ".html");
52+
$I->amOnPage("/" . $testScopeData->getCreatedDataByName('firstname') . "/" . $testScopeData->getCreatedDataByName('lastname') . ".html");
53+
$I->amOnPage("/" . $this->createData1->getCreatedDataByName('firstname') . "/" . $this->createData1->getCreatedDataByName('lastname') . ".html");
54+
$I->click("#element ." . $testScopeData->getCreatedDataByName('firstname'));
55+
$I->click("#" . $testScopeData->getCreatedDataByName('firstname') . " .success");
56+
$I->click("#John-Doe ." . $testScopeData->getCreatedDataByName('lastname'));
57+
$I->click("#" . $testScopeData->getCreatedDataByName('firstname') . " ." . $testScopeData->getCreatedDataByName('lastname'));
58+
$I->click("#" . $this->createData1->getCreatedDataByName('firstname') . " ." . $this->createData1->getCreatedDataByName('lastname'));
59+
$I->fillField("#sample", "Hello " . $testScopeData->getCreatedDataByName('firstname') . " " . $testScopeData->getCreatedDataByName('lastname'));
60+
$I->fillField("#sample", "Hello " . $this->createData1->getCreatedDataByName('firstname') . " " . $this->createData1->getCreatedDataByName('lastname'));
61+
$I->searchAndMultiSelectOption("#selector", [$testScopeData->getCreatedDataByName('lastname')]);
62+
$I->searchAndMultiSelectOption("#selector", [$this->createData1->getCreatedDataByName('lastname')]);
63+
$I->amOnPage($uniqueData->getCreatedDataByName('firstname') . ".html");
64+
$I->amOnPage("/" . $uniqueData->getCreatedDataByName('firstname') . "/" . $uniqueData->getCreatedDataByName('lastname') . ".html");
65+
$I->click("#element ." . $uniqueData->getCreatedDataByName('firstname'));
66+
$I->click("#" . $uniqueData->getCreatedDataByName('firstname') . " .success");
67+
$I->click("#" . $uniqueData->getCreatedDataByName('firstname'));
68+
$I->dragAndDrop($uniqueData->getCreatedDataByName('firstname'), $uniqueData->getCreatedDataByName('firstname'));
69+
$I->dragAndDrop("#element ." . $uniqueData->getCreatedDataByName('firstname'), "#" . $uniqueData->getCreatedDataByName('firstname') . " .success");
70+
}
71+
}

dev/tests/verification/TestModule/Cest/basicFunctionalCest.xml

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<dragAndDrop selector1=".functionalTestSelector" selector2=".functionalTestSelector2" mergeKey="dragAndDropKey1" />
6161
<executeJS function="someJSFunction" mergeKey="executeJSKey1"/>
6262
<fillField selector=".functionalTestSelector" userInput="someInput" mergeKey="fillFieldKey1" />
63+
<fillField selector=".functionalTestSelector" userInput="0" mergeKey="fillFieldKey2" />
6364
<grabAttributeFrom returnVariable="grabAttributeVar" selector=".functionalTestSelector" userInput="someInput" mergeKey="grabAttributeFromKey1" />
6465
<grabCookie returnVariable="grabCookieVar" userInput="grabCookieInput" parameterArray="['domain' => 'www.google.com']" mergeKey="grabCookieKey1" />
6566
<grabFromCurrentUrl returnVariable="grabUrlVar" url="/grabCurrentUrl" mergeKey="grabFromCurrentUrlKey1" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
11+
<cest name="PersistedReplacementCest">
12+
<before>
13+
<createData entity="replacementPerson" mergeKey="createData1"/>
14+
</before>
15+
<test name="PersistedReplacementTest">
16+
<createData entity="replacementPerson" mergeKey="testScopeData"/>
17+
<createData entity="uniquePerson" mergeKey="uniqueData"/>
18+
19+
<!-- parameterized url that uses literal params -->
20+
<amOnPage url="{{SamplePage.url('success','success2')}}" mergeKey="a0"/>
21+
22+
<!-- url referencing data that was created in this <test> -->
23+
<amOnPage url="$testScopeData.firstname$.html" mergeKey="a1"/>
24+
25+
<!-- url referencing data that was created in a <before> -->
26+
<amOnPage url="$$createData1.firstname$$.html" mergeKey="a2"/>
27+
28+
<!--parameterized url that uses created data params-->
29+
<amOnPage url="{{SamplePage.url($testScopeData.firstname$,$testScopeData.lastname$)}}" mergeKey="a3"/>
30+
<amOnPage url="{{SamplePage.url($$createData1.firstname$$,$$createData1.lastname$$)}}" mergeKey="a4"/>
31+
32+
<!-- parameterized selector that uses literal params -->
33+
<click selector="{{SampleSection.oneParamElement($testScopeData.firstname$)}}" mergeKey="c1"/>
34+
<click selector="{{SampleSection.twoParamElement($testScopeData.firstname$,'success')}}" mergeKey="c2"/>
35+
36+
<!-- parameterized selector with literal, static data, and created data -->
37+
<click selector="{{SampleSection.threeParamElement('John', replacementPerson.lastname, $testScopeData.lastname$)}}"
38+
mergeKey="c3"/>
39+
40+
<!-- selector that uses created data -->
41+
<click selector="#$testScopeData.firstname$ .$testScopeData.lastname$" mergeKey="c4"/>
42+
<click selector="#$$createData1.firstname$$ .$$createData1.lastname$$" mergeKey="c5"/>
43+
44+
<!-- userInput that uses created data -->
45+
<fillField selector="#sample" userInput="Hello $testScopeData.firstname$ $testScopeData.lastname$"
46+
mergeKey="f1"/>
47+
<fillField selector="#sample" userInput="Hello $$createData1.firstname$$ $$createData1.lastname$$"
48+
mergeKey="f2"/>
49+
50+
<!-- parameterArray replacement-->
51+
<searchAndMultiSelectOption mergeKey="g1" selector="#selector" parameterArray="[$testScopeData.lastname$]"/>
52+
<searchAndMultiSelectOption mergeKey="g2" selector="#selector" parameterArray="[$$createData1.lastname$$]"/>
53+
54+
<!-- uniqueData replacement -->
55+
<amOnPage url="$uniqueData.firstname$.html" mergeKey="h1"/>
56+
<amOnPage url="{{SamplePage.url($uniqueData.firstname$,$uniqueData.lastname$)}}" mergeKey="h2"/>
57+
<click selector="{{SampleSection.oneParamElement($uniqueData.firstname$)}}" mergeKey="h3"/>
58+
<click selector="{{SampleSection.twoParamElement($uniqueData.firstname$,'success')}}" mergeKey="h4"/>
59+
<click selector="#$uniqueData.firstname$" mergeKey="h5"/>
60+
61+
<!-- selector1/2 replacement -->
62+
<dragAndDrop selector1="$uniqueData.firstname$" selector2="$uniqueData.firstname$" mergeKey="j1"/>
63+
<dragAndDrop selector1="{{SampleSection.oneParamElement($uniqueData.firstname$)}}" selector2="{{SampleSection.twoParamElement($uniqueData.firstname$,'success')}}" mergeKey="j2"/>
64+
65+
</test>
66+
</cest>
67+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
/**
5+
* Copyright © Magento, Inc. All rights reserved.
6+
* See COPYING.txt for license details.
7+
*/
8+
-->
9+
10+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
11+
xsi:noNamespaceSchemaLocation="../../../../../src/Magento/FunctionalTestingFramework/DataGenerator/etc/dataProfileSchema.xsd">
12+
<entity name="replacementPerson" type="samplePerson">
13+
<data key="firstname">John</data>
14+
<data key="lastName">Doe</data>
15+
</entity>
16+
<entity name="uniquePerson" type="samplePerson">
17+
<data key="firstname" unique="suffix">John</data>
18+
<data key="lastName">Doe</data>
19+
</entity>
20+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/PageObject.xsd">
11+
<page name="SamplePage" urlPath="/{{var1}}/{{var2}}.html" module="SampleTests" parameterized="true">
12+
<section name="SampleSection"/>
13+
</page>
14+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
11+
<section name="SampleSection">
12+
<element name="oneParamElement" type="button" selector="#element .{{var1}}" parameterized="true"/>
13+
<element name="twoParamElement" type="button" selector="#{{var1}} .{{var2}}" parameterized="true"/>
14+
<element name="threeParamElement" type="button" selector="#{{var1}}-{{var2}} .{{var3}}" parameterized="true"/>
15+
<element name="timeoutElement" type="button" selector="#foo" timeout="30"/>
16+
</section>
17+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace tests\verification\Tests;
7+
8+
use Magento\FunctionalTestingFramework\Test\Handlers\CestObjectHandler;
9+
use Magento\FunctionalTestingFramework\Util\TestGenerator;
10+
use PHPUnit\Framework\TestCase;
11+
use tests\verification\Util\FileDiffUtil;
12+
13+
class PersistedReplacementGenerationTest extends TestCase
14+
{
15+
const PERSISTED_REPLACEMENT_CEST = 'PersistedReplacementCest';
16+
const RESOURCES_PATH = __DIR__ . '/../Resources';
17+
18+
/**
19+
* Tests flat generation of a hardcoded cest file with no external references.
20+
*/
21+
public function testPersistedReplacementGeneration()
22+
{
23+
$cest = CestObjectHandler::getInstance()->getObject(self::PERSISTED_REPLACEMENT_CEST);
24+
$test = TestGenerator::getInstance(null, [$cest]);
25+
$test->createAllCestFiles();
26+
27+
$cestFile = $test->getExportDir() .
28+
DIRECTORY_SEPARATOR .
29+
self::PERSISTED_REPLACEMENT_CEST .
30+
".php";
31+
32+
$this->assertTrue(file_exists($cestFile));
33+
34+
$fileDiffUtil = new FileDiffUtil(
35+
self::RESOURCES_PATH . DIRECTORY_SEPARATOR . self::PERSISTED_REPLACEMENT_CEST . ".txt",
36+
$cestFile
37+
);
38+
39+
$diffResult = $fileDiffUtil->diffContents();
40+
$this->assertNull($diffResult, $diffResult);
41+
}
42+
}

src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/DataObjectHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ private function parseDataEntities()
201201
$arrayValues[] = $arrayValue[self::ARRAY_ELEMENT_ITEM_VALUE];
202202
}
203203

204-
$dataValues[$arrayKey] = $arrayValues;
204+
$dataValues[strtolower($arrayKey)] = $arrayValues;
205205
}
206206
}
207207

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private function getResolvedActionsWithArgs($arguments, $actionReferenceKey)
8484
// $regexPattern match on: $matches[0] {{section.element(arg.field)}}
8585
// $matches[1] = section.element
8686
// $matches[2] = arg.field
87-
$regexPattern = '/{{([\w.]+)\(*([\w.$\']+)*\)*}}/';
87+
$regexPattern = '/{{([\w.\[\]]+)\(*([\w.$\']+)*\)*}}/';
8888

8989
foreach ($this->parsedActions as $action) {
9090
$varAttributes = array_intersect(self::VAR_ATTRIBUTES, array_keys($action->getCustomActionAttributes()));
@@ -140,10 +140,10 @@ private function replaceAttributeArguments($arguments, $attributeValue, $matches
140140
if (empty($variable)) {
141141
continue;
142142
}
143-
// Truncate arg.field into arg
143+
// Truncate arg.field into arg. If 'Literal' was passed, variableName will be null.
144144
$variableName = strstr($variable, '.', true);
145145
// Check if arguments has a mapping for the given variableName
146-
if (!array_key_exists($variableName, $arguments)) {
146+
if ($variableName == null || !array_key_exists($variableName, $arguments)) {
147147
continue;
148148
}
149149
$isPersisted = strstr($arguments[$variableName], '$');

0 commit comments

Comments
 (0)