Skip to content

Commit 86f2295

Browse files
committed
Merge branch '2.1-develop' of github.com:magento/adobe-stock-integration into 1787-cover-getassetlistinterface-with-integration-test
2 parents fef5956 + bfe916e commit 86f2295

File tree

6 files changed

+158
-20
lines changed

6 files changed

+158
-20
lines changed

AdobeStockAsset/etc/acl.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
<resources>
1111
<resource id="Magento_Backend::admin">
1212
<resource id="Magento_Backend::system">
13-
<resource id="Magento_AdobeStockAsset::adobe_stock_asset" title="Adobe Stock" translate="title" sortOrder="5">
14-
<resource id="Magento_AdobeStockAsset::actions" title="Actions" translate="title">
13+
<resource id="Magento_AdobeStockAsset::adobe_stock_asset" title="Adobe Stock WebAPI" translate="title" sortOrder="5">
14+
<resource id="Magento_AdobeStockAsset::actions" title="WebAPI Actions" translate="title">
1515
<resource id="Magento_AdobeStockAsset::actions_delete" title="Delete" translate="title"/>
1616
<resource id="Magento_AdobeStockAsset::actions_save" title="Save" translate="title"/>
1717
<resource id="Magento_AdobeStockAsset::actions_view" title="View" translate="title"/>
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\AdobeStockClient\Test\Integration\Model\Client;
10+
11+
use AdobeStock\Api\Client\AdobeStock;
12+
use AdobeStock\Api\Models\StockFile;
13+
use AdobeStock\Api\Response\Files as FilesResponse;
14+
use Magento\AdobeStockClient\Model\Client\Files;
15+
use Magento\AdobeStockClient\Model\ConnectionFactory;
16+
use Magento\Framework\Exception\IntegrationException;
17+
use Magento\TestFramework\Helper\Bootstrap;
18+
use PHPUnit\Framework\MockObject\MockObject;
19+
use PHPUnit\Framework\TestCase;
20+
21+
/**
22+
* Test client files for communication to Adobe Stock API.
23+
*/
24+
class FilesTest extends TestCase
25+
{
26+
/**
27+
* @var Files
28+
*/
29+
private $files;
30+
31+
/**
32+
* @var AdobeStock|MockObject
33+
*/
34+
private $connection;
35+
36+
/**
37+
* Prepare objects.
38+
*/
39+
protected function setUp(): void
40+
{
41+
$this->connection = $this->createMock(AdobeStock::class);
42+
$response = $this->createMock(FilesResponse::class);
43+
$response->expects($this->once())
44+
->method('getFiles')
45+
->willReturn($this->getStockFiles());
46+
$this->connection->expects($this->once())
47+
->method('getFiles')
48+
->willReturn($response);
49+
/** @var ConnectionFactory|MockObject $connectionFactory */
50+
$connectionFactory = $this->createMock(ConnectionFactory::class);
51+
$connectionFactory->expects($this->once())
52+
->method('create')
53+
->willReturn($this->connection);
54+
$this->files = Bootstrap::getObjectManager()->create(
55+
Files::class,
56+
[
57+
'connectionFactory' => $connectionFactory
58+
]
59+
);
60+
}
61+
62+
/**
63+
* Test execute method return data.
64+
*
65+
* @throws IntegrationException
66+
*/
67+
public function testExecute(): void
68+
{
69+
$files = $this->files->execute(['1', '2', '3'], []);
70+
71+
$this->assertIsArray($files);
72+
$this->assertCount(3, $files);
73+
$this->assertEquals(
74+
'https://test.url/2',
75+
$files[1]['comp_url']
76+
);
77+
}
78+
79+
/**
80+
* Result files.
81+
*
82+
* @return StockFile[]
83+
*/
84+
private function getStockFiles(): array
85+
{
86+
$stockFilesData = [
87+
[
88+
'id' => 1,
89+
'comp_url' => 'https://test.url/1',
90+
'thumbnail_240_url' => 'https://test.url/1',
91+
'width' => 110,
92+
'height' => 210,
93+
'some_bool_param' => false,
94+
'some_nullable_param' => null,
95+
'category' => [
96+
'id' => 1,
97+
'name' => 'Test'
98+
]
99+
],
100+
[
101+
'id' => 2,
102+
'comp_url' => 'https://test.url/2',
103+
'thumbnail_240_url' => 'https://test.url/2',
104+
'width' => 120,
105+
'height' => 220,
106+
'some_bool_params' => false,
107+
'some_nullable_param' => 1,
108+
'category' => [
109+
'id' => 1,
110+
'name' => 'Test'
111+
]
112+
],
113+
[
114+
'id' => 3,
115+
'comp_url' => 'https://test.url/3',
116+
'thumbnail_240_url' => 'https://test.url/3',
117+
'width' => 130,
118+
'height' => 230,
119+
'some_bool_params' => true,
120+
'some_nullable_param' => 2,
121+
'category' => [
122+
'id' => 1,
123+
'name' => 'Test'
124+
]
125+
],
126+
];
127+
128+
$stockFiles = [];
129+
foreach ($stockFilesData as $stockFileData) {
130+
$stockFiles[] = new StockFile($stockFileData);
131+
}
132+
133+
return $stockFiles;
134+
}
135+
}

