Skip to content

Commit f9457ea

Browse files
committed
B2B-1704: Add MFTF test for MC-38621
- Updating export test to use form url
1 parent e1fa06a commit f9457ea

File tree

4 files changed

+18
-21
lines changed

4 files changed

+18
-21
lines changed

app/code/Magento/TaxImportExport/Test/Mftf/ActionGroup/AdminExportTaxRatesActionGroup.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11-
<actionGroup name="AdminExportTaxRatesActionGroup">
11+
<actionGroup name="AdminClickExportTaxRatesActionGroup">
1212
<annotations>
1313
<description>Clicks the 'Export Tax Rates' button.</description>
1414
</annotations>

app/code/Magento/TaxImportExport/Test/Mftf/Helper/CurlHelpers.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,33 @@ class CurlHelpers extends Helper
1717
/**
1818
* Assert a that a curl request's response contains an expected string
1919
*
20-
* @param string $uri
20+
* @param string $url
2121
* @param string $expectedString
2222
* @return void
2323
*
2424
* @throws \Magento\Framework\Exception\FileSystemException
2525
*/
26-
public function assertCurlResponseContainsString($uri, $expectedString): void
26+
public function assertCurlResponseContainsString($url, $expectedString): void
2727
{
2828
$cookie = $this->getCookie();
29-
echo $cookie;
30-
$curlResponse = $this->getCurlResponse($uri, $cookie);
31-
echo $curlResponse;
29+
$curlResponse = $this->getCurlResponse($url, $cookie);
3230
$this->assertStringContainsString($expectedString, $curlResponse);
3331
}
3432

3533
/**
36-
* Sends a curl request with the provided URI & cookie. Returns the response
34+
* Sends a curl request with the provided URL & cookie. Returns the response
3735
*
38-
* @param string $uri
36+
* @param string $url
3937
* @param string $cookie
4038
* @return string
4139
*
4240
* @throws \Magento\Framework\Exception\FileSystemException
4341
*/
44-
public function getCurlResponse($uri, $cookie): string
42+
public function getCurlResponse($url, $cookie): string
4543
{
4644
try {
4745
// Start Session
48-
$session = curl_init($uri);
46+
$session = curl_init($url);
4947

5048
// Set Options
5149
curl_setopt($session, CURLOPT_COOKIE, $cookie);
@@ -65,7 +63,7 @@ public function getCurlResponse($uri, $cookie): string
6563
}
6664

6765
/**
68-
* Sends a curl request with the provided URI & cookie. Returns the response in JSON format
66+
* Gets the value of the specified cookie and returns the key value pair of the cookie
6967
*
7068
* @return string
7169
*

app/code/Magento/TaxImportExport/Test/Mftf/Section/AdminImportExportTaxRatesSection.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<section name="AdminImportExportTaxRatesSection">
1212
<element name="uploadFile" type="input" selector="#import_rates_file"/>
1313
<element name="importTaxRatesButton" type="button" selector="[title='Import Tax Rates']"/>
14-
<element name="exportTaxRatesButton" type="button" selector="[title='Export Tax Rates']"/>
14+
<element name="exportTaxRatesButtonForm" type="block" selector="#export_form"/>
15+
<element name="exportTaxRatesButton" type="button" selector="#export_form [title='Export Tax Rates']"/>
1516
</section>
1617
</sections>

app/code/Magento/TaxImportExport/Test/Mftf/Test/AdminExportTaxRatesTest.xml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
<description value="Exports tax rates from the System > Data Transfer > Import/Export Tax Rates page and
1717
validates contents in downloaded file. Note that MFTF cannot simply click export and have access to the file
1818
that is downloaded in the browser due to the test not having access to the server that is running the test
19-
browser. Therefore, this test clicks the Export button, grabs the request URI from the browser, and executes
20-
the same request on the magento machine via a curl request to download the same file there so that the test
21-
has access to the exported file."/>
19+
browser. Therefore, this test verifies that the Export button can be successfully clicked, grabs the request
20+
URL from the Export button's form, executes the request on the magento machine via a curl request, and
21+
verifies the contents of the exported file."/>
2222
<severity value="MAJOR"/>
2323
<testCaseId value="MC-38949"/>
2424
<group value="importExport"/>
@@ -41,16 +41,14 @@
4141

4242
<!-- Export Tax Rates & Validate Export -->
4343
<actionGroup ref="AdminNavigateImportExportTaxRatesActionGroup" stepKey="navigateToImportExportTaxRatesPage"/>
44-
<actionGroup ref="AdminExportTaxRatesActionGroup" stepKey="exportTaxRates"/>
45-
<executeJS function="return window.performance.getEntriesByName('mousedown')[0].target.baseURI" stepKey="exportURI"/>
46-
<comment userInput="{$exportURI}" stepKey="commentExportURI"/>
47-
<executeJS function="return window.location.origin" stepKey="baseUrl"/>
44+
<actionGroup ref="AdminClickExportTaxRatesActionGroup" stepKey="exportTaxRates"/>
45+
<grabAttributeFrom userInput="action" selector="{{AdminImportExportTaxRatesSection.exportTaxRatesButtonForm}}" stepKey="grabExportUrl"/>
4846
<helper class="\Magento\TaxImportExport\Test\Mftf\Helper\CurlHelpers" method="assertCurlResponseContainsString" stepKey="assertExportedFileContainsCATaxRate">
49-
<argument name="uri">{$baseUrl}/admin/tax/rate/exportPost/</argument>
47+
<argument name="url">{$grabExportUrl}</argument>
5048
<argument name="expectedString">{{US_CA_Rate_1.code}}</argument>
5149
</helper>
5250
<helper class="\Magento\TaxImportExport\Test\Mftf\Helper\CurlHelpers" method="assertCurlResponseContainsString" stepKey="assertExportedFileContainsNYTaxRate">
53-
<argument name="uri">{$baseUrl}/admin/tax/rate/exportPost/</argument>
51+
<argument name="url">{$grabExportUrl}</argument>
5452
<argument name="expectedString">{{US_NY_Rate_1.code}}</argument>
5553
</helper>
5654
</test>

0 commit comments

Comments
 (0)