Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Pangolin] Requested bug fixes #8

Merged
merged 4 commits into from
Oct 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dev/tests/verification/Resources/BasicFunctionalCest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class BasicFunctionalCest
$I->dragAndDrop(".functionalTestSelector", ".functionalTestSelector2");
$I->executeJS("someJSFunction");
$I->fillField(".functionalTestSelector", "someInput");
$I->fillField(".functionalTestSelector", "0");
$grabAttributeVar = $I->grabAttributeFrom(".functionalTestSelector", "someInput");
$grabCookieVar = $I->grabCookie("grabCookieInput", ['domain' => 'www.google.com']);
$grabUrlVar = $I->grabFromCurrentUrl("/grabCurrentUrl");
Expand Down
71 changes: 71 additions & 0 deletions dev/tests/verification/Resources/PersistedReplacementCest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php
namespace Magento\AcceptanceTest\_generated\Backend;

use Magento\FunctionalTestingFramework\AcceptanceTester;
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;
use Magento\FunctionalTestingFramework\DataGenerator\Persist\DataPersistenceHandler;
use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
use Yandex\Allure\Adapter\Annotation\Features;
use Yandex\Allure\Adapter\Annotation\Stories;
use Yandex\Allure\Adapter\Annotation\Title;
use Yandex\Allure\Adapter\Annotation\Description;
use Yandex\Allure\Adapter\Annotation\Parameter;
use Yandex\Allure\Adapter\Annotation\Severity;
use Yandex\Allure\Adapter\Model\SeverityLevel;
use Yandex\Allure\Adapter\Annotation\TestCaseId;

