Skip to content

MQE-1222: Selector Fails To Resolve Correctly in Action Group #235

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

Merged
merged 2 commits into from
Sep 25, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
namespace Magento\AcceptanceTest\_default\Backend;

use Magento\FunctionalTestingFramework\AcceptanceTester;
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore;
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler;
use \Codeception\Util\Locator;
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 ActionGroupWithSectionAndDataAsArgumentsCest
{
/**
* @Features({"TestModule"})
* @Parameter(name = "AcceptanceTester", value="$I")
* @param AcceptanceTester $I
* @return void
* @throws \Exception
*/
public function ActionGroupWithSectionAndDataAsArguments(AcceptanceTester $I)
{
$I->waitForElementVisible("#element .John");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,12 @@
<actionGroup name="actionGroupWithSkipReadinessActions">
<comment userInput="ActionGroupSkipReadiness" stepKey="skip" skipReadiness="true"/>
</actionGroup>

<actionGroup name="actionGroupWithSectionAndData">
<arguments>
<argument name="content" type="string"/>
<argument name="section"/>
</arguments>
<waitForElementVisible selector="{{section.oneParamElement(content)}}" stepKey="arg1"/>
</actionGroup>
</actionGroups>
7 changes: 7 additions & 0 deletions dev/tests/verification/TestModule/Test/ActionGroupTest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,11 @@
<argument name="sameStepKeyAsArg" value="arg1"/>
</actionGroup>
</test>

<test name="ActionGroupWithSectionAndDataAsArguments">
<actionGroup ref="actionGroupWithSectionAndData" stepKey="actionGroup">
<argument name="content" value="{{simpleData.firstname}}"/>
<argument name="section" value="SampleSection"/>
</actionGroup>
</test>
</tests>
11 changes: 11 additions & 0 deletions dev/tests/verification/Tests/ActionGroupGenerationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,15 @@ public function testActionGroupWithSkipReadiness()
{
$this->generateAndCompareTest('ActionGroupSkipReadiness');
}

/**
* Test an action group with an arg containing stepKey text
*
* @throws \Exception
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
*/
public function testActionGroupWithSectionAndDataArguments()
{
$this->generateAndCompareTest('ActionGroupWithSectionAndDataAsArguments');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ public function getResolvedValue($isInnerArgument)
* Takes in boolean to determine if the replacement is being done with an inner argument (as in if it's a parameter)
*
* Example Type Non Inner Inner
* {{XML.DATA}}: {{XML.DATA}} XML.DATA
* $TEST.DATA$: $TEST.DATA$ $TEST.DATA$
* {{XML.DATA}} {{XML.DATA}} XML.DATA
* $TEST.DATA$ $TEST.DATA$ $TEST.DATA$
* stringLiteral stringLiteral 'stringLiteral'
*
* @param boolean $isInnerArgument
Expand All @@ -114,6 +114,11 @@ public function getResolvedValue($isInnerArgument)
private function resolveStringArgument($isInnerArgument)
{
if ($isInnerArgument) {
if (preg_match('/{{[\w.\[\]]+}}/', $this->value)) {
return ltrim(rtrim($this->value, "}"), "{");
} elseif (preg_match('/\${1,2}[\w.\[\]]+\${1,2}/', $this->value)) {
return $this->value;
}
return "'" . $this->value . "'";
} else {
return $this->value;
Expand Down