Skip to content

Commit

Permalink
feat: Put Taxonomies tab behind flag (#937)
Browse files Browse the repository at this point in the history
  • Loading branch information
yusuf-musleh authored Apr 5, 2024
1 parent 7f3164b commit 50d2577
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
14 changes: 13 additions & 1 deletion src/studio-home/tabs-section/TabsSection.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,23 @@ describe('<TabsSection />', () => {
});

describe('taxonomies tab', () => {
it('should redirect to taxonomies page', async () => {
it('should not show taxonomies tab on page if not enabled', async () => {
render(<RootWrapper />);
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(<RootWrapper />);
axiosMock.onGet(getStudioHomeApiUrl()).reply(200, data);
await executeThunk(fetchStudioHomeData(), store.dispatch);

const taxonomiesTab = screen.getByText(tabMessages.taxonomiesTabTitle.defaultMessage);
fireEvent.click(taxonomiesTab);

Expand Down
18 changes: 10 additions & 8 deletions src/studio-home/tabs-section/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const TabsSection = ({
libraryAuthoringMfeUrl,
redirectToLibraryAuthoringMfe,
courses, librariesEnabled, libraries, archivedCourses,
numPages, coursesCount,
numPages, coursesCount, taxonomiesEnabled,
} = useSelector(getStudioHomeData);
const {
courseLoadingStatus,
Expand Down Expand Up @@ -103,13 +103,15 @@ const TabsSection = ({
);
}

tabs.push(
<Tab
key={TABS_LIST.taxonomies}
eventKey={TABS_LIST.taxonomies}
title={intl.formatMessage(messages.taxonomiesTabTitle)}
/>,
);
if (taxonomiesEnabled) {
tabs.push(
<Tab
key={TABS_LIST.taxonomies}
eventKey={TABS_LIST.taxonomies}
title={intl.formatMessage(messages.taxonomiesTabTitle)}
/>,
);
}

return tabs;
}, [archivedCourses, librariesEnabled, showNewCourseContainer, isLoadingCourses, isLoadingLibraries]);
Expand Down

0 comments on commit 50d2577

Please sign in to comment.