Skip to content

Commit 5588999

Browse files
authored
Merge pull request #4430 from magento-tsg-csl3/2.3-develop-pr27
[TSG-CSL3] For 2.3 (pr27)
2 parents f94b4a8 + 660fe3e commit 5588999

File tree

6 files changed

+128
-19
lines changed

6 files changed

+128
-19
lines changed
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+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<entity name="ChangedCookieDomainForMainWebsiteConfigData">
12+
<data key="path">web/cookie/cookie_domain</data>
13+
<data key="scope">website</data>
14+
<data key="scope_code">base</data>
15+
<data key="value">testDomain.com</data>
16+
</entity>
17+
<entity name="EmptyCookieDomainForMainWebsiteConfigData">
18+
<data key="path">web/cookie/cookie_domain</data>
19+
<data key="scope">website</data>
20+
<data key="scope_code">base</data>
21+
<data key="value">''</data>
22+
</entity>
23+
</entities>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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="AdminLoginAfterChangeCookieDomainTest">
12+
<annotations>
13+
<features value="Backend"/>
14+
<stories value="Login on the Admin Backend"/>
15+
<title value="Admin user can login after changing cookie domain on main website scope without changing cookie domain on default scope"/>
16+
<description value="Admin user can login after changing cookie domain on main website scope without changing cookie domain on default scope"/>
17+
<severity value="CRITICAL"/>
18+
<testCaseId value="MC-17847"/>
19+
<useCaseId value="MC-17275"/>
20+
<group value="backend"/>
21+
</annotations>
22+
<before>
23+
<magentoCLI command="config:set {{ChangedCookieDomainForMainWebsiteConfigData.path}} --scope={{ChangedCookieDomainForMainWebsiteConfigData.scope}} --scope-code={{ChangedCookieDomainForMainWebsiteConfigData.scope_code}} {{ChangedCookieDomainForMainWebsiteConfigData.value}}" stepKey="changeDomainForMainWebsiteBeforeTestRun"/>
24+
<magentoCLI command="cache:flush config" stepKey="flushCacheBeforeTestRun"/>
25+
</before>
26+
<after>
27+
<magentoCLI command="config:set {{EmptyCookieDomainForMainWebsiteConfigData.path}} --scope={{EmptyCookieDomainForMainWebsiteConfigData.scope}} --scope-code={{EmptyCookieDomainForMainWebsiteConfigData.scope_code}} {{EmptyCookieDomainForMainWebsiteConfigData.value}}" stepKey="changeDomainForMainWebsiteAfterTestComplete"/>
28+
<magentoCLI command="cache:flush config" stepKey="flushCacheAfterTestComplete"/>
29+
</after>
30+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
31+
<actionGroup ref="AssertAdminDashboardPageIsVisibleActionGroup" stepKey="seeDashboardPage"/>
32+
<actionGroup ref="logout" stepKey="logoutFromAdmin"/>
33+
</test>
34+
</tests>

app/code/Magento/Backend/etc/adminhtml/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
<arguments>
8787
<argument name="lifetimePath" xsi:type="const">Magento\Backend\Model\Auth\Session::XML_PATH_SESSION_LIFETIME</argument>
8888
<argument name="sessionName" xsi:type="const">Magento\Backend\Model\Session\AdminConfig::SESSION_NAME_ADMIN</argument>
89+
<argument name="scopeType" xsi:type="const">Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT</argument>
8990
</arguments>
9091
</type>
9192
<type name="Magento\Framework\View\Result\PageFactory">

