Skip to content

Commit 5621862

Browse files
committed
ACP2E-1092: [Automation] Please automate AC-3635 for MC-36096
1 parent bab1f54 commit 5621862

File tree

3 files changed

+137
-0
lines changed

3 files changed

+137
-0
lines changed

app/code/Magento/Cookie/Test/Mftf/Section/AdminDefaultCookieSettingsSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@
1111
<section name="AdminDefaultCookieSettingsSection">
1212
<element name="DefaultCookieSettingsTab" type="button" selector="#web_cookie-head"/>
1313
<element name="DefaultCookieLifetime" type="input" selector="#web_cookie_cookie_lifetime"/>
14+
<element name="DefaultCookieLifetimeSystemValueCheckbox" type="input" selector="#web_cookie_cookie_lifetime_inherit"/>
15+
<element name="Save" type="button" selector="#save"/>
1416
</section>
1517
</sections>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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="StorefrontVerifyCustomerDefaultCookieExpiryDateActionGroup">
12+
<annotations>
13+
<description>Verify a customer's cookies expiry date on browser's local storage in storefront</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="timezoneOffset" type="string" defaultValue="0"/>
17+
<argument name="timeUnit" type="string" defaultValue="minute"/>
18+
</arguments>
19+
20+
<!--Verify that there are cookies exists with the given name `section_data_ids`, `mage-cache-sessid`, `mage-cache-storage`-->
21+
<seeCookie userInput="section_data_ids" stepKey="seeCookieForMagentoSectionDataIds"/>
22+
<seeCookie userInput="mage-cache-sessid" stepKey="seeCookieForMagentoCacheSessionId"/>
23+
<seeCookie userInput="mage-cache-storage" stepKey="seeCookieForMagentoCacheStorage"/>
24+
25+
<!--Grab the cookies attribute with the given names `section_data_ids`, `mage-cache-sessid`, `mage-cache-storage-->
26+
<grabCookieAttributes userInput="section_data_ids" stepKey="grabCookieForMagentoDataIds"/>
27+
<grabCookieAttributes userInput="mage-cache-sessid" stepKey="grabCookieForMagentoCacheSessionId"/>
28+
<grabCookieAttributes userInput="mage-cache-storage" stepKey="grabCookieForMagentoCacheStorage"/>
29+
30+
<!--Grab expected date-->
31+
<generateDate date="{{timezoneOffset}} {{timeUnit}}" format="d/m/Y" timezone="UTC" stepKey="generateExpireDate"/>
32+
33+
<!--Assert cookies `section_data_ids`, `mage-cache-sessid`, `mage-cache-storage` having expiry date equal to expected date-->
34+
<assertEquals stepKey="validateExpiryDateForMagentoDataIds">
35+
<actualResult type="string">{{$grabCookieForMagentoDataIds['expiry']}}</actualResult>
36+
<expectedResult type="string">{{$generateExpireDate}}</expectedResult>
37+
</assertEquals>
38+
<assertEquals stepKey="validateExpiryDateForMagentoCacheSessionId">
39+
<actualResult type="string">{{$grabCookieForMagentoCacheSessionId['expiry']}}</actualResult>
40+
<expectedResult type="string">{{$generateExpireDate}}</expectedResult>
41+
</assertEquals>
42+
<assertEquals stepKey="validateExpiryDateForMagentoCacheStorage">
43+
<actualResult type="string">{{$grabCookieForMagentoCacheStorage['expiry']}}</actualResult>
44+
<expectedResult type="string">{{$generateExpireDate}}</expectedResult>
45+
</assertEquals>
46+
</actionGroup>
47+
</actionGroups>
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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="StorefrontRetainLocalCacheStorageTest">
12+
<annotations>
13+
<features value="Customer"/>
14+
<stories value="Local cache storage is not retained for the expected period."/>
15+
<title value="Verify that Local cache storage is retained for the expected period."/>
16+
<description value="Verify that Local cache storage is retained for the expected period."/>
17+
<severity value="AVERAGE"/>
18+
<testCaseId value="AC-3635"/>
19+
<group value="customer"/>
20+
</annotations>
21+
<before>
22+
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
23+
<magentoCLI command="config:set general/locale/timezone UTC" stepKey="setTimezone"/>
24+
</before>
25+
<after>
26+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
27+
<magentoCLI command="config:set general/locale/timezone America/Los_Angeles" stepKey="setTimezone"/>
28+
<!--Restore default configuration settings.-->
29+
<magentoCLI command="config:set {{DefaultWebCookieLifetimeConfigData.path}} {{DefaultWebCookieLifetimeConfigData.value}}" stepKey="setDefaultCookieLifetime"/>
30+
<!--Clear cache and perform reindex-->
31+
<magentoCLI command="indexer:reindex" stepKey="performReindex"/>
32+
<magentoCLI command="cache:clean" stepKey="cleanCache"/>
33+
<magentoCLI command="cache:flush" stepKey="flushCache"/>
34+
</after>
35+
<!--Login to storefront from customer-->
36+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginCustomer">
37+
<argument name="Customer" value="$$createCustomer$$"/>
38+
</actionGroup>
39+
<see userInput="Welcome, $$createCustomer.firstname$$ $$createCustomer.lastname$$!" selector="{{StorefrontPanelHeaderSection.welcomeMessage}}" stepKey="checkWelcomeMessage"/>
40+
41+
<!--Grab timezone offset-->
42+
<executeJS function="return new Date().getTimezoneOffset();" stepKey="getTimezoneOffset"/>
43+
<actionGroup ref="StorefrontVerifyCustomerDefaultCookieExpiryDateActionGroup" stepKey="VerifyCookiesExpiryDate">
44+
<argument name="timezoneOffset" value="{$getTimezoneOffset}"/>
45+
</actionGroup>
46+
47+
<!--Logout customer before in case of it logged in from previous test-->
48+
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="customerLogoutStorefront"/>
49+
50+
<!--Login as admin-->
51+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
52+
<actionGroup ref="AssertAdminSuccessLoginActionGroup" stepKey="assertLoggedIn"/>
53+
54+
<!--Clear browser locale storage for magento site-->
55+
<resetCookie userInput="section_data_ids" stepKey="resetCookieForMagentoCacheSectionDataIds"/>
56+
<resetCookie userInput="mage-cache-sessid" stepKey="resetCookieForMagentoCacheSessionId"/>
57+
<resetCookie userInput="mage-cache-storage" stepKey="resetCookieForMagentoCacheStorage"/>
58+
59+
<!--Set-Cookie Lifetime to 30 days (2592000) under Stores > Configuration > General > Web > Default Cookie Settings-->
60+
<actionGroup ref="AdminNavigateToDefaultCookieSettingsActionGroup" stepKey="goToCurrencySetupPage"/>
61+
<!--Ensure the checkbox `use system value` is unchecked.-->
62+
<uncheckOption selector="{{AdminDefaultCookieSettingsSection.DefaultCookieLifetimeSystemValueCheckbox}}" stepKey="uncheckCheckboxForSystemValue"/>
63+
<fillField userInput="2592000" selector="{{AdminDefaultCookieSettingsSection.DefaultCookieLifetime}}" stepKey="fillDefaultLabel"/>
64+
<click selector="{{AdminDefaultCookieSettingsSection.Save}}" stepKey="clickSaveConfig"/>
65+
66+
<!--Clear cache and perform reindex-->
67+
<actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex">
68+
<argument name="indices" value=""/>
69+
</actionGroup>
70+
<actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanInvalidatedCaches">
71+
<argument name="tags" value=""/>
72+
</actionGroup>
73+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/>
74+
75+
<!--Login storefront again using registered customer credentials-->
76+
<actionGroup ref="StorefrontOpenCustomerLoginPageActionGroup" stepKey="goToSignInPage"/>
77+
<actionGroup ref="StorefrontFillCustomerLoginFormActionGroup" stepKey="fillLoginFormWithCustomerData">
78+
<argument name="customer" value="$$createCustomer$$"/>
79+
</actionGroup>
80+
<actionGroup ref="StorefrontClickSignOnCustomerLoginFormActionGroup" stepKey="clickSignInAccountButtonFirstAttempt"/>
81+
82+
<!--Grab current timezone offset after 30 days-->
83+
<executeJS function="return {$getTimezoneOffset} + (30*24*60);" stepKey="getTimezoneOffsetAfterReset"/>
84+
<actionGroup ref="StorefrontVerifyCustomerDefaultCookieExpiryDateActionGroup" stepKey="VerifyCookiesExpiryDateAfterReset">
85+
<argument name="timezoneOffset" value="{$getTimezoneOffsetAfterReset}"/>
86+
</actionGroup>
87+
</test>
88+
</tests>

0 commit comments

Comments
 (0)