Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.4-develop' into PWA-1303
Browse files Browse the repository at this point in the history
  • Loading branch information
cspruiell committed Mar 5, 2021
2 parents dca9b03 + adc70c4 commit 3530ceb
Show file tree
Hide file tree
Showing 34 changed files with 884 additions and 25 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>
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 '';
}
}
}
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/etc/db_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,7 @@
<constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_MDA_GLR_VAL_TO_ENTT_ENTT_ID_CAT_PRD_ENTT_ENTT_ID"
table="catalog_product_entity_media_gallery_value_to_entity" column="entity_id"
referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/>
<constraint xsi:type="unique" referenceId="CAT_PRD_ENTT_MDA_GLR_VAL_TO_ENTT_VAL_ID_ENTT_ID">
<constraint xsi:type="primary" referenceId="CAT_PRD_ENTT_MDA_GLR_VAL_TO_ENTT_VAL_ID_ENTT_ID">
<column name="value_id"/>
<column name="entity_id"/>
</constraint>
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Catalog/etc/db_schema_whitelist.json
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,7 @@
"entity_id": true
},
"constraint": {
"PRIMARY": true,
"FK_A6C6C8FAA386736921D3A7C4B50B1185": true,
"CAT_PRD_ENTT_MDA_GLR_VAL_TO_ENTT_ENTT_ID_CAT_PRD_ENTT_ENTT_ID": true,
"CAT_PRD_ENTT_MDA_GLR_VAL_TO_ENTT_VAL_ID_ENTT_ID": true
Expand Down
3 changes: 3 additions & 0 deletions app/code/Magento/CatalogUrlRewrite/etc/db_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
comment="category_id"/>
<column xsi:type="int" name="product_id" unsigned="true" nullable="false" identity="false"
comment="product_id"/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="url_rewrite_id"/>
</constraint>
<constraint xsi:type="foreign" referenceId="CAT_URL_REWRITE_PRD_CTGR_PRD_ID_CAT_PRD_ENTT_ENTT_ID"
table="catalog_url_rewrite_product_category" column="product_id"
referenceTable="catalog_product_entity" referenceColumn="entity_id" onDelete="CASCADE"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
"CATALOG_URL_REWRITE_PRODUCT_CATEGORY_CATEGORY_ID_PRODUCT_ID": true
},
"constraint": {
"PRIMARY": true,
"CAT_URL_REWRITE_PRD_CTGR_PRD_ID_CAT_PRD_ENTT_ENTT_ID": true,
"FK_BB79E64705D7F17FE181F23144528FC8": true,
"CAT_URL_REWRITE_PRD_CTGR_CTGR_ID_CAT_CTGR_ENTT_ENTT_ID": true,
"CAT_URL_REWRITE_PRD_CTGR_CTGR_ID_SEQUENCE_CAT_CTGR_SEQUENCE_VAL": true,
"CAT_URL_REWRITE_PRD_CTGR_PRD_ID_SEQUENCE_PRD_SEQUENCE_VAL": true
}
}
}
}
2 changes: 1 addition & 1 deletion app/code/Magento/Integration/etc/db_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<constraint xsi:type="foreign" referenceId="OAUTH_NONCE_CONSUMER_ID_OAUTH_CONSUMER_ENTITY_ID" table="oauth_nonce"
column="consumer_id" referenceTable="oauth_consumer" referenceColumn="entity_id"
onDelete="CASCADE"/>
<constraint xsi:type="unique" referenceId="OAUTH_NONCE_NONCE_CONSUMER_ID">
<constraint xsi:type="primary" referenceId="OAUTH_NONCE_NONCE_CONSUMER_ID">
<column name="nonce"/>
<column name="consumer_id"/>
</constraint>
Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/Integration/etc/db_schema_whitelist.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"consumer_id": true
},
"constraint": {
"PRIMARY": true,
"OAUTH_NONCE_CONSUMER_ID_OAUTH_CONSUMER_ENTITY_ID": true,
"OAUTH_NONCE_NONCE_CONSUMER_ID": true
},
Expand Down Expand Up @@ -94,4 +95,4 @@
"OAUTH_TOKEN_REQUEST_LOG_USER_NAME_USER_TYPE": true
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<constraint xsi:type="foreign" referenceId="LOGIN_AS_CUSTOMER_ASSISTANCE_ALLOWED_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID"
table="login_as_customer_assistance_allowed" column="customer_id" referenceTable="customer_entity"
referenceColumn="entity_id" onDelete="CASCADE"/>
<constraint xsi:type="unique" referenceId="LOGIN_AS_CUSTOMER_ASSISTANCE_ALLOWED_CUSTOMER_ID">
<constraint xsi:type="primary" referenceId="LOGIN_AS_CUSTOMER_ASSISTANCE_ALLOWED_CUSTOMER_ID">
<column name="customer_id"/>
</constraint>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"customer_id": true
},
"constraint": {
"PRIMARY": true,
"LOGIN_AS_CSTR_ASSISTANCE_ALLOWED_CSTR_ID_CSTR_ENTT_ENTT_ID": true,
"LOGIN_AS_CUSTOMER_ASSISTANCE_ALLOWED_CUSTOMER_ID": true
}
}
}
}
2 changes: 1 addition & 1 deletion app/code/Magento/ProductVideo/etc/db_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<constraint xsi:type="foreign" referenceId="CAT_PRD_ENTT_MDA_GLR_VAL_VIDEO_STORE_ID_STORE_STORE_ID"
table="catalog_product_entity_media_gallery_value_video" column="store_id" referenceTable="store"
referenceColumn="store_id" onDelete="CASCADE"/>
<constraint xsi:type="unique" referenceId="CAT_PRD_ENTT_MDA_GLR_VAL_VIDEO_VAL_ID_STORE_ID">
<constraint xsi:type="primary" referenceId="CAT_PRD_ENTT_MDA_GLR_VAL_VIDEO_VAL_ID_STORE_ID">
<column name="value_id"/>
<column name="store_id"/>
</constraint>
Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/ProductVideo/etc/db_schema_whitelist.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
"metadata": true
},
"constraint": {
"PRIMARY": true,
"FK_6FDF205946906B0E653E60AA769899F8": true,
"CAT_PRD_ENTT_MDA_GLR_VAL_VIDEO_STORE_ID_STORE_STORE_ID": true,
"CAT_PRD_ENTT_MDA_GLR_VAL_VIDEO_VAL_ID_STORE_ID": true
}
}
}
}
2 changes: 1 addition & 1 deletion app/code/Magento/Rule/Test/Mftf/Helper/RuleHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class RuleHelper extends Helper
{
/**
* Delete all Catalog Price Rules obe by one.
* Deletes all Catalog Price Rules one by one.
*
* @param string $emptyRow
* @param string $modalAceptButton
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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="AdminAssertTaxRateInGridActionGroup">
<annotations>
<description>Verifies the specified data is in the specified row on the the admin Tax Zones and Rates page.</description>
</annotations>
<arguments>
<argument name="taxIdentifier" defaultValue="{{US_CA_Rate_1.code}}" type="string"/>
<argument name="country" defaultValue="{{US_CA_Rate_1.tax_country}}" type="string"/>
<argument name="region" defaultValue="{{US_CA_Rate_1.tax_region}}" type="string"/>
<argument name="zip" defaultValue="{{US_CA_Rate_1.tax_postcode}}" type="string"/>
<argument name="rate" defaultValue="{{US_CA_Rate_1.rate}}" type="string"/>
<argument name="rowIndex" defaultValue="1" type="string"/>
</arguments>
<waitForElementVisible selector="{{AdminTaxRateGridSection.nthRow(rowIndex)}}" stepKey="waitForRow"/>
<see userInput="{{taxIdentifier}}" selector="{{AdminTaxRateGridSection.taxIdentifierByRow(rowIndex)}}" stepKey="seeTaxIdentifier"/>
<see userInput="{{country}}" selector="{{AdminTaxRateGridSection.countryByRow(rowIndex)}}" stepKey="seeCountry"/>
<see userInput="{{region}}" selector="{{AdminTaxRateGridSection.regionByRow(rowIndex)}}" stepKey="seeRegion"/>
<see userInput="{{zip}}" selector="{{AdminTaxRateGridSection.zipByRow(rowIndex)}}" stepKey="seeZip"/>
<see userInput="{{rate}}" selector="{{AdminTaxRateGridSection.rateByRow(rowIndex)}}" stepKey="seeRate"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?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="AdminDeleteMultipleTaxRatesActionGroup">
<annotations>
<description>Navigates to the 'Tax Zones and Rates' page and deletes all specified rows one by one. Defaults
to delete all rows except the defaults of 'US-CA-*-Rate 1' and 'US-NY-*-Rate 1'.</description>
</annotations>
<arguments>
<argument name="rowsToDelete" defaultValue="{{AdminTaxRateGridSection.allNonDefaultTaxRates}}" type="string"/>
<argument name="expectedRemainingRows" defaultValue="2" type="string"/>
</arguments>
<waitForElementVisible selector="{{AdminLegacyDataGridFilterSection.clear}}" stepKey="waitForResetFilter"/>
<click selector="{{AdminLegacyDataGridFilterSection.clear}}" stepKey="clickResetFilter"/>
<waitForPageLoad stepKey="waitForGridReset"/>
<helper class="\Magento\Tax\Test\Mftf\Helper\TaxHelpers" method="deleteAllSpecifiedTaxRuleRows" stepKey="deleteAllSpecifiedTaxRules">
<argument name="rowsToDelete">{{rowsToDelete}}</argument>
<argument name="deleteButton">{{AdminMainActionsSection.delete}}</argument>
<argument name="modalAcceptButton">{{AdminConfirmationModalSection.ok}}</argument>
<argument name="successMessage">You deleted the tax rate.</argument>
<argument name="successMessageContainer">{{AdminMessagesSection.success}}</argument>
</helper>
<waitForPageLoad stepKey="waitForGridLoad"/>
<seeNumberOfElements userInput="{{expectedRemainingRows}}" selector="{{AdminTaxRateGridSection.allRows}}" stepKey="seeExpectedFinalTotalRows"/>
</actionGroup>
</actionGroups>
33 changes: 21 additions & 12 deletions app/code/Magento/Tax/Test/Mftf/Data/TaxRateData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,39 @@
-->
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
<entity name="SimpleTaxRate" type="taxRate">
<data key="code" unique="suffix">TaxRate</data>
</entity>
<entity name="defaultTaxRate" type="taxRate">
<data key="code" unique="suffix">Tax Rate </data>
<data key="tax_country_id">US</data>
<data key="tax_region_id">12</data>
<data key="tax_postcode">*</data>
<data key="zip_is_range">0</data>
<data key="rate">10</data>
</entity>
<!-- These Tax Rates Are Installed by Default with Magento -->
<entity name="US_CA_Rate_1" type="taxRate">
<data key="id">1</data>
<data key="code">US-CA-*-Rate 1</data>
<data key="tax_country_id">US</data>
<data key="tax_country">United States</data>
<data key="tax_region_id">12</data>
<data key="tax_region">CA</data>
<data key="tax_postcode">*</data>
<data key="rate">8.2500</data>
</entity>
<entity name="US_NY_Rate_1" type="taxRate">
<data key="id">2</data>
<data key="code">US-NY-*-Rate 1</data>
<data key="tax_country_id">US</data>
<data key="tax_country">United States</data>
<data key="tax_region_id">43</data>
<data key="tax_region">NY</data>
<data key="tax_postcode">*</data>
<data key="rate">8.3750</data>
<data key="id">2</data>
</entity>

<!-- Test Tax Rates -->
<entity name="SimpleTaxRate" type="taxRate">
<data key="code" unique="suffix">TaxRate</data>
</entity>
<entity name="defaultTaxRate" type="taxRate">
<data key="code" unique="suffix">Tax Rate </data>
<data key="tax_country_id">US</data>
<data key="tax_region_id">12</data>
<data key="tax_postcode">*</data>
<data key="zip_is_range">0</data>
<data key="rate">10</data>
</entity>
<entity name="taxRate_US_NY_8_1" type="taxRate">
<data key="code" unique="suffix">US-NY-*-</data>
Expand Down
Loading

0 comments on commit 3530ceb

Please sign in to comment.