Skip to content

Commit efdd8a8

Browse files
ENGCOM-7488: comments & validation added in cookie configuration #26886
- Merge Pull Request #26886 from ajithkumar-maragathavel/magento2:module-cookie-improvements - Merged commits: 1. b7db784 2. a3d0010 3. dc14a72 4. 1c92793 5. e3ecb7e 6. 9ce188b
2 parents f442fa9 + 9ce188b commit efdd8a8

File tree

7 files changed

+133
-5
lines changed

7 files changed

+133
-5
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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="AdminFillCookieLifetimeActionGroup">
12+
<annotations>
13+
<description>Fills the cookie lifetime field with sample data.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="cookieLifetime" type="string"/>
17+
</arguments>
18+
<fillField selector="{{AdminDefaultCookieSettingsSection.DefaultCookieLifetime}}" userInput="{{cookieLifetime}}" stepKey="fillFieldCookieLifetime"/>
19+
</actionGroup>
20+
</actionGroups>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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="AdminNavigateToDefaultCookieSettingsActionGroup">
12+
<amOnPage url="{{AdminConfigurationDefaultCookieSettingsPage.url}}" stepKey="navigateToDefaultCookieSettings"/>
13+
<waitForPageLoad stepKey="waitForWebConfigurationPageLoad"/>
14+
<scrollTo selector="{{AdminDefaultCookieSettingsSection.DefaultCookieSettingsTab}}" x="-150" y="-150" stepKey="scrollToDefaultCookieSettingsSection"/>
15+
<conditionalClick stepKey="expandDefaultCookieSettingsTab" selector="{{AdminDefaultCookieSettingsSection.DefaultCookieSettingsTab}}" dependentSelector="{{AdminDefaultCookieSettingsSection.DefaultCookieLifetime}}" visible="false"/>
16+
<waitForElementVisible selector="{{AdminDefaultCookieSettingsSection.DefaultCookieSettingsTab}}" stepKey="waitForElementsAppeared"/>
17+
</actionGroup>
18+
</actionGroups>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
11+
<page name="AdminConfigurationDefaultCookieSettingsPage" url="admin/system_config/edit/section/web/" module="Cookie" area="admin">
12+
<section name="AdminDefaultCookieSettingsSection"/>
13+
</page>
14+
</pages>
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="AdminDefaultCookieSettingsSection">
12+
<element name="DefaultCookieSettingsTab" type="button" selector="#web_cookie-head"/>
13+
<element name="DefaultCookieLifetime" type="input" selector="#web_cookie_cookie_lifetime"/>
14+
</section>
15+
</sections>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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="AdminValidateCookieLifetimeTest">
12+
<annotations>
13+
<features value="Cookie"/>
14+
<stories value="Validate cookie lifetime field in Magento admin"/>
15+
<title value="Admin should not able to enter text in cookie lifetime filed"/>
16+
<description value="Admin can only be able type numbers in cookie lifetime filed in Magento admin"/>
17+
<group value="Cookie"/>
18+
</annotations>
19+
<before>
20+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginGetFromGeneralFile"/>
21+
</before>
22+
<after>
23+
<actionGroup ref="AdminLogoutActionGroup" stepKey="adminLogout"/>
24+
</after>
25+
<actionGroup ref="AdminNavigateToDefaultCookieSettingsActionGroup" stepKey="navigateToDefaultCookieSettingsPage"/>
26+
<actionGroup ref="AdminUncheckUseSystemValueActionGroup" stepKey="uncheckUseSystemValue">
27+
<argument name="rowId" value="row_web_cookie_cookie_lifetime"/>
28+
</actionGroup>
29+
<actionGroup ref="AdminFillCookieLifetimeActionGroup" stepKey="fillCookieLifetimeField">
30+
<argument name="cookieLifetime" value="cookie"/>
31+
</actionGroup>
32+
<actionGroup ref="AdminClickFormActionButtonActionGroup" stepKey="clickSaveButtonWithString">
33+
<argument name="buttonSelector" value="{{AdminMainActionsSection.save}}"/>
34+
</actionGroup>
35+
<actionGroup ref="AssertAdminValidationErrorActionGroup" stepKey="assertNumberValidation">
36+
<argument name="inputId" value="web_cookie_cookie_lifetime"/>
37+
<argument name="errorMessage" value="Please enter a valid number in this field."/>
38+
</actionGroup>
39+
<actionGroup ref="AdminFillCookieLifetimeActionGroup" stepKey="fillCookieLifetimeFieldWithNumber">
40+
<argument name="cookieLifetime" value="3600"/>
41+
</actionGroup>
42+
<actionGroup ref="AdminCheckUseSystemValueActionGroup" stepKey="checkUseSystemValue">
43+
<argument name="rowId" value="row_web_cookie_cookie_lifetime"/>
44+
</actionGroup>
45+
<actionGroup ref="AdminClickFormActionButtonActionGroup" stepKey="clickSaveButtonWithNumber">
46+
<argument name="buttonSelector" value="{{AdminMainActionsSection.save}}"/>
47+
</actionGroup>
48+
<actionGroup ref="AssertMessageInAdminPanelActionGroup" stepKey="assertSaveCookieLifetimeSuccessMessage">
49+
<argument name="message" value="You saved the configuration."/>
50+
<argument name="messageType" value="success"/>
51+
</actionGroup>
52+
</test>
53+
</tests>

