Skip to content

Commit

Permalink
fix: check taggng flag and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rpenido committed Feb 15, 2024
1 parent db898a8 commit 873b902
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/header/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ const messages = defineMessages({
},
'header.links.export': {
id: 'header.links.export',
defaultMessage: 'Export',
description: 'Link to Studio Export page',
},
'header.links.exportCourse': {
id: 'header.links.exportCourse',
defaultMessage: 'Export Course',
description: 'Link to Studio Export page',
},
Expand Down
18 changes: 12 additions & 6 deletions src/header/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,19 @@ export const getToolsMenuItems = ({ studioBaseUrl, courseId, intl }) => ([
title: intl.formatMessage(messages['header.links.import']),
},
{
href: `${studioBaseUrl}/export/${courseId}`,
title: intl.formatMessage(messages['header.links.export']),
},
{
href: `${studioBaseUrl}/api/content_tagging/v1/object_tags/${courseId}/export/`,
title: intl.formatMessage(messages['header.links.exportTags']),
href: `${studioBaseUrl}/import/${courseId}`,
title: intl.formatMessage(
getConfig().ENABLE_TAGGING_TAXONOMY_PAGES === 'true'
? messages['header.links.exportCourse']
: messages['header.links.export']

Check failure on line 71 in src/header/utils.js

View workflow job for this annotation

GitHub Actions / tests

Missing trailing comma
),
},
...(getConfig().ENABLE_TAGGING_TAXONOMY_PAGES === 'true'
? [{
href: `${studioBaseUrl}/api/content_tagging/v1/object_tags/${courseId}/export/`,
title: intl.formatMessage(messages['header.links.exportTags']),
}] : []
),
{
href: `${studioBaseUrl}/checklists/${courseId}`,
title: intl.formatMessage(messages['header.links.checklists']),
Expand Down
20 changes: 19 additions & 1 deletion src/header/utils.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getConfig, setConfig } from '@edx/frontend-platform';
import { getContentMenuItems } from './utils';
import { getContentMenuItems, getToolsMenuItems } from './utils';

const props = {
studioBaseUrl: 'UrLSTuiO',
Expand Down Expand Up @@ -28,4 +28,22 @@ describe('header utils', () => {
expect(actualItems).toHaveLength(4);
});
});
describe('getToolsMenuItems', () => {
it('should include export tags option', () => {
setConfig({
...getConfig(),
ENABLE_TAGGING_TAXONOMY_PAGES: 'true',
});
const actualItems = getToolsMenuItems(props);
expect(actualItems).toHaveLength(4);
});
it('should not include export tags option', () => {
setConfig({
...getConfig(),
ENABLE_TAGGING_TAXONOMY_PAGES: 'false',
});
const actualItems = getToolsMenuItems(props);
expect(actualItems).toHaveLength(3);
});
});
});

0 comments on commit 873b902

Please sign in to comment.