Skip to content

Commit

Permalink
Merge branch '2.4-develop' into 32279-issue-with-tier-price
Browse files Browse the repository at this point in the history
  • Loading branch information
Usik2203 committed Mar 10, 2021
2 parents 022d7bf + 1fa7fb1 commit 60e258f
Show file tree
Hide file tree
Showing 564 changed files with 91,722 additions and 31,159 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?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="AdminAwsS3ExportTaxRatesTest" extends="AdminExportTaxRatesTest">
<annotations>
<features value="AwsS3"/>
<stories value="Export Tax"/>
<title value="S3 - Export Tax Rates"/>
<description value="Exports tax rates from the System > Data Transfer > Import/Export Tax Rates page, from
the Tax Rule page, from the Tax Rates grid page as a .csv, and from the Tax Rates grid page as an .xml.
Validates contents in downloaded file for each export area. Note that MFTF cannot simply click export and
have access to the file that is downloaded in the browser due to the test not having access to the server
that is running the test browser. Therefore, this test verifies that the Export button can be successfully
clicked, grabs the request URL from the Export button's form, executes the request on the magento machine
via a curl request, and verifies the contents of the exported file. Uses S3 for the file system."/>
<severity value="MAJOR"/>
<testCaseId value="MC-38621"/>
<group value="importExport"/>
<group value="tax"/>
</annotations>

<before>
<!-- Enable AWS S3 Remote Storage -->
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.enable_options}}" stepKey="enableRemoteStorage" before="revertInitialTaxRateCA"/>
</before>

<after>
<!-- Disable AWS S3 Remote Storage -->
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.disable_options}}" stepKey="disableRemoteStorage" after="logoutFromAdmin"/>
</after>
</test>
</tests>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?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="AdminAwsS3ImportTaxRatesTest" extends="AdminImportTaxRatesTest">
<annotations>
<features value="AwsS3"/>
<stories value="Import Tax"/>
<title value="S3 - Import and Update Tax Rates"/>
<description value="Imports tax rates from the System > Data Transfer > Import/Export Tax Rates page and
from the Tax Rule page, to create new tax rates and update existing tax rates. Verifies results on the Tax
Rates grid page. Uses S3 for the file system."/>
<severity value="MAJOR"/>
<testCaseId value="MC-38621"/>
<group value="importExport"/>
<group value="tax"/>
</annotations>

<before>
<!-- Enable AWS S3 Remote Storage -->
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.enable_options}}" stepKey="enableRemoteStorage" before="revertInitialTaxRateCA"/>
</before>

<after>
<!-- Disable AWS S3 Remote Storage -->
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.disable_options}}" stepKey="disableRemoteStorage" after="logoutFromAdmin"/>
</after>
</test>
</tests>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?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="AssertAdminDashboardDisplayedWithNoErrorsActionGroup">
<annotations>
<description>Checks if Dashboard is displayed properly</description>
</annotations>

<seeElement selector="{{AdminDashboardSection.dashboardDiagramOrderContentTab}}" stepKey="seeOrderContentTab"/>
<seeElement selector="{{AdminDashboardSection.dashboardDiagramContent}}" stepKey="seeDiagramContent"/>
<click selector="{{AdminDashboardSection.dashboardDiagramAmounts}}" stepKey="clickDashboardAmount"/>
<waitForLoadingMaskToDisappear stepKey="waitForDashboardAmountLoading"/>
<seeElement selector="{{AdminDashboardSection.dashboardDiagramAmountsContentTab}}" stepKey="seeDiagramAmountContent"/>
<seeElement selector="{{AdminDashboardSection.dashboardDiagramTotals}}" stepKey="seeAmountTotals"/>
<dontSeeJsError stepKey="dontSeeJsError"/>
</actionGroup>
</actionGroups>
83 changes: 83 additions & 0 deletions app/code/Magento/Backend/Test/Mftf/Helper/CurlHelpers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Backend\Test\Mftf\Helper;

use Magento\FunctionalTestingFramework\Helper\Helper;

/**
* Class for MFTF helpers for curl requests.
*/
class CurlHelpers extends Helper
{
/**
* Assert a that a curl request's response contains an expected string
*
* @param string $url
* @param string $expectedString
* @param string $postBody
* @param string $cookieName
* @return void
*
*/
public function assertCurlResponseContainsString($url, $expectedString, $postBody = null, $cookieName = 'admin'): void
{
$cookie = $this->getCookie($cookieName);
$curlResponse = $this->getCurlResponse($url, $cookie, $postBody);
$this->assertStringContainsString($expectedString, $curlResponse);
}

/**
* Sends a curl request with the provided URL & cookie. Returns the response
*
* @param string $url
* @param string $cookie
* @param string $postBody
* @return string
*
*/
private function getCurlResponse($url, $cookie = null, $postBody = null): string
{
// Start Session
$session = curl_init($url);

// Set Options
if ($postBody) {
$data = json_decode($postBody, true);
curl_setopt($session, CURLOPT_POST, true);
curl_setopt($session, CURLOPT_POSTFIELDS, $data);
}
curl_setopt($session, CURLOPT_COOKIE, $cookie);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);

// Execute
$response = curl_exec($session);
curl_close($session);

return $response;
}

