Skip to content

Commit 974868e

Browse files
committed
Merge branch '2.3-develop' into MQE-975
2 parents 22cfcc9 + 18a7e29 commit 974868e

File tree

11 files changed

+196
-13
lines changed

11 files changed

+196
-13
lines changed

app/code/Magento/Cms/Helper/Wysiwyg/Images.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
/**
1111
* Wysiwyg Images Helper.
12-
*
13-
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1412
*/
1513
class Images extends \Magento\Framework\App\Helper\AbstractHelper
1614
{

app/code/Magento/Cms/view/adminhtml/web/js/folder-tree.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ define([
9494

9595
lastExistentFolderEl = folderEl;
9696

97-
if (path.length > 1) {
97+
if (path.length) {
9898
tree.jstree('open_node', folderEl, recursiveOpen);
9999
} else {
100100
tree.jstree('open_node', folderEl, function () {

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Section/AdminProductFormSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@
104104
<element name="AcceptFolderName" type="button" selector=".action-primary.action-accept" />
105105
<element name="StorageRootArrow" type="button" selector="#root > .jstree-icon" />
106106
<element name="checkIfArrowExpand" type="button" selector="//li[@id='root' and contains(@class,'jstree-closed')]" />
107+
<element name="WysiwygArrow" type="button" selector="#d3lzaXd5Zw-- > .jstree-icon" />
108+
<element name="checkIfWysiwygArrowExpand" type="button" selector="//li[@id='d3lzaXd5Zw--' and contains(@class,'jstree-closed')]" />
107109
<element name="confirmDelete" type="button" selector=".action-primary.action-accept" />
108110
</section>
109111
<section name="ProductShortDescriptionWYSIWYGToolbarSection">

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Test/AdminAddImageToWYSIWYGProductTest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
<fillField selector="{{ProductDescriptionWYSIWYGToolbarSection.FolderName}}" userInput="{{ImageFolder.name}}" stepKey="fillFolderName1" />
4646
<click selector="{{ProductDescriptionWYSIWYGToolbarSection.AcceptFolderName}}" stepKey="acceptFolderName11" />
4747
<waitForLoadingMaskToDisappear stepKey="waitForLoading3" />
48-
<conditionalClick selector="{{ProductDescriptionWYSIWYGToolbarSection.StorageRootArrow}}" dependentSelector="{{ProductDescriptionWYSIWYGToolbarSection.checkIfArrowExpand}}" stepKey="clickArrowIfCloses1" visible="true"/>
48+
<conditionalClick selector="{{ProductDescriptionWYSIWYGToolbarSection.StorageRootArrow}}" dependentSelector="{{ProductDescriptionWYSIWYGToolbarSection.checkIfArrowExpand}}" stepKey="clickStorageRootArrowIfClosed" visible="true"/>
49+
<conditionalClick selector="{{ProductDescriptionWYSIWYGToolbarSection.WysiwygArrow}}" dependentSelector="{{ProductDescriptionWYSIWYGToolbarSection.checkIfWysiwygArrowExpand}}" stepKey="clickWysiwygArrowIfClosed" visible="true"/>
4950
<waitForText userInput="{{ImageFolder.name}}" stepKey="waitForNewFolder1" />
5051
<click userInput="{{ImageFolder.name}}" stepKey="clickOnCreatedFolder1" />
5152
<waitForLoadingMaskToDisappear stepKey="waitForLoading4" />

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Data/CmsPageData.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
<data key="content">Sample page content. Yada yada yada.</data>
1515
<data key="identifier" unique="suffix">test-page-</data>
1616
</entity>
17+
<entity name="_newDefaultCmsPage" type="cms_page">
18+
<data key="title" unique="suffix">Test CMS Page</data>
19+
<data key="content_heading">Test Content Heading</data>
20+
<data key="content">Sample page content. Yada yada yada.</data>
21+
<data key="identifier" unique="suffix">test-page-</data>
22+
</entity>
1723
<entity name="_duplicatedCMSPage" type="cms_page">
1824
<data key="title">testpage</data>
1925
<data key="content_heading">Test Content Heading</data>
@@ -33,6 +39,7 @@
3339
<data key="shareable">Yes</data>
3440
<data key="value">magento.jpg</data>
3541
<data key="fileName">magento</data>
42+
<data key="extension">jpg</data>
3643
<data key="content">Image content. Yeah.</data>
3744
<data key="height">1000</data>
3845
</entity>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Test/VerifyTinyMCEv4IsNativeWYSIWYGOnNewsletterTest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
<description value="Admin see TinyMCEv4.6 is native WYSIWYG on Newsletter"/>
1717
<severity value="CRITICAL"/>
1818
<testCaseId value="MAGETWO-84683"/>
19-
<!-- MAGETWO-90659 -->
20-
<group value="skip"/>
2119
</annotations>
2220
<before>
2321
<actionGroup ref="LoginActionGroup" stepKey="loginGetFromGeneralFile"/>
@@ -30,6 +28,7 @@
3028
<fillField selector="{{BasicFieldNewsletterSection.templateSubject}}" userInput="{{_defaultNewsletter.subject}}" stepKey="fillTemplateSubject" />
3129
<fillField selector="{{BasicFieldNewsletterSection.senderName}}" userInput="{{_defaultNewsletter.senderName}}" stepKey="fillSenderName" />
3230
<fillField selector="{{BasicFieldNewsletterSection.senderEmail}}" userInput="{{_defaultNewsletter.senderEmail}}" stepKey="fillSenderEmail" />
31+
<conditionalClick selector="#toggletext" dependentSelector=".mce-tinymce" visible="false" stepKey="clickBtnIfTinyMCEHidden"/>
3332
<actionGroup ref="VerifyTinyMCEActionGroup" stepKey="verifyTinyMCE4"/>
3433
<actionGroup ref="VerifyMagentoEntityActionGroup" stepKey="verifyMagentoEntities"/>
3534
<executeJS function="tinyMCE.get('text').setContent('Hello World From Newsletter Template!');" stepKey="executeJSFillContent"/>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Variable/ActionGroup/CreateCustomVariableActionGroup.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<waitForPageLoad stepKey="waitForPageLoad1" />
2323
<click selector="{{CustomVariableSection.GridCustomVariableCode(customVariable.code)}}" stepKey="goToCustomVariableEditPage" />
2424
<waitForPageLoad stepKey="waitForPageLoad2" />
25+
<waitForElementVisible selector="{{CustomVariableSection.delete}}" stepKey="waitForDeleteBtn" />
2526
<click selector="{{CustomVariableSection.delete}}" stepKey="deleteCustomVariable" />
2627
<waitForText userInput="Are you sure you want to do this?" stepKey="waitForText" />
2728
<click selector="{{CustomVariableSection.confirmDelete}}" stepKey="confirmDelete" />

dev/tests/integration/testsuite/Magento/Cms/Helper/Wysiwyg/ImagesTest.php

Lines changed: 109 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,20 @@
66
namespace Magento\Cms\Helper\Wysiwyg;
77

88
use Magento\Framework\App\Filesystem\DirectoryList;
9+
use Magento\TestFramework\ObjectManager;
910

1011
class ImagesTest extends \PHPUnit\Framework\TestCase
1112
{
13+
/**
14+
* @var ObjectManager
15+
*/
16+
private $objectManager;
17+
18+
protected function setUp()
19+
{
20+
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
21+
}
22+
1223
public function testGetStorageRoot()
1324
{
1425
/** @var \Magento\Framework\Filesystem $filesystem */
@@ -17,17 +28,112 @@ public function testGetStorageRoot()
1728
);
1829
$mediaPath = $filesystem->getDirectoryRead(DirectoryList::MEDIA)->getAbsolutePath();
1930
/** @var \Magento\Cms\Helper\Wysiwyg\Images $helper */
20-
$helper = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
31+
$helper = $this->objectManager->create(
2132
\Magento\Cms\Helper\Wysiwyg\Images::class
2233
);
2334
$this->assertStringStartsWith($mediaPath, $helper->getStorageRoot());
2435
}
2536

37+
/**
38+
* @magentoConfigFixture current_store web/unsecure/base_url http://example.com/
39+
*/
2640
public function testGetCurrentUrl()
2741
{
28-
$helper = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
42+
/** @var \Magento\Cms\Helper\Wysiwyg\Images $helper */
43+
$helper = $this->objectManager->create(
2944
\Magento\Cms\Helper\Wysiwyg\Images::class
3045
);
31-
$this->assertStringStartsWith('http://localhost/', $helper->getCurrentUrl());
46+
$this->assertStringStartsWith('http://example.com/', $helper->getCurrentUrl());
47+
}
48+
49+
/**
50+
* @param bool $isStaticUrlsAllowed
51+
* @param string $filename
52+
* @param bool $renderAsTag
53+
* @param string|callable $expectedResult - string or callable to make unique assertions on $expectedResult
54+
* @magentoConfigFixture current_store web/unsecure/base_url http://example.com/
55+
* @dataProvider providerGetImageHtmlDeclaration
56+
*/
57+
public function testGetImageHtmlDeclaration(
58+
$isStaticUrlsAllowed,
59+
$filename,
60+
$renderAsTag,
61+
$expectedResult
62+
) {
63+
$helper = $this->generateHelper($isStaticUrlsAllowed);
64+
65+
$actualResult = $helper->getImageHtmlDeclaration($filename, $renderAsTag);
66+
67+
if (is_callable($expectedResult)) {
68+
$expectedResult($actualResult);
69+
} else {
70+
$this->assertEquals(
71+
$expectedResult,
72+
$actualResult
73+
);
74+
}
75+
}
76+
77+
/**
78+
* Data provider for testGetImageHtmlDeclaration
79+
*
80+
* @return array
81+
*/
82+
public function providerGetImageHtmlDeclaration()
83+
{
84+
return [
85+
[true, 'wysiwyg/hello.png', true, '<img src="http://example.com/pub/media/wysiwyg/hello.png" alt="" />'],
86+
[
87+
false,
88+
'wysiwyg/hello.png',
89+
false,
90+
function ($actualResult) {
91+
$expectedResult = (
92+
'/backend/cms/wysiwyg/directive/___directive/' .
93+
'e3ttZWRpYSB1cmw9Ind5c2l3eWcvaGVsbG8ucG5nIn19/'
94+
);
95+
96+
$this->assertContains($expectedResult, parse_url($actualResult, PHP_URL_PATH));
97+
}
98+
],
99+
[true, 'wysiwyg/hello.png', false, 'http://example.com/pub/media/wysiwyg/hello.png'],
100+
[false, 'wysiwyg/hello.png', true, '<img src="{{media url=&quot;wysiwyg/hello.png&quot;}}" alt="" />'],
101+
];
102+
}
103+
104+
/**
105+
* Generate instance of Images Helper
106+
*
107+
* @param bool $isStaticUrlsAllowed - mock is created to override value of isUsingStaticUrlsAllowed method in class
108+
* @return \Magento\Cms\Helper\Wysiwyg\Images
109+
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
110+
*/
111+
private function generateHelper($isStaticUrlsAllowed = false)
112+
{
113+
$storeId = 1;
114+
115+
$eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class);
116+
117+
$contextMock = $this->objectManager->create(\Magento\Framework\App\Helper\Context::class, [
118+
'eventManager' => $eventManagerMock,
119+
]);
120+
121+
$helper = $this->objectManager->create(\Magento\Cms\Helper\Wysiwyg\Images::class, [
122+
'context' => $contextMock
123+
]);
124+
125+
$checkResult = new \stdClass();
126+
$checkResult->isAllowed = false;
127+
128+
$eventManagerMock->expects($this->any())
129+
->method('dispatch')
130+
->with('cms_wysiwyg_images_static_urls_allowed', ['result' => $checkResult, 'store_id' => $storeId])
131+
->willReturnCallback(function ($_, $arr) use ($isStaticUrlsAllowed) {
132+
$arr['result']->isAllowed = $isStaticUrlsAllowed;
133+
});
134+
135+
$helper->setStoreId($storeId);
136+
137+
return $helper;
32138
}
33139
}

dev/tests/integration/testsuite/Magento/Cms/Model/Wysiwyg/ConfigTest.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,16 @@ public function testGetConfig()
3939
public function testGetConfigCssUrls()
4040
{
4141
$config = $this->model->getConfig();
42-
$publicPathPattern = 'http://localhost/pub/static/%s/adminhtml/Magento/backend/en_US/mage/%s';
42+
$publicPathPattern = 'http://localhost/pub/static/%s/adminhtml/Magento/backend/en_US/%s';
4343
$tinyMce4Config = $config->getData('tinymce4');
44-
$this->assertStringMatchesFormat($publicPathPattern, $tinyMce4Config['content_css']);
44+
$contentCss = $tinyMce4Config['content_css'];
45+
if (is_array($contentCss)) {
46+
foreach ($contentCss as $url) {
47+
$this->assertStringMatchesFormat($publicPathPattern, $url);
48+
}
49+
} else {
50+
$this->assertStringMatchesFormat($publicPathPattern, $contentCss);
51+
}
4552
}
4653

4754
/**
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
/* eslint-disable max-nested-callbacks */
7+
define([
8+
'wysiwygAdapter'
9+
], function (wysiwygAdapter) {
10+
'use strict';
11+
12+
var obj;
13+
14+
beforeEach(function () {
15+
16+
/**
17+
* Dummy constructor to use for instantiation
18+
* @constructor
19+
*/
20+
var Constr = function () {};
21+
22+
Constr.prototype = wysiwygAdapter;
23+
24+
obj = new Constr();
25+
obj.initialize('id', {
26+
'directives_url': 'http://example.com/admin/cms/wysiwyg/directive/'
27+
});
28+
});
29+
30+
describe('wysiwygAdapter', function () {
31+
var decodedHtml = '<p>' +
32+
'<img src="{{media url=&quot;wysiwyg/banana.jpg&quot;}}" alt="" width="612" height="459"></p>',
33+
encodedHtml = '<p>' +
34+
'<img src="http://example.com/admin/cms/wysiwyg/directive/' +
35+
'___directive/e3ttZWRpYSB1cmw9Ind5c2l3eWcvYmFuYW5hLmpwZyJ9fQ%2C%2C" alt="" width="612" height="459">' +
36+
'</p>',
37+
encodedHtmlWithForwardSlashInImgSrc = encodedHtml.replace('%2C%2C', '%2C%2C/');
38+
39+
describe('"encodeDirectives" method', function () {
40+
it('converts media directive img src to directive URL', function () {
41+
expect(obj.encodeDirectives(decodedHtml)).toEqual(encodedHtml);
42+
});
43+
});
44+
45+
describe('"decodeDirectives" method', function () {
46+
it(
47+
'converts directive URL img src without a trailing forward slash ' +
48+
'to media url without a trailing forward slash',
49+
function () {
50+
expect(obj.decodeDirectives(encodedHtml)).toEqual(decodedHtml);
51+
}
52+
);
53+
54+
it('converts directive URL img src with a trailing forward slash ' +
55+
'to media url without a trailing forward slash',
56+
function () {
57+
expect(obj.decodeDirectives(encodedHtmlWithForwardSlashInImgSrc)).toEqual(decodedHtml);
58+
}
59+
);
60+
});
61+
});
62+
});

0 commit comments

Comments
 (0)