Skip to content

#1760: Media Gallery Page opened successfully if "Enhanced Media Gallery" disabled #29632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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="AssertAdminPageIs404ActionGroup">
<annotations>
<description>Validates that the '404 Error' message is present in the current Admin 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
Expand Up @@ -12,6 +12,9 @@
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\Controller\ResultInterface;
use Magento\MediaContentApi\Model\Config;
use Magento\Backend\App\Action\Context;
use Magento\Backend\Model\View\Result\Forward;

/**
* Controller serving the media gallery content
Expand All @@ -20,13 +23,39 @@ 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->setActiveMenu('Magento_MediaGalleryUi::media_gallery')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<suites xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Suite/etc/suiteSchema.xsd">
<suite name="MediaGalleryUiDisabledSuite">
<include>
<group name="media_gallery_ui_disabled"/>
</include>
</suite>
</suites>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?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="AdminStandaloneMediaGalleryDisabledTest">
<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_disabled"/>
</annotations>
<before>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
</before>
<actionGroup ref="AdminOpenStandaloneMediaGalleryActionGroup" stepKey="openStandaloneMediaGallery"/>
<actionGroup ref="AssertAdminPageIs404ActionGroup" stepKey="see404Page"/>
</test>
</tests>