/**
* Gets the value of the specified cookie and returns the key value pair of the cookie
*
* @param string $cookieName
* @return string
*
*/
private function getCookie($cookieName = 'admin'): string
{
try {
$webDriver = $this->getModule('\Magento\FunctionalTestingFramework\Module\MagentoWebDriver');
$cookieValue = $webDriver->grabCookie($cookieName);

return $cookieName . '=' . $cookieValue;
} catch (\Exception $exception) {
$this->fail($exception->getMessage());
return '';
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?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="AdminCheckDashboardWithChartsTest">
<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>
<createData entity="CustomerCart" stepKey="createCustomerCart">
<requiredEntity createDataKey="createCustomer"/>
</createData>
<createData entity="CustomerCartItem" stepKey="addCartItem">
<requiredEntity createDataKey="createCustomerCart"/>
<requiredEntity createDataKey="createProduct"/>
</createData>
<createData entity="CustomerAddressInformation" stepKey="addCustomerOrderAddress">
<requiredEntity createDataKey="createCustomerCart"/>
</createData>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
</before>
<after>
<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>

<grabTextFrom selector="{{AdminDashboardSection.dashboardTotals('Quantity')}}" stepKey="grabQuantityBefore"/>

<updateData createDataKey="createCustomerCart" entity="CustomerOrderPaymentMethod" stepKey="sendCustomerPaymentInformation">
<requiredEntity createDataKey="createCustomerCart"/>
</updateData>
<createData entity="Invoice" stepKey="invoiceOrder">
<requiredEntity createDataKey="createCustomerCart"/>
</createData>
<createData entity="Shipment" stepKey="shipOrder">
<requiredEntity createDataKey="createCustomerCart"/>
</createData>

<reloadPage stepKey="refreshPage"/>
<actionGroup ref="AssertAdminDashboardDisplayedWithNoErrorsActionGroup" stepKey="assertAdminDashboardNotBroken"/>
<grabTextFrom selector="{{AdminDashboardSection.dashboardTotals('Quantity')}}" stepKey="grabQuantityAfter"/>
<assertGreaterThan stepKey="checkQuantityWasChanged">
<actualResult type="const">$grabQuantityAfter</actualResult>
<expectedResult type="const">$grabQuantityBefore</expectedResult>
</assertGreaterThan>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminDashboardWithChartsTest">
<test name="AdminDashboardWithChartsTest" deprecated="Use AdminCheckDashboardWithChartsTest instead">
<annotations>
<features value="Backend"/>
<stories value="Google Charts on Magento dashboard"/>
<title value="Admin should see Google chart on Magento dashboard"/>
<title value="DEPRECATED. 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"/>
<skip>
<issueId value="DEPRECATED">Use AdminCheckDashboardWithChartsTest instead</issueId>
</skip>
</annotations>
<before>
<magentoCLI command="config:set admin/dashboard/enable_charts 1" stepKey="setEnableCharts"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,11 @@
</annotations>
<before>
<magentoCLI command="config:set {{ChangedCookieDomainForMainWebsiteConfigData.path}} --scope={{ChangedCookieDomainForMainWebsiteConfigData.scope}} --scope-code={{ChangedCookieDomainForMainWebsiteConfigData.scope_code}} {{ChangedCookieDomainForMainWebsiteConfigData.value}}" stepKey="changeDomainForMainWebsiteBeforeTestRun"/>
<actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCacheBeforeTestRun">
<argument name="tags" value="config"/>
</actionGroup>
<comment userInput="Adding the comment to replace CliCacheFlushActionGroup action group ('cache:flush' command) for preserving Backward Compatibility" stepKey="flushCacheBeforeTestRun"/>
</before>
<after>
<magentoCLI command="config:set {{EmptyCookieDomainForMainWebsiteConfigData.path}} --scope={{EmptyCookieDomainForMainWebsiteConfigData.scope}} --scope-code={{EmptyCookieDomainForMainWebsiteConfigData.scope_code}} {{EmptyCookieDomainForMainWebsiteConfigData.value}}" stepKey="changeDomainForMainWebsiteAfterTestComplete"/>
<actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCacheAfterTestComplete">
<argument name="tags" value="config"/>
</actionGroup>
<comment userInput="Adding the comment to replace CliCacheFlushActionGroup action group ('cache:flush' command) for preserving Backward Compatibility" stepKey="flushCacheAfterTestComplete"/>
</after>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
<actionGroup ref="AssertAdminDashboardPageIsVisibleActionGroup" stepKey="seeDashboardPage"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ script;
setLocation(url);
';
} else {
$scriptString .= <<<script
$scriptString .= <<<'script'
jQuery('#preview_selected_store').val(scopeId);
jQuery('#preview_form').submit();
Expand Down
Loading

0 comments on commit 60e258f

Please sign in to comment.