Skip to content

Commit a51d638

Browse files
ENGCOM-8066: Redirect to "Options" config path more accurate (in Currency Rate form) #29276
2 parents 300128d + 6fab465 commit a51d638

File tree

5 files changed

+84
-3
lines changed

5 files changed

+84
-3
lines changed

app/code/Magento/CurrencySymbol/Block/Adminhtml/System/Currency.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,14 @@ protected function _prepareLayout()
4141
]
4242
);
4343

44-
$onClick = "setLocation('" . $this->getUrl('adminhtml/system_config/edit/section/currency') . "')";
44+
$currencyOptionPath = $this->getUrl(
45+
'adminhtml/system_config/edit',
46+
[
47+
'section' => 'currency',
48+
'_fragment' => 'currency_options-link'
49+
]
50+
);
51+
$onClick = "setLocation('$currencyOptionPath')";
4552

4653
$this->getToolbar()->addChild(
4754
'options_button',
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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="AdminNavigateToCurrencyRatesOptionActionGroup">
12+
<click selector="{{AdminCurrencyRatesSection.options}}" stepKey="clickOptionsButton"/>
13+
<waitForPageLoad stepKey="waitForPageLoad"/>
14+
</actionGroup>
15+
</actionGroups>

app/code/Magento/CurrencySymbol/Test/Mftf/Section/AdminCurrencyRatesSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<section name="AdminCurrencyRatesSection">
1212
<element name="import" type="button" selector="//button[@title='Import']"/>
1313
<element name="saveCurrencyRates" type="button" selector="//button[@title='Save Currency Rates']"/>
14+
<element name="options" type="button" selector="//button[@title='Options']"/>
1415
<element name="oldRate" type="text" selector="//div[contains(@class, 'admin__field-note') and contains(text(), 'Old rate:')]/strong"/>
1516
<element name="rateService" type="select" selector="#rate_services"/>
1617
<element name="currencyRate" type="input" selector="input[name='rate[{{fistCurrency}}][{{secondCurrency}}]']" parameterized="true"/>
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminCurrencyOptionsSystemConfigExpandedTabTest">
12+
<annotations>
13+
<features value="Expanded tab on Currency Option page"/>
14+
<stories value="Expanded tab"/>
15+
<title value=" Verify the Currency Option tab expands automatically."/>
16+
<description value="Check auto open the collapse on Currency Option page."/>
17+
<severity value="MINOR"/>
18+
<testCaseId value="MC-37425"/>
19+
</annotations>
20+
<before>
21+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
22+
</before>
23+
<after>
24+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
25+
</after>
26+
<actionGroup ref="AdminNavigateMenuActionGroup" stepKey="navigateToStoresCurrencyRatesPage">
27+
<argument name="menuUiId" value="{{AdminMenuStores.dataUiId}}"/>
28+
<argument name="submenuUiId" value="{{AdminMenuStoresCurrencyCurrencyRates.dataUiId}}"/>
29+
</actionGroup>
30+
<actionGroup ref="AdminNavigateToCurrencyRatesOptionActionGroup" stepKey="navigateToOptions" />
31+
<grabAttributeFrom selector="{{CurrencySetupSection.currencyOptions}}" userInput="class" stepKey="grabClass"/>
32+
<assertStringContainsString stepKey="assertClass">
33+
<actualResult type="string">{$grabClass}</actualResult>
34+
<expectedResult type="string">open</expectedResult>
35+
</assertStringContainsString>
36+
</test>
37+
</tests>

app/code/Magento/CurrencySymbol/Test/Unit/Block/Adminhtml/System/CurrencyTest.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,22 @@
77

88
namespace Magento\CurrencySymbol\Test\Unit\Block\Adminhtml\System;
99

10+
use Magento\Backend\Block\Template\Context;
1011
use Magento\Backend\Block\Widget\Button;
1112
use Magento\CurrencySymbol\Block\Adminhtml\System\Currency;
1213
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1314
use Magento\Framework\View\Element\BlockInterface;
1415
use Magento\Framework\View\LayoutInterface;
1516
use PHPUnit\Framework\TestCase;
17+
use Magento\Framework\UrlInterface;
1618

1719
class CurrencyTest extends TestCase
1820
{
21+
/**
22+
* Stub currency option link url
23+
*/
24+
const STUB_OPTION_LINK_URL = 'https://localhost/admin/system_config/edit/section/currency#currency_options-link';
25+
1926
/**
2027
* Object manager helper
2128
*
@@ -70,12 +77,25 @@ public function testPrepareLayout()
7077
]
7178
);
7279

80+
$contextMock = $this->createMock(Context::class);
81+
$urlBuilderMock = $this->createMock(UrlInterface::class);
82+
83+
$contextMock->expects($this->once())->method('getUrlBuilder')->willReturn($urlBuilderMock);
84+
85+
$urlBuilderMock->expects($this->once())->method('getUrl')->with(
86+
'adminhtml/system_config/edit',
87+
[
88+
'section' => 'currency',
89+
'_fragment' => 'currency_options-link'
90+
]
91+
)->willReturn(self::STUB_OPTION_LINK_URL);
92+
7393
$childBlockMock->expects($this->at(1))
7494
->method('addChild')
7595
->with(
7696
'options_button',
7797
Button::class,
78-
['label' => __('Options'), 'onclick' => 'setLocation(\'\')']
98+
['label' => __('Options'), 'onclick' => 'setLocation(\''.self::STUB_OPTION_LINK_URL.'\')']
7999
);
80100

81101
$childBlockMock->expects($this->at(2))
@@ -90,7 +110,8 @@ public function testPrepareLayout()
90110
$block = $this->objectManagerHelper->getObject(
91111
Currency::class,
92112
[
93-
'layout' => $layoutMock
113+
'layout' => $layoutMock,
114+
'context' => $contextMock
94115
]
95116
);
96117
$block->setLayout($layoutMock);

0 commit comments

Comments
 (0)