From 50d2577353f2ee4ed45b9dd7b9123217b3d34c28 Mon Sep 17 00:00:00 2001 From: Yusuf Musleh Date: Fri, 5 Apr 2024 19:01:52 +0300 Subject: [PATCH] feat: Put Taxonomies tab behind flag (#937) --- .../tabs-section/TabsSection.test.jsx | 14 +++++++++++++- src/studio-home/tabs-section/index.jsx | 18 ++++++++++-------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/studio-home/tabs-section/TabsSection.test.jsx b/src/studio-home/tabs-section/TabsSection.test.jsx index 215c3ee288..9b7fcfb6a9 100644 --- a/src/studio-home/tabs-section/TabsSection.test.jsx +++ b/src/studio-home/tabs-section/TabsSection.test.jsx @@ -158,11 +158,23 @@ describe('', () => { }); describe('taxonomies tab', () => { - it('should redirect to taxonomies page', async () => { + it('should not show taxonomies tab on page if not enabled', async () => { render(); axiosMock.onGet(getStudioHomeApiUrl()).reply(200, generateGetStudioHomeDataApiResponse()); await executeThunk(fetchStudioHomeData(), store.dispatch); + expect(screen.getByText(tabMessages.coursesTabTitle.defaultMessage)).toBeInTheDocument(); + expect(screen.queryByText(tabMessages.taxonomiesTabTitle.defaultMessage)).toBeNull(); + }); + + it('should redirect to taxonomies page', async () => { + const data = generateGetStudioHomeDataApiResponse(); + data.taxonomiesEnabled = true; + + render(); + axiosMock.onGet(getStudioHomeApiUrl()).reply(200, data); + await executeThunk(fetchStudioHomeData(), store.dispatch); + const taxonomiesTab = screen.getByText(tabMessages.taxonomiesTabTitle.defaultMessage); fireEvent.click(taxonomiesTab); diff --git a/src/studio-home/tabs-section/index.jsx b/src/studio-home/tabs-section/index.jsx index 1e0cb3848c..e1b6b91f62 100644 --- a/src/studio-home/tabs-section/index.jsx +++ b/src/studio-home/tabs-section/index.jsx @@ -33,7 +33,7 @@ const TabsSection = ({ libraryAuthoringMfeUrl, redirectToLibraryAuthoringMfe, courses, librariesEnabled, libraries, archivedCourses, - numPages, coursesCount, + numPages, coursesCount, taxonomiesEnabled, } = useSelector(getStudioHomeData); const { courseLoadingStatus, @@ -103,13 +103,15 @@ const TabsSection = ({ ); } - tabs.push( - , - ); + if (taxonomiesEnabled) { + tabs.push( + , + ); + } return tabs; }, [archivedCourses, librariesEnabled, showNewCourseContainer, isLoadingCourses, isLoadingLibraries]);