* feat: Add StudioHeader with optional AppMenu StudioHeader is a graft of Header with an additional optional AppMenu. Some Frontend Apps use Menus in their custom headers to provide more functionality in their apps. By adding this functionality in StudioHeader, it will be easier for frontend apps in Studio to adopt this component without it affecting the main Header component. * test: Add tests for StudioHeader and AppMenu * fix: Remove orderHistory * fix: Remove Responsive components * fix: Redefine User Menu for Studio The userMenu in StudioHeader will be used more for Studio related items such as Studio Home and Studio Maintenance. This requires new messages and reestablishing the url destinations of these menu items. * fix: Remove loggedOutItems * fix: Remove AUTHN_MINIMAL_HEADER items * fix: Remove unnecessary tests Anonymous sessions do not exist in the Studio. And Studio is not Mobile Ready. Tests of these kind are superfluous and have been removed. * feat: Turn mainMenu into an optional prop * test: Add test for optional mainMenu prop * feat: Update snapshots * fix: Remove ResponsiveContext * fix: Remove href and update appMenu prop Dropping the href because having a link that also works as a dropdown can be mildly confusing. Changing menu (type, href, content ) triplet to stick to the pattern; so we removed "menu". Also adding brackets around the triplet. Lastly, updating test and snapshot. Co-authored-by: Carlos Muniz <cmuniz@trcil.org>
136 lines
3.6 KiB
JavaScript
136 lines
3.6 KiB
JavaScript
import React from 'react';
|
|
import { IntlProvider } from '@edx/frontend-platform/i18n';
|
|
import TestRenderer from 'react-test-renderer';
|
|
import { AppContext } from '@edx/frontend-platform/react';
|
|
|
|
import { StudioHeader } from './index';
|
|
|
|
describe('<StudioHeader />', () => {
|
|
it('renders correctly', () => {
|
|
const component = (
|
|
<IntlProvider locale="en" messages={{}}>
|
|
<AppContext.Provider
|
|
value={{
|
|
authenticatedUser: {
|
|
userId: 'abc123',
|
|
username: 'edX',
|
|
roles: [],
|
|
administrator: false,
|
|
},
|
|
config: {
|
|
STUDIO_BASE_URL: process.env.STUDIO_BASE_URL,
|
|
SITE_NAME: process.env.SITE_NAME,
|
|
LOGIN_URL: process.env.LOGIN_URL,
|
|
LOGOUT_URL: process.env.LOGOUT_URL,
|
|
LOGO_URL: process.env.LOGO_URL,
|
|
},
|
|
}}
|
|
>
|
|
<StudioHeader />
|
|
</AppContext.Provider>
|
|
</IntlProvider>
|
|
);
|
|
|
|
const wrapper = TestRenderer.create(component);
|
|
|
|
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
});
|
|
|
|
it('renders correctly with the optional app menu', () => {
|
|
const appMenu = {
|
|
content: 'App Menu',
|
|
menuItems: [
|
|
{
|
|
type: 'dropdown',
|
|
href: 'https://menu-href-url.org',
|
|
content: 'Content 1',
|
|
},
|
|
{
|
|
type: 'dropdown',
|
|
href: 'https://menu-href-url.org',
|
|
content: 'Content 2',
|
|
},
|
|
{
|
|
type: 'dropdown',
|
|
href: 'https://menu-href-url.org',
|
|
content: 'Content 3',
|
|
},
|
|
],
|
|
};
|
|
const component = (
|
|
<IntlProvider locale="en" messages={{}}>
|
|
<AppContext.Provider
|
|
value={{
|
|
authenticatedUser: {
|
|
userId: 'abc123',
|
|
username: 'edX',
|
|
roles: [],
|
|
administrator: false,
|
|
},
|
|
config: {
|
|
STUDIO_BASE_URL: process.env.STUDIO_BASE_URL,
|
|
SITE_NAME: process.env.SITE_NAME,
|
|
LOGIN_URL: process.env.LOGIN_URL,
|
|
LOGOUT_URL: process.env.LOGOUT_URL,
|
|
LOGO_URL: process.env.LOGO_URL,
|
|
},
|
|
}}
|
|
>
|
|
<StudioHeader appMenu={appMenu} />
|
|
</AppContext.Provider>
|
|
</IntlProvider>
|
|
);
|
|
|
|
const wrapper = TestRenderer.create(component);
|
|
|
|
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
});
|
|
|
|
it('renders correctly with the optional main menu', () => {
|
|
const mainMenu = [
|
|
{
|
|
type: 'dropdown',
|
|
href: 'https://menu-href-url.org',
|
|
content: 'Content 1',
|
|
},
|
|
{
|
|
type: 'dropdown',
|
|
href: 'https://menu-href-url.org',
|
|
content: 'Content 2',
|
|
},
|
|
{
|
|
type: 'dropdown',
|
|
href: 'https://menu-href-url.org',
|
|
content: 'Content 3',
|
|
},
|
|
];
|
|
const component = (
|
|
<IntlProvider locale="en" messages={{}}>
|
|
<AppContext.Provider
|
|
value={{
|
|
authenticatedUser: {
|
|
userId: 'abc123',
|
|
username: 'edX',
|
|
roles: [],
|
|
administrator: false,
|
|
},
|
|
config: {
|
|
STUDIO_BASE_URL: process.env.STUDIO_BASE_URL,
|
|
SITE_NAME: process.env.SITE_NAME,
|
|
LOGIN_URL: process.env.LOGIN_URL,
|
|
LOGOUT_URL: process.env.LOGOUT_URL,
|
|
LOGO_URL: process.env.LOGO_URL,
|
|
},
|
|
}}
|
|
>
|
|
<StudioHeader mainMenu={mainMenu} />
|
|
</AppContext.Provider>
|
|
</IntlProvider>
|
|
);
|
|
|
|
const wrapper = TestRenderer.create(component);
|
|
|
|
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
});
|
|
});
|