Skip to content

Commit dc20d4e

Browse files
committed
B2B-1704: Add MFTF test for MC-38621
- Moving CurlHelpers.php - Adding export checks
1 parent a58e324 commit dc20d4e

File tree

4 files changed

+95
-6
lines changed

4 files changed

+95
-6
lines changed

app/code/Magento/Catalog/Test/Mftf/Helper/CurlHelpers.php renamed to app/code/Magento/Backend/Test/Mftf/Helper/CurlHelpers.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
declare(strict_types=1);
77

8-
namespace Magento\Catalog\Test\Mftf\Helper;
8+
namespace Magento\Backend\Test\Mftf\Helper;
99

1010
use Magento\FunctionalTestingFramework\Helper\Helper;
1111

@@ -20,12 +20,13 @@ class CurlHelpers extends Helper
2020
* @param string $url
2121
* @param string $expectedString
2222
* @param string $postBody
23+
* @param string $cookieName
2324
* @return void
2425
*
2526
*/
26-
public function assertCurlResponseContainsString($url, $expectedString, $postBody = null): void
27+
public function assertCurlResponseContainsString($url, $expectedString, $postBody = null, $cookieName = 'admin'): void
2728
{
28-
$cookie = $this->getCookie('admin');
29+
$cookie = $this->getCookie($cookieName);
2930
$curlResponse = $this->getCurlResponse($url, $cookie, $postBody);
3031
$this->assertStringContainsString($expectedString, $curlResponse);
3132
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminExportTaxRatesFromGridActionGroup">
12+
<annotations>
13+
<description>Selects the export file type and clicks the 'Export' button from the Tax Zones and Rates admin page.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="fileType" defaultValue="CSV" type="string"/>
17+
</arguments>
18+
<waitForElementVisible selector="{{AdminTaxRateGridSection.exportFileType}}" stepKey="waitForExportFileTypeDropDown"/>
19+
<selectOption userInput="{{fileType}}" selector="{{AdminTaxRateGridSection.exportFileType}}" stepKey="selectFileType"/>
20+
<click selector="{{AdminTaxRateGridSection.exportButton}}" stepKey="clickExportButton"/>
21+
<waitForPageLoad stepKey="waitForExport"/>
22+
</actionGroup>
23+
</actionGroups>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="AdminTaxRateGridSection">
12+
<element name="exportFileType" type="select" selector="#tax_rate_grid_export"/>
13+
<element name="exportFileTypeOption" type="select" parameterized="true" selector="//select[@id='tax_rate_grid_export']//option[.='{{option}}']"/>
14+
<element name="exportButton" type="button" selector="#tax_rate_grid [title='Export']"/>
15+
</section>
16+
</sections>

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

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,69 @@
3939
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/>
4040
</after>
4141

42-
<!-- Export Tax Rates & Validate Export -->
42+
<!-- Export Tax Rates & Validate Export from System > Data Transfer -->
4343
<actionGroup ref="AdminNavigateImportExportTaxRatesActionGroup" stepKey="navigateToImportExportTaxRatesPage"/>
4444
<actionGroup ref="AdminClickExportTaxRatesActionGroup" stepKey="exportTaxRates"/>
4545
<grabAttributeFrom userInput="action" selector="{{AdminImportExportTaxRatesSection.exportTaxRatesButtonForm}}" stepKey="grabExportUrl"/>
4646
<executeJS function="return window.FORM_KEY" stepKey="grabFormKey"/>
47-
<helper class="\Magento\Catalog\Test\Mftf\Helper\CurlHelpers" method="assertCurlResponseContainsString" stepKey="assertExportedFileContainsCATaxRate">
47+
<helper class="\Magento\Backend\Test\Mftf\Helper\CurlHelpers" method="assertCurlResponseContainsString" stepKey="assertExportedFileContainsCATaxRate">
4848
<argument name="url">{$grabExportUrl}</argument>
4949
<argument name="postBody">{"form_key": "{$grabFormKey}"}</argument>
5050
<argument name="expectedString">{{US_CA_Rate_1.code}}</argument>
5151
</helper>
52-
<helper class="\Magento\Catalog\Test\Mftf\Helper\CurlHelpers" method="assertCurlResponseContainsString" stepKey="assertExportedFileContainsNYTaxRate">
52+
<helper class="\Magento\Backend\Test\Mftf\Helper\CurlHelpers" method="assertCurlResponseContainsString" stepKey="assertExportedFileContainsNYTaxRate">
5353
<argument name="url">{$grabExportUrl}</argument>
5454
<argument name="postBody">{"form_key": "{$grabFormKey}"}</argument>
5555
<argument name="expectedString">{{US_NY_Rate_1.code}}</argument>
5656
</helper>
57+
58+
<!-- Export Tax Rates & Validate Export from Tax Rule Page -->
59+
<actionGroup ref="AdminGoToNewTaxRulePageActionGroup" stepKey="navigateToTaxRulePage"/>
60+
<actionGroup ref="AdminClickExportTaxRatesActionGroup" stepKey="exportTaxRates2"/>
61+
<grabAttributeFrom userInput="action" selector="{{AdminImportExportTaxRatesSection.exportTaxRatesButtonForm}}" stepKey="grabExportUrl2"/>
62+
<executeJS function="return window.FORM_KEY" stepKey="grabFormKey2"/>
63+
<helper class="\Magento\Backend\Test\Mftf\Helper\CurlHelpers" method="assertCurlResponseContainsString" stepKey="assertExportedFileContainsCATaxRate2">
64+
<argument name="url">{$grabExportUrl2}</argument>
65+
<argument name="postBody">{"form_key": "{$grabFormKey2}"}</argument>
66+
<argument name="expectedString">{{US_CA_Rate_1.code}}</argument>
67+
</helper>
68+
<helper class="\Magento\Backend\Test\Mftf\Helper\CurlHelpers" method="assertCurlResponseContainsString" stepKey="assertExportedFileContainsNYTaxRate2">
69+
<argument name="url">{$grabExportUrl2}</argument>
70+
<argument name="postBody">{"form_key": "{$grabFormKey2}"}</argument>
71+
<argument name="expectedString">{{US_NY_Rate_1.code}}</argument>
72+
</helper>
73+
74+
<!-- Export Tax Rates & Validate Export from Tax Rates Grid Page as CSV -->
75+
<actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="navigateToTaxRatesGridPage"/>
76+
<actionGroup ref="AdminExportTaxRatesFromGridActionGroup" stepKey="exportTaxRatesCSV"/>
77+
<grabAttributeFrom userInput="value" selector="{{AdminTaxRateGridSection.exportFileTypeOption('CSV')}}" stepKey="grabExportUrl3"/>
78+
<executeJS function="return window.FORM_KEY" stepKey="grabFormKey3"/>
79+
<helper class="\Magento\Backend\Test\Mftf\Helper\CurlHelpers" method="assertCurlResponseContainsString" stepKey="assertExportedFileContainsCATaxRate3">
80+
<argument name="url">{$grabExportUrl3}</argument>
81+
<argument name="postBody">{"form_key": "{$grabFormKey3}"}</argument>
82+
<argument name="expectedString">{{US_CA_Rate_1.code}}</argument>
83+
</helper>
84+
<helper class="\Magento\Backend\Test\Mftf\Helper\CurlHelpers" method="assertCurlResponseContainsString" stepKey="assertExportedFileContainsNYTaxRate3">
85+
<argument name="url">{$grabExportUrl3}</argument>
86+
<argument name="postBody">{"form_key": "{$grabFormKey3}"}</argument>
87+
<argument name="expectedString">{{US_NY_Rate_1.code}}</argument>
88+
</helper>
89+
90+
<!-- Export Tax Rates & Validate Export from Tax Rates Grid Page as XML -->
91+
<actionGroup ref="AdminExportTaxRatesFromGridActionGroup" stepKey="exportTaxRatesXML">
92+
<argument name="fileType" value="Excel XML"/>
93+
</actionGroup>
94+
<grabAttributeFrom userInput="value" selector="{{AdminTaxRateGridSection.exportFileTypeOption('Excel XML')}}" stepKey="grabExportUrl4"/>
95+
<executeJS function="return window.FORM_KEY" stepKey="grabFormKey4"/>
96+
<helper class="\Magento\Backend\Test\Mftf\Helper\CurlHelpers" method="assertCurlResponseContainsString" stepKey="assertExportedFileContainsCATaxRate4">
97+
<argument name="url">{$grabExportUrl4}</argument>
98+
<argument name="postBody">{"form_key": "{$grabFormKey4}"}</argument>
99+
<argument name="expectedString">{{US_CA_Rate_1.code}}</argument>
100+
</helper>
101+
<helper class="\Magento\Backend\Test\Mftf\Helper\CurlHelpers" method="assertCurlResponseContainsString" stepKey="assertExportedFileContainsNYTaxRate4">
102+
<argument name="url">{$grabExportUrl4}</argument>
103+
<argument name="postBody">{"form_key": "{$grabFormKey4}"}</argument>
104+
<argument name="expectedString">{{US_NY_Rate_1.code}}</argument>
105+
</helper>
57106
</test>
58107
</tests>

0 commit comments

Comments
 (0)