From e980f1f20ec0470bbf7d152f6e44d49297c5da87 Mon Sep 17 00:00:00 2001 From: Dmytro <98233552+DmytroAlipov@users.noreply.github.com> Date: Thu, 8 Jun 2023 18:06:11 +0300 Subject: [PATCH] fix: disable invalid link Video Uploads (#511) --- .env | 1 + .env.development | 1 + .env.test | 1 + src/studio-header/Header.jsx | 8 +++--- src/studio-header/Header.test.jsx | 41 +++++++++++++++++++++++++++++++ 5 files changed, 49 insertions(+), 3 deletions(-) diff --git a/.env b/.env index c33fe8af1..393647634 100644 --- a/.env +++ b/.env @@ -40,6 +40,7 @@ ENABLE_NEW_IMPORT_PAGE = false ENABLE_NEW_EXPORT_PAGE = false ENABLE_UNIT_PAGE = false ENABLE_NEW_CUSTOM_PAGES = false +ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN = false BBB_LEARN_MORE_URL='' HOTJAR_APP_ID='' HOTJAR_VERSION=6 diff --git a/.env.development b/.env.development index 19a2b78cd..76be662fd 100644 --- a/.env.development +++ b/.env.development @@ -42,6 +42,7 @@ ENABLE_NEW_IMPORT_PAGE = false ENABLE_NEW_EXPORT_PAGE = false ENABLE_UNIT_PAGE = false ENABLE_NEW_CUSTOM_PAGES = false +ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN = false BBB_LEARN_MORE_URL='' HOTJAR_APP_ID='' HOTJAR_VERSION=6 diff --git a/.env.test b/.env.test index b778ac52f..0e1a0b2c1 100644 --- a/.env.test +++ b/.env.test @@ -41,4 +41,5 @@ ENABLE_NEW_IMPORT_PAGE = true ENABLE_NEW_EXPORT_PAGE = true ENABLE_UNIT_PAGE = true ENABLE_NEW_CUSTOM_PAGES = true +ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN = true BBB_LEARN_MORE_URL='' diff --git a/src/studio-header/Header.jsx b/src/studio-header/Header.jsx index 348f0b214..db9e47a1d 100644 --- a/src/studio-header/Header.jsx +++ b/src/studio-header/Header.jsx @@ -58,9 +58,11 @@ const Header = ({
{intl.formatMessage(messages['header.links.textbooks'])}
-
- {intl.formatMessage(messages['header.links.videoUploads'])} -
+ {process.env.ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN === 'true' && ( +
+ {intl.formatMessage(messages['header.links.videoUploads'])} +
+ )} ), }, diff --git a/src/studio-header/Header.test.jsx b/src/studio-header/Header.test.jsx index c1e84086e..c350c76c0 100644 --- a/src/studio-header/Header.test.jsx +++ b/src/studio-header/Header.test.jsx @@ -6,6 +6,7 @@ import { AppContext } from '@edx/frontend-platform/react'; import { Context as ResponsiveContext } from 'react-responsive'; import { cleanup, + fireEvent, render, screen, } from '@testing-library/react'; @@ -104,6 +105,46 @@ describe('
', () => { expect(screen.getByTestId('edx-header-logo')); }); + it('renders Video Uploads link', () => { + process.env.ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN = 'true'; + + const component = createComponent( + 1280, ( +
+ ), + ); + + render(component); + fireEvent.click(screen.getByText('Content')); + + expect(screen.getByText('Video Uploads')).toBeInTheDocument(); + }); + + it('does not render Video Uploads link', () => { + process.env.ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN = 'false'; + + const component = createComponent( + 1280, ( +
+ ), + ); + + render(component); + fireEvent.click(screen.getByText('Content')); + + expect(screen.queryByText('Video Uploads')).toBeNull(); + }); + afterEach(() => { cleanup(); });