/**
*/
class PersistedReplacementCest
{
/**
* @var DataPersistenceHandler $createData1;
*/
protected $createData1;

public function _before(AcceptanceTester $I)
{
$I->amGoingTo("create entity that has the mergeKey: createData1");
$replacementPerson = DataObjectHandler::getInstance()->getObject("replacementPerson");
$this->createData1 = new DataPersistenceHandler($replacementPerson);
$this->createData1->createEntity();
}

/**
* @Parameter(name = "AcceptanceTester", value="$I")
* @param AcceptanceTester $I
* @return void
*/
public function PersistedReplacementTest(AcceptanceTester $I)
{
$I->amGoingTo("create entity that has the mergeKey: testScopeData");
$replacementPerson = DataObjectHandler::getInstance()->getObject("replacementPerson");
$testScopeData = new DataPersistenceHandler($replacementPerson);
$testScopeData->createEntity();
$I->amGoingTo("create entity that has the mergeKey: uniqueData");
$uniquePerson = DataObjectHandler::getInstance()->getObject("uniquePerson");
$uniqueData = new DataPersistenceHandler($uniquePerson);
$uniqueData->createEntity();
$I->amOnPage("/success/success2.html");
$I->amOnPage($testScopeData->getCreatedDataByName('firstname') . ".html");
$I->amOnPage($this->createData1->getCreatedDataByName('firstname') . ".html");
$I->amOnPage("/" . $testScopeData->getCreatedDataByName('firstname') . "/" . $testScopeData->getCreatedDataByName('lastname') . ".html");
$I->amOnPage("/" . $this->createData1->getCreatedDataByName('firstname') . "/" . $this->createData1->getCreatedDataByName('lastname') . ".html");
$I->click("#element ." . $testScopeData->getCreatedDataByName('firstname'));
$I->click("#" . $testScopeData->getCreatedDataByName('firstname') . " .success");
$I->click("#John-Doe ." . $testScopeData->getCreatedDataByName('lastname'));
$I->click("#" . $testScopeData->getCreatedDataByName('firstname') . " ." . $testScopeData->getCreatedDataByName('lastname'));
$I->click("#" . $this->createData1->getCreatedDataByName('firstname') . " ." . $this->createData1->getCreatedDataByName('lastname'));
$I->fillField("#sample", "Hello " . $testScopeData->getCreatedDataByName('firstname') . " " . $testScopeData->getCreatedDataByName('lastname'));
$I->fillField("#sample", "Hello " . $this->createData1->getCreatedDataByName('firstname') . " " . $this->createData1->getCreatedDataByName('lastname'));
$I->searchAndMultiSelectOption("#selector", [$testScopeData->getCreatedDataByName('lastname')]);
$I->searchAndMultiSelectOption("#selector", [$this->createData1->getCreatedDataByName('lastname')]);
$I->amOnPage($uniqueData->getCreatedDataByName('firstname') . ".html");
$I->amOnPage("/" . $uniqueData->getCreatedDataByName('firstname') . "/" . $uniqueData->getCreatedDataByName('lastname') . ".html");
$I->click("#element ." . $uniqueData->getCreatedDataByName('firstname'));
$I->click("#" . $uniqueData->getCreatedDataByName('firstname') . " .success");
$I->click("#" . $uniqueData->getCreatedDataByName('firstname'));
$I->dragAndDrop($uniqueData->getCreatedDataByName('firstname'), $uniqueData->getCreatedDataByName('firstname'));
$I->dragAndDrop("#element ." . $uniqueData->getCreatedDataByName('firstname'), "#" . $uniqueData->getCreatedDataByName('firstname') . " .success");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<dragAndDrop selector1=".functionalTestSelector" selector2=".functionalTestSelector2" mergeKey="dragAndDropKey1" />
<executeJS function="someJSFunction" mergeKey="executeJSKey1"/>
<fillField selector=".functionalTestSelector" userInput="someInput" mergeKey="fillFieldKey1" />
<fillField selector=".functionalTestSelector" userInput="0" mergeKey="fillFieldKey2" />
<grabAttributeFrom returnVariable="grabAttributeVar" selector=".functionalTestSelector" userInput="someInput" mergeKey="grabAttributeFromKey1" />
<grabCookie returnVariable="grabCookieVar" userInput="grabCookieInput" parameterArray="['domain' => 'www.google.com']" mergeKey="grabCookieKey1" />
<grabFromCurrentUrl returnVariable="grabUrlVar" url="/grabCurrentUrl" mergeKey="grabFromCurrentUrlKey1" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
<cest name="PersistedReplacementCest">
<before>
<createData entity="replacementPerson" mergeKey="createData1"/>
</before>
<test name="PersistedReplacementTest">
<createData entity="replacementPerson" mergeKey="testScopeData"/>
<createData entity="uniquePerson" mergeKey="uniqueData"/>

<!-- parameterized url that uses literal params -->
<amOnPage url="{{SamplePage.url('success','success2')}}" mergeKey="a0"/>

<!-- url referencing data that was created in this <test> -->
<amOnPage url="$testScopeData.firstname$.html" mergeKey="a1"/>

<!-- url referencing data that was created in a <before> -->
<amOnPage url="$$createData1.firstname$$.html" mergeKey="a2"/>

<!--parameterized url that uses created data params-->
<amOnPage url="{{SamplePage.url($testScopeData.firstname$,$testScopeData.lastname$)}}" mergeKey="a3"/>
<amOnPage url="{{SamplePage.url($$createData1.firstname$$,$$createData1.lastname$$)}}" mergeKey="a4"/>

<!-- parameterized selector that uses literal params -->
<click selector="{{SampleSection.oneParamElement($testScopeData.firstname$)}}" mergeKey="c1"/>
<click selector="{{SampleSection.twoParamElement($testScopeData.firstname$,'success')}}" mergeKey="c2"/>

<!-- parameterized selector with literal, static data, and created data -->
<click selector="{{SampleSection.threeParamElement('John', replacementPerson.lastname, $testScopeData.lastname$)}}"
mergeKey="c3"/>

<!-- selector that uses created data -->
<click selector="#$testScopeData.firstname$ .$testScopeData.lastname$" mergeKey="c4"/>
<click selector="#$$createData1.firstname$$ .$$createData1.lastname$$" mergeKey="c5"/>

<!-- userInput that uses created data -->
<fillField selector="#sample" userInput="Hello $testScopeData.firstname$ $testScopeData.lastname$"
mergeKey="f1"/>
<fillField selector="#sample" userInput="Hello $$createData1.firstname$$ $$createData1.lastname$$"
mergeKey="f2"/>

<!-- parameterArray replacement-->
<searchAndMultiSelectOption mergeKey="g1" selector="#selector" parameterArray="[$testScopeData.lastname$]"/>
<searchAndMultiSelectOption mergeKey="g2" selector="#selector" parameterArray="[$$createData1.lastname$$]"/>

<!-- uniqueData replacement -->
<amOnPage url="$uniqueData.firstname$.html" mergeKey="h1"/>
<amOnPage url="{{SamplePage.url($uniqueData.firstname$,$uniqueData.lastname$)}}" mergeKey="h2"/>
<click selector="{{SampleSection.oneParamElement($uniqueData.firstname$)}}" mergeKey="h3"/>
<click selector="{{SampleSection.twoParamElement($uniqueData.firstname$,'success')}}" mergeKey="h4"/>
<click selector="#$uniqueData.firstname$" mergeKey="h5"/>

<!-- selector1/2 replacement -->
<dragAndDrop selector1="$uniqueData.firstname$" selector2="$uniqueData.firstname$" mergeKey="j1"/>
<dragAndDrop selector1="{{SampleSection.oneParamElement($uniqueData.firstname$)}}" selector2="{{SampleSection.twoParamElement($uniqueData.firstname$,'success')}}" mergeKey="j2"/>

</test>
</cest>
</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../src/Magento/FunctionalTestingFramework/DataGenerator/etc/dataProfileSchema.xsd">
<entity name="replacementPerson" type="samplePerson">
<data key="firstname">John</data>
<data key="lastName">Doe</data>
</entity>
<entity name="uniquePerson" type="samplePerson">
<data key="firstname" unique="suffix">John</data>
<data key="lastName">Doe</data>
</entity>
</config>
14 changes: 14 additions & 0 deletions dev/tests/verification/TestModule/Page/SamplePage.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/PageObject.xsd">
<page name="SamplePage" urlPath="/{{var1}}/{{var2}}.html" module="SampleTests" parameterized="true">
<section name="SampleSection"/>
</page>
</config>
17 changes: 17 additions & 0 deletions dev/tests/verification/TestModule/Section/SampleSection.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
<section name="SampleSection">
<element name="oneParamElement" type="button" selector="#element .{{var1}}" parameterized="true"/>
<element name="twoParamElement" type="button" selector="#{{var1}} .{{var2}}" parameterized="true"/>
<element name="threeParamElement" type="button" selector="#{{var1}}-{{var2}} .{{var3}}" parameterized="true"/>
<element name="timeoutElement" type="button" selector="#foo" timeout="30"/>
</section>
</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace tests\verification\Tests;

use Magento\FunctionalTestingFramework\Test\Handlers\CestObjectHandler;
use Magento\FunctionalTestingFramework\Util\TestGenerator;
use PHPUnit\Framework\TestCase;
use tests\verification\Util\FileDiffUtil;

class PersistedReplacementGenerationTest extends TestCase
{
const PERSISTED_REPLACEMENT_CEST = 'PersistedReplacementCest';
const RESOURCES_PATH = __DIR__ . '/../Resources';

/**
* Tests flat generation of a hardcoded cest file with no external references.
*/
public function testPersistedReplacementGeneration()
{
$cest = CestObjectHandler::getInstance()->getObject(self::PERSISTED_REPLACEMENT_CEST);
$test = TestGenerator::getInstance(null, [$cest]);
$test->createAllCestFiles();

$cestFile = $test->getExportDir() .
DIRECTORY_SEPARATOR .
self::PERSISTED_REPLACEMENT_CEST .
".php";

$this->assertTrue(file_exists($cestFile));

$fileDiffUtil = new FileDiffUtil(
self::RESOURCES_PATH . DIRECTORY_SEPARATOR . self::PERSISTED_REPLACEMENT_CEST . ".txt",
$cestFile
);

$diffResult = $fileDiffUtil->diffContents();
$this->assertNull($diffResult, $diffResult);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ private function parseDataEntities()
$arrayValues[] = $arrayValue[self::ARRAY_ELEMENT_ITEM_VALUE];
}

$dataValues[$arrayKey] = $arrayValues;
$dataValues[strtolower($arrayKey)] = $arrayValues;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private function getResolvedActionsWithArgs($arguments, $actionReferenceKey)
// $regexPattern match on: $matches[0] {{section.element(arg.field)}}
// $matches[1] = section.element
// $matches[2] = arg.field
$regexPattern = '/{{([\w.]+)\(*([\w.$\']+)*\)*}}/';
$regexPattern = '/{{([\w.\[\]]+)\(*([\w.$\']+)*\)*}}/';

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