Skip to content

Commit 9be708b

Browse files
committed
MC-32766: Page builder issue with secure variable
- Add jasmine test coverage for text/preview component
1 parent fed8d2a commit 9be708b

File tree

1 file changed

+94
-0
lines changed
  • dev/tests/js/jasmine/tests/app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/text

1 file changed

+94
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
/* eslint-disable max-nested-callbacks */
7+
/* eslint-disable max-depth */
8+
/* jscs:disable jsDoc*/
9+
define([
10+
'Magento_PageBuilder/js/content-type/text/preview',
11+
'Magento_PageBuilder/js/content-type'
12+
], function (Preview, ContentType) {
13+
'use strict';
14+
15+
describe('Magento_PageBuilder/js/content-type/text/preview', function () {
16+
var preview;
17+
18+
function ObservableUpdater() {}
19+
ObservableUpdater.prototype.update = function () {};
20+
21+
beforeEach(function () {
22+
var contentType,
23+
config,
24+
observableUpdater;
25+
26+
observableUpdater = new ObservableUpdater();
27+
config = {
28+
name: 'text',
29+
label: 'Text'
30+
};
31+
contentType = new ContentType(null, config);
32+
preview = new Preview(contentType, config, observableUpdater);
33+
});
34+
35+
describe('Text component content change', function () {
36+
it('Should replace double quote with single quote if the directive is not in html attr', function () {
37+
var actual = '<p>' +
38+
'<a title="Contact Us" href="{{config path="web/secure/base_url"}}contact">Contact Us</a>' +
39+
'</p>',
40+
expected = '<p>' +
41+
'<a title="Contact Us" href="{{config path=\'web/secure/base_url\'}}contact">Contact Us</a>' +
42+
'</p>';
43+
44+
preview.contentType.dataStore.setState({
45+
content: actual
46+
});
47+
expect(preview.contentType.dataStore.get('content')).toBe(expected);
48+
});
49+
it('Should not replace double quote with single quote if the directive is not in html attr', function () {
50+
var actual = '<p>Our website:</p><p>{{config path="web/secure/base_url"}}</p>',
51+
expected = actual;
52+
53+
preview.contentType.dataStore.setState({
54+
content: actual
55+
});
56+
expect(preview.contentType.dataStore.get('content')).toBe(expected);
57+
});
58+
});
59+
});
60+
61+
if (typeof Object.assign !== 'function') {
62+
// Must be writable: true, enumerable: false, configurable: true
63+
Object.defineProperty(Object, 'assign', {
64+
value: function assign(target) { // .length of function is 2
65+
var to,
66+
index,
67+
nextKey,
68+
nextSource;
69+
70+
if (target === null || target === undefined) {
71+
throw new TypeError('Cannot convert undefined or null to object');
72+
}
73+
to = Object(target);
74+
75+
for (index = 1; index < arguments.length; index++) {
76+
nextSource = arguments[index];
77+
78+
if (nextSource !== null && nextSource !== undefined) {
79+
for (nextKey in nextSource) {
80+
// Avoid bugs when hasOwnProperty is shadowed
81+
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
82+
to[nextKey] = nextSource[nextKey];
83+
}
84+
}
85+
}
86+
}
87+
88+
return to;
89+
},
90+
writable: true,
91+
configurable: true
92+
});
93+
}
94+
});

0 commit comments

Comments
 (0)