-
Notifications
You must be signed in to change notification settings - Fork 132
MQE-2043 Custom helper argument in action group is not resolved #669
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the fix, helper argument now works for static data.
However, it looks like it still won't work for
For example,
<grabFromCurrentUrl stepKey="grabText" regex="#docs/([^\/]+)$#"/>
Reference like
<actionGroup ref="HelperActionGroup" stepKey="actionGroupWithCustomHelper2"> <argument name="test" value="$grabText"/> <argument name="entityTest" value="HelperData"/> </actionGroup>
For example (need attached to Magento)
<createData entity="Simple_US_Customer_CA" stepKey="simpleCustomer"/>
Reference like
<actionGroup ref="HelperActionGroup" stepKey="actionGroupWithCustomHelper2"> <argument name="test" value="$$simpleCustomer.firstname$$"/> <argument name="entityTest" value="HelperData"/> </actionGroup>
Please check if it works as expected. <?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminDashboardWithChartsTest">
<annotations>
<features value="Backend"/>
<stories value="Google Charts on Magento dashboard"/>
<title value="Admin should see Google chart on Magento dashboard"/>
<description value="Google chart on Magento dashboard page is displaying properly"/>
<severity value="MAJOR"/>
<testCaseId value="MAGETWO-98934"/>
<useCaseId value="MAGETWO-98584"/>
<group value="backend"/>
</annotations>
<before>
<magentoCLI command="config:set admin/dashboard/enable_charts 1" stepKey="setEnableCharts"/>
<createData entity="SimpleProduct2" stepKey="createProduct">
<field key="price">150</field>
</createData>
<createData entity="Simple_US_Customer" stepKey="createCustomer">
<field key="firstname">John1</field>
<field key="lastname">Doe1</field>
</createData>
</before>
<after>
<!-- Reset admin order filter -->
<comment userInput="Reset admin order filter" stepKey="resetAdminOrderFilter"/>
<actionGroup ref="AdminOrdersGridClearFiltersActionGroup" stepKey="clearOrderFilters"/>
<waitForLoadingMaskToDisappear stepKey="waitForLoadingOrderGrid"/>
<magentoCLI command="config:set admin/dashboard/enable_charts 0" stepKey="setDisableChartsAsDefault"/>
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
</after>
<!-- Login as admin -->
<comment userInput="Login as admin" stepKey="adminLogin"/>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
<!-- Grab quantity value -->
<comment userInput="Grab quantity value from dashboard" stepKey="grabQuantityFromDashboard"/>
<grabTextFrom selector="{{AdminDashboardSection.dashboardTotals('Quantity')}}" stepKey="grabStartQuantity"/>
<grabFromCurrentUrl stepKey="grabText" regex="#docs/([^\/]+)$#"/>
<helper class="\Magento\Backend\Test\Mftf\Helper\CustomHelper" method="goTo" stepKey="customHelperWithArrayParametrized">
<argument name="test">{{Simple_US_Customer.firstname}}</argument>
<argument name="module">[$$createCustomer.lastname$$, $grabText]</argument>
<argument name="url">{$grabText}</argument>
<argument name="superBla">1.2</argument>
<argument name="bla" />
<argument name="bool">false</argument>
<argument name="float">4.223</argument>
<argument name="int">$grabStartQuantity</argument>
</helper>
<actionGroup ref="HelperActionGroup" stepKey="actionGroupWithCustomHelper">
<argument name="test" value="$$createCustomer.lastname$$" />
<argument name="qwerty" value="$$createProduct$$" />
<argument name="grabbedValue" value="$grabStartQuantity" />
</actionGroup>
</test>
</tests> My generated PHP test: <?php
namespace Magento\AcceptanceTest\_default\Backend;
use Magento\FunctionalTestingFramework\AcceptanceTester;
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;
/**
* @Title("MAGETWO-98934: Admin should see Google chart on Magento dashboard")
* @Description("Google chart on Magento dashboard page is displaying properly<h3>Test files</h3>app/code/Magento/Backend/Test/Mftf/Test/AdminDashboardWithChartsChart.xml<br>")
* @TestCaseId("MAGETWO-98934")
* @group backend
*/
class AdminDashboardWithChartsTestCest
{
/**
* @var \Magento\FunctionalTestingFramework\Helper\HelperContainer
*/
private $helperContainer;
/**
* Special method which automatically creates the respective objects.
*/
public function _inject(
\Magento\Backend\Test\Mftf\Helper\CustomHelper $customHelperWithArrayParametrized
) {
$this->helperContainer = new \Magento\FunctionalTestingFramework\Helper\HelperContainer(
[
'\Magento\Backend\Test\Mftf\Helper\CustomHelper' => $customHelperWithArrayParametrized,
]
);
}
/**
* @param AcceptanceTester $I
* @throws \Exception
*/
public function _before(AcceptanceTester $I)
{
$setEnableCharts = $I->magentoCLI("config:set admin/dashboard/enable_charts 1", 60); // stepKey: setEnableCharts
$I->comment($setEnableCharts);
$createProductFields['price'] = "150";
$I->createEntity("createProduct", "hook", "SimpleProduct2", [], $createProductFields); // stepKey: createProduct
$createCustomerFields['firstname'] = "John1";
$createCustomerFields['lastname'] = "Doe1";
$I->createEntity("createCustomer", "hook", "Simple_US_Customer", [], $createCustomerFields); // stepKey: createCustomer
}
/**
* @param AcceptanceTester $I
* @throws \Exception
*/
public function _after(AcceptanceTester $I)
{
$I->comment("Reset admin order filter");
$I->comment("Reset admin order filter");
$I->comment("Entering Action Group [clearOrderFilters] AdminOrdersGridClearFiltersActionGroup");
$I->amOnPage("/" . getenv("MAGENTO_BACKEND_NAME") . "/sales/order/"); // stepKey: goToGridOrdersPageClearOrderFilters
$I->waitForPageLoad(30); // stepKey: waitForPageToLoadClearOrderFilters
$I->conditionalClick(".admin__data-grid-header [data-action='grid-filter-reset']", ".admin__data-grid-header .admin__data-grid-filters-current._show", true); // stepKey: clickOnButtonToRemoveFiltersIfPresentClearOrderFilters
$I->comment("Exiting Action Group [clearOrderFilters] AdminOrdersGridClearFiltersActionGroup");
$I->waitForLoadingMaskToDisappear(); // stepKey: waitForLoadingOrderGrid
$setDisableChartsAsDefault = $I->magentoCLI("config:set admin/dashboard/enable_charts 0", 60); // stepKey: setDisableChartsAsDefault
$I->comment($setDisableChartsAsDefault);
$I->deleteEntity("createProduct", "hook"); // stepKey: deleteProduct
$I->deleteEntity("createCustomer", "hook"); // stepKey: deleteCustomer
$I->comment("Entering Action Group [logout] AdminLogoutActionGroup");
$I->amOnPage("/" . getenv("MAGENTO_BACKEND_NAME") . "/admin/auth/logout/"); // stepKey: amOnLogoutPageLogout
$I->comment("Exiting Action Group [logout] AdminLogoutActionGroup");
}
/**
* @param AcceptanceTester $I
* @throws \Exception
*/
public function _failed(AcceptanceTester $I)
{
$I->saveScreenshot(); // stepKey: saveScreenshot
}
/**
* @Features({"Backend"})
* @Stories({"Google Charts on Magento dashboard"})
* @Severity(level = SeverityLevel::NORMAL)
* @Parameter(name = "AcceptanceTester", value="$I")
* @param AcceptanceTester $I
* @return void
* @throws \Exception
*/
public function AdminDashboardWithChartsTest(AcceptanceTester $I)
{
$I->comment("Login as admin");
$I->comment("Login as admin");
$I->comment("Entering Action Group [loginAsAdmin] AdminLoginActionGroup");
$I->amOnPage("/" . getenv("MAGENTO_BACKEND_NAME") . "/admin"); // stepKey: navigateToAdminLoginAsAdmin
$I->fillField("#username", getenv("MAGENTO_ADMIN_USERNAME")); // stepKey: fillUsernameLoginAsAdmin
$I->fillField("#login", getenv("MAGENTO_ADMIN_PASSWORD")); // stepKey: fillPasswordLoginAsAdmin
$I->click(".actions .action-primary"); // stepKey: clickLoginLoginAsAdmin
$I->waitForPageLoad(30); // stepKey: clickLoginLoginAsAdminWaitForPageLoad
$I->conditionalClick(".modal-popup .action-secondary", ".modal-popup .action-secondary", true); // stepKey: clickDontAllowButtonIfVisibleLoginAsAdmin
$I->closeAdminNotification(); // stepKey: closeAdminNotificationLoginAsAdmin
$I->comment("Exiting Action Group [loginAsAdmin] AdminLoginActionGroup");
$I->comment("Grab quantity value");
$I->comment("Grab quantity value from dashboard");
$grabStartQuantity = $I->grabTextFrom("//*[@class='dashboard-totals-label' and contains(text(), 'Quantity')]/../*[@class='dashboard-totals-value']"); // stepKey: grabStartQuantity
$grabText = $I->grabFromCurrentUrl("#docs/([^\/]+)$#"); // stepKey: grabText
$I->comment('[customHelperWithArrayParametrized] \Magento\Backend\Test\Mftf\Helper\CustomHelper::goTo()');
$this->helperContainer->get('\Magento\Backend\Test\Mftf\Helper\CustomHelper')->goTo($grabText, "John", false, $grabStartQuantity, 4.223, [$I->retrieveEntityField('createCustomer', 'lastname', 'test'), $grabText], "1.2", "", array ( 'key' => 'value', 0 => 'test',)); // stepKey: customHelperWithArrayParametrized
$I->comment("Entering Action Group [actionGroupWithCustomHelper] HelperActionGroup");
$I->comment("Action group to demonstrate helper functionality available from action groups.");
$I->comment('[customHelperActionGroupWithCustomHelper] \Magento\Backend\Test\Mftf\Helper\CustomHelper::goTo()');
$this->helperContainer->get('\Magento\Backend\Test\Mftf\Helper\CustomHelper')->goTo($I->retrieveEntityField('createCustomer', 'lastname', 'test'), "//*[@class='dashboard-totals-label' and contains(text(), '" . $I->retrieveEntityField('createCustomer', 'lastname', 'test') . "')]/../*[@class='dashboard-totals-value']", true, 42, 4.400000000234234, [$I->retrieveEntityField('createCustomer', 'lastname', 'test'), $I->retrieveEntityField('createProduct', 'custom_attributes[url_key]', 'test'), $grabStartQuantity], NULL, 'blaValue', array ( 'key' => 'value', 0 => 'test',)); // stepKey: customHelperActionGroupWithCustomHelper
$I->comment("Exiting Action Group [actionGroupWithCustomHelper] HelperActionGroup");
}
} And my action group: <?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="HelperActionGroup">
<arguments>
<argument name="test" type="string" />
<argument name="qwerty" />
<argument name="grabbedValue" type="string"/>
</arguments>
<comment userInput="Action group to demonstrate helper functionality available from action groups." stepKey="comment" />
<helper class="\Magento\Backend\Test\Mftf\Helper\CustomHelper" method="goTo" stepKey="customHelper">
<argument name="test">{{AdminDashboardSection.dashboardTotals(test)}}</argument>
<argument name="module">[{{test}}, {{qwerty.custom_attributes[url_key]}}, {{grabbedValue}}]</argument>
<argument name="url">{{test}}</argument>
<argument name="bool">true</argument>
<argument name="float">4.400000000234234</argument>
<argument name="int">42</argument>
</helper>
</actionGroup>
</actionGroups> Custom helper is the same as in MFTF DevDocs test |
@okolesnyk <actionGroup ref="HelperActionGroup" stepKey="actionGroupWithCustomHelper2">
<argument name="test" value="$grabStartQuantity"/>
<argument name="qwerty" value="$$createProduct$$" />
<argument name="grabbedValue" value="$grabStartQuantity" />
</actionGroup> The additional generated code will look like the following for me, which is wrong. $this->helperContainer->get('\Magento\Backend\Test\Mftf\Helper\CustomHelper')->goTo("$grabStartQuantity", "//*[@class='dashboard-totals-label' and contains(text(), '$grabStartQuantity')]/../*[@class='dashboard-totals-value']", true, 42, 4.400000000234234, [$grabStartQuantity, $I->retrieveEntityField('createProduct', 'custom_attributes[url_key]', 'test'), $grabStartQuantity], NULL, 'blaValue', array ( 'key' => 'value', 0 => 'test',)); // stepKey: customHelperActionGroupWithCustomHelper2 |
What's wrong in this? I don't see a problem here |
The |
I see. That is ok. PHP will handle this just fine. And also that part developed in MFTF for a long time to generate variables in double quotes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Approve it!
Description
Fixed Issues (if relevant)
Contribution checklist