Skip to content

Commit 20dc815

Browse files
author
joweecaquicla
committed
magento/adobe-stock-integration#1523: Switching between Views does not change the selected folder. [Media Gallery] - implement request change and mftf test
1 parent 3396cfd commit 20dc815

File tree

3 files changed

+101
-10
lines changed

3 files changed

+101
-10
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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="AssertFolderIsChangedActionGroup">
12+
<annotations>
13+
<description>Assert that folder is changed</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="newSelectedFolder" type="string"/>
17+
<argument name="oldSelectedFolder" type="string" defaultValue="{{AdminMediaGalleryFolderData.name}}"/>
18+
</arguments>
19+
20+
<assertNotEquals stepKey="assertNotEqual">
21+
<actualResult type="string">{{newSelectedFolder}}</actualResult>
22+
<expectedResult type="string">{{oldSelectedFolder}}</expectedResult>
23+
</assertNotEquals>
24+
</actionGroup>
25+
</actionGroups>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminMediaGallerySwitchingBetweenViewsTest">
11+
<annotations>
12+
<features value="MediaGallery"/>
13+
<useCaseId value="https://github.com/magento/adobe-stock-integration/issues/1523"/>
14+
<title value="User switches between Views and checks if the folder is changed"/>
15+
<stories value="User switches between Views and checks if the folder is changed"/>
16+
<testCaseId value="https://studio.cucumber.io/projects/131313/test-plan/folders/1337102/scenarios/5060037"/>
17+
<description value="User switches between Views and checks if the folder is changed"/>
18+
<severity value="CRITICAL"/>
19+
<group value="media_gallery_ui"/>
20+
</annotations>
21+
<before>
22+
<createData entity="SimpleSubCategory" stepKey="category"/>
23+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
24+
</before>
25+
<after>
26+
<actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/>
27+
<actionGroup ref="AdminEnhancedMediaGalleryDeleteGridViewActionGroup" stepKey="deleteView">
28+
<argument name="viewToDelete" value="New View"/>
29+
</actionGroup>
30+
<actionGroup ref="AdminMediaGalleryFolderSelectActionGroup" stepKey="selectFolderForDelete"/>
31+
<actionGroup ref="AdminMediaGalleryFolderDeleteActionGroup" stepKey="deleteFolder"/>
32+
<actionGroup ref="AdminMediaGalleryAssertFolderDoesNotExistActionGroup" stepKey="assertFolderWasDeleted"/>
33+
<deleteData createDataKey="category" stepKey="deleteCategory"/>
34+
</after>
35+
<actionGroup ref="AdminOpenCreateNewCMSPageActionGroup" stepKey="openNewPage"/>
36+
<actionGroup ref="AdminOpenMediaGalleryFromPageNoEditorActionGroup" stepKey="openMediaGalleryForPage"/>
37+
<actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="clearFilters"/>
38+
<actionGroup ref="AdminMediaGalleryOpenNewFolderFormActionGroup" stepKey="openNewFolderForm"/>
39+
<actionGroup ref="AdminMediaGalleryCreateNewFolderActionGroup" stepKey="createNewFolder"/>
40+
<actionGroup ref="AdminMediaGalleryAssertFolderNameActionGroup" stepKey="assertNewFolderCreated"/>
41+
<waitForLoadingMaskToDisappear stepKey="waitForFolderContents"/>
42+
<actionGroup ref="AdminEnhancedMediaGallerySaveCustomViewActionGroup" stepKey="saveCustomView">
43+
<argument name="viewName" value="New View"/>
44+
</actionGroup>
45+
<actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openCategoryPage"/>
46+
<actionGroup ref="AdminCategoriesOpenCategoryActionGroup" stepKey="openCategory">
47+
<argument name="category" value="$$category$$"/>
48+
</actionGroup>
49+
<actionGroup ref="AdminOpenMediaGalleryFromCategoryImageUploaderActionGroup" stepKey="openMediaGalleryFromImageUploader"/>
50+
<actionGroup ref="AdminEnhancedMediaGallerySelectCustomBookmarksViewActionGroup" stepKey="selectDefaultView">
51+
<argument name="selectView" value="Default View"/>
52+
</actionGroup>
53+
<actionGroup ref="AssertFolderIsChangedActionGroup" stepKey="assertFolderIsChanged">
54+
<argument name="newSelectedFolder" value="category" />
55+
</actionGroup>
56+
<actionGroup ref="AdminEnhancedMediaGallerySelectCustomBookmarksViewActionGroup" stepKey="switchBackToNewView">
57+
<argument name="selectView" value="New View"/>
58+
</actionGroup>
59+
<actionGroup ref="AdminEnhancedMediaGalleryAssertActiveFiltersActionGroup" stepKey="assertFilterApplied">
60+
<argument name="resultValue" value="{{AdminMediaGalleryFolderData.name}}"/>
61+
</actionGroup>
62+
</test>
63+
</tests>

app/code/Magento/MediaGalleryUi/view/adminhtml/web/js/directory/directoryTree.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -254,15 +254,16 @@ define([
254254

255255
if (_.isUndefined(currentFilterPath)) {
256256
this.clearFiltersHandle();
257-
} else {
258-
currentTreePath = this.isFiltersApplied(currentFilterPath) || !isMediaBrowser ? currentFilterPath :
259-
Base64.idDecode(window.MediabrowserUtility.pathId);
257+
return;
258+
}
260259

261-
if (this.folderExistsInTree(currentTreePath)) {
262-
this.locateNode(currentTreePath);
263-
} else {
264-
this.selectStorageRoot();
265-
}
260+
currentTreePath = this.isFiltersApplied(currentFilterPath) || !isMediaBrowser ? currentFilterPath :
261+
Base64.idDecode(window.MediabrowserUtility.pathId);
262+
263+
if (this.folderExistsInTree(currentTreePath)) {
264+
this.locateNode(currentTreePath);
265+
} else {
266+
this.selectStorageRoot();
266267
}
267268
},
268269

@@ -285,8 +286,7 @@ define([
285286
* @param {String} currentFilterPath
286287
*/
287288
isFiltersApplied: function (currentFilterPath) {
288-
return !_.isUndefined(currentFilterPath) && currentFilterPath !== ''
289-
&& currentFilterPath !== 'catalog/category';
289+
return !_.isUndefined(currentFilterPath) && currentFilterPath !== '';
290290
},
291291

292292
/**
@@ -306,6 +306,9 @@ define([
306306

307307
},
308308

309+
/**
310+
* Clear filters
311+
*/
309312
clearFiltersHandle: function () {
310313
$(this.directoryTreeSelector).jstree('deselect_all');
311314
this.activeNode(null);

0 commit comments

Comments
 (0)