app/code/Magento/Ui/view/base/web/js/form/element/date.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,24 +114,26 @@ define([
114114
* @param {String} value
115115
*/
116116
onValueChange: function (value) {
117-
var dateFormat,
118-
shiftedValue;
117+
var shiftedValue;
119118

120119
if (value) {
121120
if (this.options.showsTime) {
122121
shiftedValue = moment.tz(value, 'UTC').tz(this.storeTimeZone);
123122
} else {
124-
dateFormat = this.shiftedValue() ? this.outputDateFormat : this.inputDateFormat;
125-
shiftedValue = moment(value, dateFormat);
123+
shiftedValue = moment(value, this.outputDateFormat);
126124
}
127125

128-
shiftedValue = shiftedValue.format(this.pickerDateTimeFormat);
129-
130-
if (shiftedValue !== this.shiftedValue()) {
131-
this.shiftedValue(shiftedValue);
126+
if (!shiftedValue.isValid()) {
127+
shiftedValue = moment(value, this.inputDateFormat);
132128
}
129+
shiftedValue = shiftedValue.format(this.pickerDateTimeFormat);
130+
} else {
131+
shiftedValue = '';
133132
}
134133

134+
if (shiftedValue !== this.shiftedValue()) {
135+
this.shiftedValue(shiftedValue);
136+
}
135137
},
136138

137139
/**

app/code/Magento/Ui/view/base/web/js/lib/knockout/bindings/datepicker.js

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,29 +41,60 @@ define([
4141

4242
if (typeof config === 'object') {
4343
observable = config.storage;
44-
4544
_.extend(options, config.options);
4645
} else {
4746
observable = config;
4847
}
4948

5049
$(el).calendar(options);
5150

52-
observable() && $(el).datepicker(
53-
'setDate',
54-
moment(
51+
ko.utils.registerEventHandler(el, 'change', function () {
52+
observable(this.value);
53+
});
54+
},
55+
56+
/**
57+
* Update calendar widget on element and stores it's value to observable property.
58+
* Datepicker binding takes either observable property or object
59+
* { storage: {ko.observable}, options: {Object} }.
60+
* @param {HTMLElement} element - Element, that binding is applied to
61+
* @param {Function} valueAccessor - Function that returns value, passed to binding
62+
*/
63+
update: function (element, valueAccessor) {
64+
var config = valueAccessor(),
65+
observable,
66+
options = {},
67+
newVal;
68+
69+
_.extend(options, defaults);
70+
71+
if (typeof config === 'object') {
72+
observable = config.storage;
73+
_.extend(options, config.options);
74+
} else {
75+
observable = config;
76+
}
77+
78+
if (_.isEmpty(observable())) {
79+
if ($(element).datepicker('getDate')) {
80+
$(element).datepicker('setDate', null);
81+
$(element).blur();
82+
}
83+
} else {
84+
newVal = moment(
5585
observable(),
5686
utils.convertToMomentFormat(
5787
options.dateFormat + (options.showsTime ? ' ' + options.timeFormat : '')
5888
)
59-
).toDate()
60-
);
89+
).toDate();
6190

62-
$(el).blur();
63-
64-
ko.utils.registerEventHandler(el, 'change', function () {
65-
observable(this.value);
66-
});
91+
if ($(element).datepicker('getDate') == null ||
92+
newVal.valueOf() !== $(element).datepicker('getDate').valueOf()
93+
) {
94+
$(element).datepicker('setDate', newVal);
95+
$(element).blur();
96+
}
97+
}
6798
}
6899
};
69100
});

dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/ko/bind/datepicker.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,23 @@ define([
5353

5454
expect(todayDate).toEqual(result);
5555
});
56+
57+
it('update picked date\'s value after update observable value', function () {
58+
var date = '06/21/2019',
59+
inputFormat = 'M/d/yy',
60+
expectedDate;
61+
62+
expectedDate = moment(date, utils.convertToMomentFormat(inputFormat)).toDate();
63+
observable(date);
64+
65+
expect(expectedDate.valueOf()).toEqual(element.datepicker('getDate').valueOf());
66+
});
67+
68+
it('clear picked date\'s value after clear observable value', function () {
69+
element.datepicker('setTimezoneDate').blur().trigger('change');
70+
observable('');
71+
72+
expect(null).toEqual(element.datepicker('getDate'));
73+
});
5674
});
5775
});

0 commit comments

Comments
 (0)