Skip to content

Commit 8db7d3c

Browse files
committed
B2B-1704: Add MFTF test for MC-38621
- Adding test for importing tax rates - Adding supporting MFTF entities in Tax module
1 parent 4aa59a8 commit 8db7d3c

14 files changed

+367
-15
lines changed

app/code/Magento/Rule/Test/Mftf/Helper/RuleHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
class RuleHelper extends Helper
1919
{
2020
/**
21-
* Delete all Catalog Price Rules obe by one.
21+
* Deletes all Catalog Price Rules one by one.
2222
*
2323
* @param string $emptyRow
2424
* @param string $modalAceptButton
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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="AdminAssertTaxRateInGridActionGroup">
12+
<annotations>
13+
<description>Verifies the specified data is in the specified row on the the admin Tax Zones and Rates page.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="taxIdentifier" defaultValue="{{US_CA_Rate_1.code}}" type="string"/>
17+
<argument name="country" defaultValue="{{US_CA_Rate_1.tax_country}}" type="string"/>
18+
<argument name="region" defaultValue="{{US_CA_Rate_1.tax_region}}" type="string"/>
19+
<argument name="zip" defaultValue="{{US_CA_Rate_1.tax_postcode}}" type="string"/>
20+
<argument name="rate" defaultValue="{{US_CA_Rate_1.rate}}" type="string"/>
21+
<argument name="rowIndex" defaultValue="1" type="string"/>
22+
</arguments>
23+
<waitForElementVisible selector="{{AdminTaxRateGridSection.nthRow(rowIndex)}}" stepKey="waitForRow"/>
24+
<see userInput="{{taxIdentifier}}" selector="{{AdminTaxRateGridSection.taxIdentifierByRow(rowIndex)}}" stepKey="seeTaxIdentifier"/>
25+
<see userInput="{{country}}" selector="{{AdminTaxRateGridSection.countryByRow(rowIndex)}}" stepKey="seeCountry"/>
26+
<see userInput="{{region}}" selector="{{AdminTaxRateGridSection.regionByRow(rowIndex)}}" stepKey="seeRegion"/>
27+
<see userInput="{{zip}}" selector="{{AdminTaxRateGridSection.zipByRow(rowIndex)}}" stepKey="seeZip"/>
28+
<see userInput="{{rate}}" selector="{{AdminTaxRateGridSection.rateByRow(rowIndex)}}" stepKey="seeRate"/>
29+
</actionGroup>
30+
</actionGroups>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminDeleteMultipleTaxRatesActionGroup">
11+
<annotations>
12+
<description>Navigates to the 'Tax Zones and Rates' page and deletes all specified rows one by one. Defaults
13+
to delete all rows except the defaults of 'US-CA-*-Rate 1' and 'US-NY-*-Rate 1'.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="rowsToDelete" defaultValue="{{AdminTaxRateGridSection.allNonDefaultTaxRates}}" type="string"/>
17+
<argument name="expectedRemainingRows" defaultValue="2" type="string"/>
18+
</arguments>
19+
<waitForElementVisible selector="{{AdminLegacyDataGridFilterSection.clear}}" stepKey="waitForResetFilter"/>
20+
<click selector="{{AdminLegacyDataGridFilterSection.clear}}" stepKey="clickResetFilter"/>
21+
<waitForPageLoad stepKey="waitForGridReset"/>
22+
<helper class="\Magento\Tax\Test\Mftf\Helper\TaxHelpers" method="deleteAllSpecifiedTaxRuleRows" stepKey="deleteAllSpecifiedTaxRules">
23+
<argument name="rowsToDelete">{{rowsToDelete}}</argument>
24+
<argument name="deleteButton">{{AdminMainActionsSection.delete}}</argument>
25+
<argument name="modalAcceptButton">{{AdminConfirmationModalSection.ok}}</argument>
26+
<argument name="successMessage">You deleted the tax rate.</argument>
27+
<argument name="successMessageContainer">{{AdminMessagesSection.success}}</argument>
28+
</helper>
29+
<waitForPageLoad stepKey="waitForGridLoad"/>
30+
<seeNumberOfElements userInput="{{expectedRemainingRows}}" selector="{{AdminTaxRateGridSection.allRows}}" stepKey="seeExpectedFinalTotalRows"/>
31+
</actionGroup>
32+
</actionGroups>

app/code/Magento/Tax/Test/Mftf/Data/TaxRateData.xml

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,39 @@
77
-->
88
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
10-
<entity name="SimpleTaxRate" type="taxRate">
11-
<data key="code" unique="suffix">TaxRate</data>
12-
</entity>
13-
<entity name="defaultTaxRate" type="taxRate">
14-
<data key="code" unique="suffix">Tax Rate </data>
15-
<data key="tax_country_id">US</data>
16-
<data key="tax_region_id">12</data>
17-
<data key="tax_postcode">*</data>
18-
<data key="zip_is_range">0</data>
19-
<data key="rate">10</data>
20-
</entity>
10+
<!-- These Tax Rates Are Installed by Default with Magento -->
2111
<entity name="US_CA_Rate_1" type="taxRate">
2212
<data key="id">1</data>
2313
<data key="code">US-CA-*-Rate 1</data>
2414
<data key="tax_country_id">US</data>
15+
<data key="tax_country">United States</data>
16+
<data key="tax_region_id">12</data>
17+
<data key="tax_region">CA</data>
2518
<data key="tax_postcode">*</data>
2619
<data key="rate">8.2500</data>
2720
</entity>
2821
<entity name="US_NY_Rate_1" type="taxRate">
22+
<data key="id">2</data>
2923
<data key="code">US-NY-*-Rate 1</data>
3024
<data key="tax_country_id">US</data>
25+
<data key="tax_country">United States</data>
26+
<data key="tax_region_id">43</data>
27+
<data key="tax_region">NY</data>
3128
<data key="tax_postcode">*</data>
3229
<data key="rate">8.3750</data>
33-
<data key="id">2</data>
30+
</entity>
31+
32+
<!-- Test Tax Rates -->
33+
<entity name="SimpleTaxRate" type="taxRate">
34+
<data key="code" unique="suffix">TaxRate</data>
35+
</entity>
36+
<entity name="defaultTaxRate" type="taxRate">
37+
<data key="code" unique="suffix">Tax Rate </data>
38+
<data key="tax_country_id">US</data>
39+
<data key="tax_region_id">12</data>
40+
<data key="tax_postcode">*</data>
41+
<data key="zip_is_range">0</data>
42+
<data key="rate">10</data>
3443
</entity>
3544
<entity name="taxRate_US_NY_8_1" type="taxRate">
3645
<data key="code" unique="suffix">US-NY-*-</data>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Tax\Test\Mftf\Helper;
9+
10+
use Facebook\WebDriver\Remote\RemoteWebDriver as FacebookWebDriver;
11+
use Facebook\WebDriver\WebDriverBy;
12+
use Magento\FunctionalTestingFramework\Helper\Helper;
13+
use Magento\FunctionalTestingFramework\Module\MagentoWebDriver;
14+
15+
/**
16+
* Class for MFTF helpers for Tax module.
17+
*/
18+
class TaxHelpers extends Helper
19+
{
20+
/**
21+
* Delete all specified Tax Rules one by one from the Tax Zones and Rates page.
22+
*
23+
* @param string $rowsToDelete
24+
* @param string $deleteButton
25+
* @param string $modalAcceptButton
26+
* @param string $successMessage
27+
* @param string $successMessageContainer
28+
*
29+
* @return void
30+
*/
31+
public function deleteAllSpecifiedTaxRuleRows(
32+
string $rowsToDelete,
33+
string $deleteButton,
34+
string $modalAcceptButton,
35+
string $successMessage,
36+
string $successMessageContainer
37+
): void {
38+
try {
39+
/** @var MagentoWebDriver $webDriver */
40+
$magentoWebDriver = $this->getModule('\Magento\FunctionalTestingFramework\Module\MagentoWebDriver');
41+
/** @var FacebookWebDriver $webDriver */
42+
$webDriver = $magentoWebDriver->webDriver;
43+
$magentoWebDriver->waitForPageLoad(30);
44+
$rows = $webDriver->findElements(WebDriverBy::xpath($rowsToDelete));
45+
while (!empty($rows)) {
46+
$rows[0]->click();
47+
$magentoWebDriver->waitForPageLoad(30);
48+
$magentoWebDriver->waitForElementVisible($deleteButton, 10);
49+
$magentoWebDriver->click($deleteButton);
50+
$magentoWebDriver->waitForPageLoad(30);
51+
$magentoWebDriver->waitForElementVisible($modalAcceptButton, 10);
52+
$magentoWebDriver->click($modalAcceptButton);
53+
$magentoWebDriver->waitForPageLoad(60);
54+
$magentoWebDriver->waitForText($successMessage, 10, $successMessageContainer);
55+
$rows = $webDriver->findElements(WebDriverBy::xpath($rowsToDelete));
56+
}
57+
} catch (\Exception $exception) {
58+
$this->fail($exception->getMessage());
59+
}
60+
}
61+
}

app/code/Magento/Tax/Test/Mftf/Section/AdminTaxRateGridSection.xml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@
1515
<element name="filterByTaxIdentifier" type="input" selector="#tax_rate_grid_filter_code"/>
1616
<element name="filterByCountry" type="input" selector="#tax_rate_grid_filter_tax_country_id"/>
1717
<element name="filterByPostCode" type="input" selector="#tax_rate_grid_filter_tax_postcode"/>
18-
<element name="nthRow" type="block" selector="tr[data-role='row']:nth-of-type({{var}})" parameterized="true" timeout="30"/>
18+
<element name="allRows" type="block" selector="#tax_rate_grid_table tbody tr"/>
19+
<element name="nthRow" type="block" parameterized="true" timeout="30" selector="#tax_rate_grid_table tbody tr:nth-of-type({{rowIndex}})"/>
20+
<element name="taxIdentifierByRow" type="text" parameterized="true" selector="#tax_rate_grid_table tbody tr:nth-of-type({{rowIndex}}) [data-column=code]"/>
21+
<element name="countryByRow" type="text" parameterized="true" selector="#tax_rate_grid_table tbody tr:nth-of-type({{rowIndex}}) [data-column=tax_country_id]"/>
22+
<element name="regionByRow" type="text" parameterized="true" selector="#tax_rate_grid_table tbody tr:nth-of-type({{rowIndex}}) [data-column=region_name]"/>
23+
<element name="zipByRow" type="text" parameterized="true" selector="#tax_rate_grid_table tbody tr:nth-of-type({{rowIndex}}) [data-column=tax_postcode]"/>
24+
<element name="rateByRow" type="text" parameterized="true" selector="#tax_rate_grid_table tbody tr:nth-of-type({{rowIndex}}) [data-column=rate]"/>
25+
<element name="allNonDefaultTaxRates" type="block" selector="//table[@id='tax_rate_grid_table']//tbody//tr//td[@data-column='code' and not(contains(.,'US-CA-*-Rate 1')) and not(contains(.,'US-NY-*-Rate 1'))]"/>
1926
<element name="emptyText" type="text" selector=".empty-text"/>
2027
</section>
21-
</sections>
28+
</sections>
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminExportTaxRatesActionGroup">
12+
<annotations>
13+
<description>Clicks the 'Export Tax Rates' button.</description>
14+
</annotations>
15+
</actionGroup>
16+
</actionGroups>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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="AdminImportTaxRatesActionGroup">
12+
<annotations>
13+
<description>Uploads the specified file and clicks the 'Import Tax Rates' button on the Import and Export Tax Rates page.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="file" defaultValue="" type="string"/>
17+
<argument name="resultMessageType" defaultValue="success" type="string"/>
18+
<argument name="resultMessage" defaultValue="The tax rate has been imported." type="string"/>
19+
</arguments>
20+
<waitForElementVisible selector="{{AdminImportExportTaxRatesSection.uploadFile}}" stepKey="waitForUploadFile"/>
21+
<attachFile userInput="{{file}}" selector="{{AdminImportExportTaxRatesSection.uploadFile}}" stepKey="uploadFile"/>
22+
<click selector="{{AdminImportExportTaxRatesSection.importTaxRatesButton}}" stepKey="clickImportTaxRates"/>
23+
<waitForPageLoad stepKey="waitForImport"/>
24+
<waitForText userInput="{{resultMessage}}" selector="{{AdminMessagesSection.messageByType(resultMessageType)}}" stepKey="waitForMessage"/>
25+
</actionGroup>
26+
</actionGroups>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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="AdminNavigateImportExportTaxRatesActionGroup">
12+
<annotations>
13+
<description>Navigates to the admin System > Data Transfer > Import/Export Tax Rates page.</description>
14+
</annotations>
15+
<amOnPage url="{{AdminImportExportTaxRatesPage.url}}" stepKey="navigateToImportExportTaxRatesPage"/>
16+
</actionGroup>
17+
</actionGroups>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<!-- Tax Import Files -->
12+
<entity name="import_tax_rates" type="taxImport">
13+
<data key="filename">import_tax_rates.csv</data>
14+
</entity>
15+
16+
<!-- Tax Rates -->
17+
<entity name="import_rate_1" type="taxRate">
18+
<data key="code">import-rate-1</data>
19+
<data key="tax_country_id">US</data>
20+
<data key="tax_country">United States</data>
21+
<data key="tax_region_id">57</data>
22+
<data key="tax_region">TX</data>
23+
<data key="tax_postcode">78758</data>
24+
<data key="zip_is_range">0</data>
25+
<data key="rate">5.25</data>
26+
</entity>
27+
<entity name="import_rate_2" type="taxRate">
28+
<data key="code">import-rate-2</data>
29+
<data key="tax_country_id">US</data>
30+
<data key="tax_country">United States</data>
31+
<data key="tax_region_id">2</data>
32+
<data key="tax_region">AK</data>
33+
<data key="tax_postcode">12345-12346</data>
34+
<data key="zip_is_range">1</data>
35+
<data key="rate">7.75</data>
36+
</entity>
37+
</entities>

0 commit comments

Comments
 (0)