AdobeStockImageAdminUi/Test/Mftf/Section/AdminAdobeStockSection.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
<element name="recordsFound" type="text" selector="//*[@id='adobe-stock-images-search-modal']//*[text()='records found']/parent::div"/>
2626
<element name="mediaGalleryImage" type="button" selector="//img[contains(@alt,'{{imageName}}')]" parameterized="true"/>
2727
<element name="mediaGalleryDeleteButton" type="button" selector="[data-ui-id=wysiwyg-images-content-delete-files-button]"/>
28-
<element name="systemAclActions" type="checkbox" selector="//a[text()='Adobe Stock']/parent::li[contains(.,'Actions')]//a"/>
2928
<element name="adobeImsACL" type="checkbox" selector="//a[text()='Adobe IMS']"/>
3029
<element name="adobeSignIn" type="button" selector=".adobe-sign-in-button"/>
3130
<element name="adobeImsPopupUserEmail" type="button" selector="#adobeid_username"/>

AdobeStockImageAdminUi/Test/Mftf/Test/AdminAdobeStockACLTest.xml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717
<description value="User controls access to Adobe Stock images from Admin Panel in ACL"/>
1818
<testCaseId value="https://app.hiptest.com/projects/131313/test-plan/folders/943908/scenarios/3218882"/>
1919
<severity value="MAJOR"/>
20-
<group value="adobe_stock_integration_configuration"/>
20+
<group value="adobe_stock_integration"/>
2121
</annotations>
2222
<before>
2323
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdminBefore"/>
24-
<actionGroup ref="AdminAdobeStockSetConfigActionGroup" stepKey="setCorrectModuleConfig"/>
2524
</before>
2625
<after>
2726
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdminAfter"/>
@@ -47,9 +46,6 @@
4746
<argument name="User" value="adminRole"/>
4847
<argument name="restrictedRole" value="Adobe Stock"/>
4948
</actionGroup>
50-
<scrollTo selector="{{AdminAdobeStockSection.systemAclActions}}" x="0" y="-100" stepKey="scrollToResourceElement"/>
51-
<click stepKey="clickAdobeSystemActions" selector="{{AdminAdobeStockSection.systemAclActions}}"/>
52-
5349
<actionGroup ref="AdminAddRestrictedRoleActionGroup" stepKey="addRestrictedRoleAddEditNewPages">
5450
<argument name="User" value="adminRole"/>
5551
<argument name="restrictedRole" value="Pages"/>

AdobeStockImageAdminUi/view/adminhtml/web/css/source/_module.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,10 @@
317317
.prompt-message {
318318
font-weight: normal;
319319
margin-bottom: 15px;
320+
321+
p {
322+
word-break: break-all;
323+
}
320324
}
321325

322326
.admin__field-wide {

AdobeStockImageAdminUi/view/adminhtml/web/js/components/grid/column/preview/actions.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ define([
180180
if (path !== '') {
181181
this.imageDirectory().locateNode(path);
182182
}
183-
this.selectRecord(this.getRecordFromMediaGalleryProvider(assetDetails.path));
183+
this.selectRecordFromMediaGalleryProvider(assetDetails.path);
184184
}.bind(this));
185185

186186
},
@@ -203,23 +203,27 @@ define([
203203
},
204204

205205
/**
206-
* Get image data by image file name
206+
* Select record by image file name
207207
*
208208
* @param {String} path
209-
* @returns {null|Object}
210209
*/
211-
getRecordFromMediaGalleryProvider: function (path) {
212-
var report = null;
210+
selectRecordFromMediaGalleryProvider: function (path) {
211+
var subscription;
213212

214-
this.imageItems.each(function (item) {
215-
if (item.path === path) {
216-
report = item;
213+
subscription = this.imageItems.subscribe(function (items) {
214+
subscription.dispose();
215+
items.each(function (item) {
216+
if (item.path === path) {
217+
this.selectRecord(item);
217218

218-
return false;
219-
}
220-
});
219+
return false;
220+
}
221+
}.bind(this));
222+
}.bind(this));
221223

222-
return report;
224+
setTimeout(function () {
225+
subscription.dispose();
226+
}, 1500);
223227
},
224228

225229
/**

0 commit comments

Comments
 (0)