Skip to content

Commit

Permalink
magento/adobe-stock-integration#1760: Media Gallery page and Category…
Browse files Browse the repository at this point in the history
… grid page opened successfully if "Enhanced Media Gallery" disabled - revert category grid no route redirect when media gallery is disabled, MFTF test coverage
  • Loading branch information
jmonteros422 committed Aug 19, 2020
1 parent afe499d commit 0994c44
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@
namespace Magento\MediaGalleryCatalogUi\Controller\Adminhtml\Category;

use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Backend\Model\View\Result\Page;
use Magento\Backend\Model\View\Result\Forward;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\Controller\ResultInterface;
use Magento\MediaContentApi\Model\Config;

/**
* Controller serving the media gallery content
Expand All @@ -23,39 +20,13 @@ class Index extends Action implements HttpGetActionInterface
{
public const ADMIN_RESOURCE = 'Magento_Cms::media_gallery';

/**
* @var Config
*/
private $config;

/**
* Index constructor.
* @param Context $context
* @param Config $config
*/
public function __construct(
Context $context,
Config $config
) {
parent::__construct($context);
$this->config = $config;
}

/**
* Get the media gallery layout
*
* @return ResultInterface
*/
public function execute(): ResultInterface
{
if (!$this->config->isEnabled()) {
/** @var Forward $resultForward */
$resultForward = $this->resultFactory->create(ResultFactory::TYPE_FORWARD);
$resultForward->forward('noroute');

return $resultForward;
}

/** @var Page $resultPage */
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
$resultPage->getConfig()->getTitle()->prepend(__('Categories'));
Expand Down
3 changes: 1 addition & 2 deletions app/code/Magento/MediaGalleryCatalogUi/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"magento/module-backend": "*",
"magento/module-catalog": "*",
"magento/module-store": "*",
"magento/module-ui": "*",
"magento/module-media-content-api": "*"
"magento/module-ui": "*"
},
"type": "magento2-module",
"license": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AssertAdminStandaloneMediaGalleryPageIs404ActionGroup">
<annotations>
<description>Validates that the '404 Error' message is present and correct in the Admin Standalone Media Gallery Page Header.</description>
</annotations>

<see userInput="404 Error" selector="{{AdminHeaderSection.pageHeading}}" stepKey="see404PageHeading"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminMediaGalleryDisabledPageTest">
<annotations>
<features value="MediaGallery"/>
<useCaseId value="https://github.com/magento/adobe-stock-integration/issues/1760"/>
<title value="Standalone Media Gallery Page should return 404 if Media Gallery is disabled"/>
<stories value="#1760 Media Gallery Page opened successfully if Enhanced Media Gallery disabled"/>
<testCaseId value="https://studio.cucumber.io/projects/131313/test-plan/folders/1337102/scenarios/5106786"/>
<description value="Standalone Media Gallery Page should return 404 if Media Gallery is disabled"/>
<severity value="CRITICAL"/>
<group value="media_gallery_ui"/>
</annotations>
<before>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
<actionGroup ref="AdminMediaGalleryEnhancedEnableActionGroup" stepKey="disableEnhancedMediaGallery"/>
<actionGroup ref="AdminOpenStandaloneMediaGalleryActionGroup" stepKey="openStandaloneMediaGallery"/>
</before>
<actionGroup ref="AssertAdminStandaloneMediaGalleryPageIs404ActionGroup" stepKey="see404Page"/>
</test>
</tests>

0 comments on commit 0994c44

Please sign in to comment.