- TNL-11973: Previously Filters functionality was only working for subsections and units inside sections. Now sections are also filtered. - TNL-11974: New request, Show "no results found" if no results match the filters - TNL-11975: UI Change, Align filter menu popup to left side of filter button - TNL-11976: UI Change, Remove underline below "Course optimizer" title - TNL-11978: UI Change, Change title to "Scan my course" - TNL-11989: UI Change, Use empty space to display link, don't truncate text before the space runs out - TNL-11977: New request, Remove this stuff(scanning steps) when scan is complete, it'll disappear after 2.5 seconds - TNL-11979: UI Change, Move "This tool will scan your course..." text inside of Scan card - TNL-11980: UI Change, Move "Last scanned on..." date text below Scan button - TNL-11981: UI Change, Remove icon from "Start scanning" button - TNL-11983: UI Change, "Start scanning" button should be smaller, made it medium sized - TNL-11984: UI Change, Remove dividing line under subsection name in expanded card - TNL-11985: UI Change, Fix alignment of dividing lines, links, and icons in expanded cards to match Figma. - TNL-11986: UI Change, Match color of the broken icon with other Icons - TNL-11987: UI Change, Fix alignment of Filter chips to match Figma - Also added Beta Badge for course optimizer. - Added tests for codecov coverage
133 lines
5.1 KiB
JavaScript
133 lines
5.1 KiB
JavaScript
import { useSelector } from 'react-redux';
|
|
import { getConfig, setConfig } from '@edx/frontend-platform';
|
|
import { renderHook } from '@testing-library/react';
|
|
import messages from './messages';
|
|
import { useContentMenuItems, useToolsMenuItems, useSettingMenuItems } from './hooks';
|
|
|
|
jest.mock('@edx/frontend-platform/i18n', () => ({
|
|
...jest.requireActual('@edx/frontend-platform/i18n'),
|
|
useIntl: () => ({
|
|
formatMessage: jest.fn(message => message.defaultMessage),
|
|
}),
|
|
}));
|
|
|
|
jest.mock('react-redux', () => ({
|
|
...jest.requireActual('react-redux'),
|
|
useSelector: jest.fn(),
|
|
}));
|
|
|
|
describe('header utils', () => {
|
|
describe('getContentMenuItems', () => {
|
|
it('when video upload page enabled should include Video Uploads option', () => {
|
|
useSelector.mockReturnValue({
|
|
librariesV2Enabled: false,
|
|
});
|
|
setConfig({
|
|
...getConfig(),
|
|
ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN: 'true',
|
|
});
|
|
const actualItems = renderHook(() => useContentMenuItems('course-123')).result.current;
|
|
expect(actualItems).toHaveLength(5);
|
|
});
|
|
it('when video upload page disabled should not include Video Uploads option', () => {
|
|
useSelector.mockReturnValue({
|
|
librariesV2Enabled: false,
|
|
});
|
|
setConfig({
|
|
...getConfig(),
|
|
ENABLE_VIDEO_UPLOAD_PAGE_LINK_IN_CONTENT_DROPDOWN: 'false',
|
|
});
|
|
const actualItems = renderHook(() => useContentMenuItems('course-123')).result.current;
|
|
expect(actualItems).toHaveLength(4);
|
|
});
|
|
it('adds course libraries link to content menu when libraries v2 is enabled', () => {
|
|
useSelector.mockReturnValue({
|
|
librariesV2Enabled: true,
|
|
});
|
|
const actualItems = renderHook(() => useContentMenuItems('course-123')).result.current;
|
|
expect(actualItems[1]).toEqual({ href: '/course/course-123/libraries', title: 'Library Updates' });
|
|
});
|
|
});
|
|
|
|
describe('getSettingsMenuitems', () => {
|
|
beforeEach(() => {
|
|
useSelector.mockReturnValue({
|
|
canAccessAdvancedSettings: true,
|
|
});
|
|
});
|
|
|
|
it('when certificate page enabled should include certificates option', () => {
|
|
setConfig({
|
|
...getConfig(),
|
|
ENABLE_CERTIFICATE_PAGE: 'true',
|
|
});
|
|
const actualItems = renderHook(() => useSettingMenuItems('course-123')).result.current;
|
|
expect(actualItems).toHaveLength(6);
|
|
});
|
|
it('when certificate page disabled should not include certificates option', () => {
|
|
setConfig({
|
|
...getConfig(),
|
|
ENABLE_CERTIFICATE_PAGE: 'false',
|
|
});
|
|
const actualItems = renderHook(() => useSettingMenuItems('course-123')).result.current;
|
|
expect(actualItems).toHaveLength(5);
|
|
});
|
|
it('when user has access to advanced settings should include advanced settings option', () => {
|
|
const actualItemsTitle = renderHook(() => useSettingMenuItems('course-123')).result.current.map((item) => item.title);
|
|
expect(actualItemsTitle).toContain('Advanced Settings');
|
|
});
|
|
it('when user has no access to advanced settings should not include advanced settings option', () => {
|
|
useSelector.mockReturnValue({ canAccessAdvancedSettings: false });
|
|
const actualItemsTitle = renderHook(() => useSettingMenuItems('course-123')).result.current.map((item) => item.title);
|
|
expect(actualItemsTitle).not.toContain('Advanced Settings');
|
|
});
|
|
});
|
|
|
|
describe('getToolsMenuItems', () => {
|
|
beforeEach(() => {
|
|
useSelector.mockReturnValue({
|
|
waffleFlags: jest.fn(),
|
|
});
|
|
});
|
|
it('when tags enabled should include export tags option', () => {
|
|
setConfig({
|
|
...getConfig(),
|
|
ENABLE_TAGGING_TAXONOMY_PAGES: 'true',
|
|
});
|
|
const actualItemsTitle = renderHook(() => useToolsMenuItems('course-123')).result.current.map((item) => item.title);
|
|
expect(actualItemsTitle).toEqual([
|
|
'Import',
|
|
'Export Course',
|
|
'Export Tags',
|
|
'Checklists',
|
|
]);
|
|
});
|
|
it('when tags disabled should not include export tags option', () => {
|
|
setConfig({
|
|
...getConfig(),
|
|
ENABLE_TAGGING_TAXONOMY_PAGES: 'false',
|
|
});
|
|
const actualItemsTitle = renderHook(() => useToolsMenuItems('course-123')).result.current.map((item) => item.title);
|
|
expect(actualItemsTitle).toEqual([
|
|
'Import',
|
|
'Export Course',
|
|
'Checklists',
|
|
]);
|
|
});
|
|
|
|
it('when course optimizer enabled should include optimizer option', () => {
|
|
useSelector.mockReturnValue({ enableCourseOptimizer: true });
|
|
const optimizerItem = renderHook(() => useToolsMenuItems('course-123')).result.current.find(
|
|
item => item.href === '/course/course-123/optimizer',
|
|
);
|
|
expect(optimizerItem).toBeDefined();
|
|
});
|
|
|
|
it('when course optimizer disabled should not include optimizer option', () => {
|
|
useSelector.mockReturnValue({ enableCourseOptimizer: false });
|
|
const actualItemsTitle = renderHook(() => useToolsMenuItems('course-123')).result.current.map((item) => item.title);
|
|
expect(actualItemsTitle).not.toContain(messages['header.links.optimizer'].defaultMessage);
|
|
});
|
|
});
|
|
});
|