app/code/Magento/Cookie/etc/adminhtml/system.xml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,21 @@
1010
<section id="web">
1111
<group id="cookie" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
1212
<label>Default Cookie Settings</label>
13-
<field id="cookie_lifetime" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
13+
<field id="cookie_lifetime" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
1414
<label>Cookie Lifetime</label>
1515
<backend_model>Magento\Cookie\Model\Config\Backend\Lifetime</backend_model>
16+
<comment>Enter the Cookie Lifetime in seconds.</comment>
17+
<validate>validate-number</validate>
1618
</field>
17-
<field id="cookie_path" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
19+
<field id="cookie_path" translate="label comment" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
1820
<label>Cookie Path</label>
1921
<backend_model>Magento\Cookie\Model\Config\Backend\Path</backend_model>
22+
<comment>Enter a valid cookie path. e.g. /</comment>
2023
</field>
21-
<field id="cookie_domain" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
24+
<field id="cookie_domain" translate="label comment" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
2225
<label>Cookie Domain</label>
2326
<backend_model>Magento\Cookie\Model\Config\Backend\Domain</backend_model>
27+
<comment>Enter a valid domain name. e.g. "subdomain.yourdomain.com", ".yourdomain.com"</comment>
2428
</field>
2529
<field id="cookie_httponly" translate="label comment" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
2630
<label>Use HTTP Only</label>
@@ -29,10 +33,11 @@
2933
</comment>
3034
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
3135
</field>
32-
<field id="cookie_restriction" translate="label" type="select" sortOrder="50" showInDefault="1" showInWebsite="1" canRestore="1">
36+
<field id="cookie_restriction" translate="label comment" type="select" sortOrder="50" showInDefault="1" showInWebsite="1" canRestore="1">
3337
<label>Cookie Restriction Mode</label>
3438
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
3539
<backend_model>Magento\Cookie\Model\Config\Backend\Cookie</backend_model>
40+
<comment>When Cookie Restriction Mode is enabled, visitors to your store are notified that cookies are required for full-featured operations.</comment>
3641
</field>
3742
</group>
3843
</section>

app/code/Magento/Cookie/i18n/en_US.csv

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@
1212
"Use HTTP Only","Use HTTP Only"
1313
"Cookie Restriction Mode","Cookie Restriction Mode"
1414
"Cookies are disabled in your browser.","Cookies are disabled in your browser."
15-
15+
"Enter the Cookie Lifetime in seconds.","Enter the Cookie Lifetime in seconds."
16+
"Enter a valid cookie path. e.g. /","Enter a valid cookie path. e.g. /"
17+
"Enter a valid domain name. e.g. ""subdomain.yourdomain.com"", "".yourdomain.com""","Enter a valid domain name. e.g. ""subdomain.yourdomain.com"", "".yourdomain.com"""
18+
"When Cookie Restriction Mode is enabled, visitors to your store are notified that cookies are required for full-featured operations.","When Cookie Restriction Mode is enabled, visitors to your store are notified that cookies are required for full-featured operations."

0 commit comments

Comments
 (0)