diff --git a/__tests__/shared/components/Header/__mocks__/profile-state.json b/__tests__/shared/components/Header/__mocks__/profile-state.json
new file mode 100644
index 0000000000..95ef452099
--- /dev/null
+++ b/__tests__/shared/components/Header/__mocks__/profile-state.json
@@ -0,0 +1,6 @@
+{
+ "description": "devxxxxxx",
+ "email": "liwanxiang@gmail.com",
+ "handle": "huanner",
+ "photoURL": "https://topcoder-dev-media.s3.amazonaws.com/member/profile/huanner-1552562543506.png"
+}
diff --git a/__tests__/shared/components/Header/__snapshots__/index.jsx.snap b/__tests__/shared/components/Header/__snapshots__/index.jsx.snap
new file mode 100644
index 0000000000..311045f5f8
--- /dev/null
+++ b/__tests__/shared/components/Header/__snapshots__/index.jsx.snap
@@ -0,0 +1,190 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Default render 1`] = `
+
+
+ }
+ menu={
+ Array [
+ Object {
+ "href": "https://www.topcoder-dev.com",
+ "id": "business",
+ "title": "BUSINESS",
+ },
+ Object {
+ "id": "community",
+ "secondaryMenuForGuest": Array [
+ Object {
+ "href": "https://www.topcoder-dev.com/about",
+ "title": "Overview",
+ },
+ Object {
+ "href": "https://www.topcoder-dev.com/how-it-works/faqs/",
+ "title": "How It Works",
+ },
+ Object {
+ "href": "/community/learn",
+ "title": "Tracks",
+ },
+ Object {
+ "href": "https://www.topcoder-dev.com/about/why-crowdsourcing/",
+ "title": "Why Join",
+ },
+ ],
+ "secondaryMenuForLoggedInUser": Array [
+ Object {
+ "href": "/my-dashboard",
+ "title": "Dashboard",
+ },
+ Object {
+ "href": "/members/willFilledByUserName",
+ "id": "myprofile",
+ "title": "My Profile",
+ },
+ Object {
+ "href": "https://community.topcoder-dev.com/PactsMemberServlet?module=PaymentHistory&full_list=false",
+ "title": "Payments",
+ },
+ ],
+ "subMenu": Array [
+ Object {
+ "subMenu": Array [
+ Object {
+ "href": "/challenges",
+ "title": "All Challenges",
+ },
+ Object {
+ "href": "https://arena.topcoder-dev.com",
+ "title": "Competitive Programming",
+ },
+ ],
+ "title": "Compete",
+ },
+ Object {
+ "subMenu": Array [
+ Object {
+ "href": "/community/competitive-programming",
+ "title": "Competitive Programming",
+ },
+ Object {
+ "href": "/community/data-science",
+ "title": "Data Science",
+ },
+ Object {
+ "href": "/community/design",
+ "title": "Design",
+ },
+ Object {
+ "href": "/community/development",
+ "title": "Development",
+ },
+ Object {
+ "href": "/community/qa",
+ "title": "QA",
+ },
+ ],
+ "title": "Tracks",
+ },
+ Object {
+ "subMenu": Array [
+ Object {
+ "href": "https://www.topcoder-dev.com/tco",
+ "title": "TCO",
+ },
+ Object {
+ "href": "/community/member-programs",
+ "title": "Programs",
+ },
+ Object {
+ "href": "https://apps.topcoder-dev.com/forums",
+ "title": "Forums",
+ },
+ Object {
+ "href": "/community/statistics",
+ "title": "Statistics",
+ },
+ Object {
+ "href": "/community/events",
+ "title": "Events",
+ },
+ Object {
+ "href": "https://www.topcoder-dev.com/blog",
+ "title": "Blog",
+ },
+ ],
+ "title": "Explore",
+ },
+ ],
+ "title": "COMMUNITY",
+ },
+ ]
+ }
+ onChangeLevel1Id={[Function]}
+ openMore={true}
+ profileHandle="huanner"
+ rightMenu={
+
+ }
+ setOpenMore={[Function]}
+ theme="light"
+ />
+
+`;
diff --git a/__tests__/shared/components/Header/index.jsx b/__tests__/shared/components/Header/index.jsx
new file mode 100644
index 0000000000..fde9dd1cf5
--- /dev/null
+++ b/__tests__/shared/components/Header/index.jsx
@@ -0,0 +1,16 @@
+import React from 'react';
+import Renderer from 'react-test-renderer/shallow';
+
+import Header from 'components/Header';
+
+import profileState from './__mocks__/profile-state.json';
+
+
+const rnd = new Renderer();
+
+it('Default render', () => {
+ rnd.render(());
+ expect(rnd.getRenderOutput()).toMatchSnapshot();
+});
diff --git a/__tests__/shared/components/TopcoderHeader/Auth.jsx b/__tests__/shared/components/TopcoderHeader/Auth.jsx
deleted file mode 100644
index bfa7747b0a..0000000000
--- a/__tests__/shared/components/TopcoderHeader/Auth.jsx
+++ /dev/null
@@ -1,16 +0,0 @@
-import Auth from 'components/TopcoderHeader/Auth';
-import React from 'react';
-import Rnd from 'react-test-renderer/shallow';
-
-const rnd = new Rnd();
-
-test('Snapshot match', () => {
- rnd.render((
-
- ));
- expect(rnd.getRenderOutput()).toMatchSnapshot();
- rnd.render((
-
- ));
- expect(rnd.getRenderOutput()).toMatchSnapshot();
-});
diff --git a/__tests__/shared/components/TopcoderHeader/__snapshots__/Auth.jsx.snap b/__tests__/shared/components/TopcoderHeader/__snapshots__/Auth.jsx.snap
deleted file mode 100644
index 44801f1196..0000000000
--- a/__tests__/shared/components/TopcoderHeader/__snapshots__/Auth.jsx.snap
+++ /dev/null
@@ -1,45 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`Snapshot match 1`] = `
-
-`;
-
-exports[`Snapshot match 2`] = `
-
-`;
diff --git a/__tests__/shared/components/TopcoderHeader/__snapshots__/index.jsx.snap b/__tests__/shared/components/TopcoderHeader/__snapshots__/index.jsx.snap
deleted file mode 100644
index 546376cf1c..0000000000
--- a/__tests__/shared/components/TopcoderHeader/__snapshots__/index.jsx.snap
+++ /dev/null
@@ -1,991 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`Default render 1`] = `
-
-
-
-
-
-
- -
-
- Compete
-
-
- -
-
- Tracks
-
-
- -
-
- Community
-
-
-
-
-
-
-
-
-
-
,
- "link": "/challenges",
- "title": "All Challenges",
- },
- Object {
- "icon":
,
- "link": "https://arena.topcoder-dev.com",
- "title": "Competitive Programming",
- },
- ],
- "title": "Compete",
- },
- Object {
- "items": Array [
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/community/competitive-programming",
- "title": "Competitive Programming",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/community/data-science/",
- "title": "Data Science",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/community/design",
- "title": "Design",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/community/development",
- "title": "Development",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/community/qa",
- "title": "QA",
- },
- ],
- "title": "Tracks",
- "url": "https://www.topcoder-dev.com/community/learn",
- },
- Object {
- "items": Array [
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder.com/tco",
- "title": "TCO",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/community/member-programs",
- "title": "Programs",
- },
- Object {
- "icon":
,
- "link": "https://apps.topcoder-dev.com/forums",
- "title": "Forums",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/community/statistics",
- "title": "Statistics",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/community/events",
- "title": "Events",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/blog",
- "title": "Blog",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/thrive",
- "title": "Thrive",
- },
- ],
- "title": "Community",
- },
- ]
- }
- open={[Function]}
- opened={false}
- profile={null}
- userMenu={null}
- />
-
-`;
-
-exports[`Render with open menu 1`] = `
-
-
-
-
-
-
- -
-
- Compete
-
-
- -
-
- Tracks
-
-
- -
-
- Community
-
-
-
-
-
-
,
- "link": "/link",
- "title": "Title",
- },
- ],
- "title": "Compete",
- }
- }
- trigger={null}
- />
-
-
-
-
,
- "link": "/challenges",
- "title": "All Challenges",
- },
- Object {
- "icon":
,
- "link": "https://arena.topcoder-dev.com",
- "title": "Competitive Programming",
- },
- ],
- "title": "Compete",
- },
- Object {
- "items": Array [
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/community/competitive-programming",
- "title": "Competitive Programming",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/community/data-science/",
- "title": "Data Science",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/community/design",
- "title": "Design",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/community/development",
- "title": "Development",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/community/qa",
- "title": "QA",
- },
- ],
- "title": "Tracks",
- "url": "https://www.topcoder-dev.com/community/learn",
- },
- Object {
- "items": Array [
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder.com/tco",
- "title": "TCO",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/community/member-programs",
- "title": "Programs",
- },
- Object {
- "icon":
,
- "link": "https://apps.topcoder-dev.com/forums",
- "title": "Forums",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/community/statistics",
- "title": "Statistics",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/community/events",
- "title": "Events",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/blog",
- "title": "Blog",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/thrive",
- "title": "Thrive",
- },
- ],
- "title": "Community",
- },
- ]
- }
- open={[Function]}
- opened={false}
- profile={null}
- userMenu={null}
- />
-
-`;
-
-exports[`Render with specified profile 1`] = `
-
-
-
-
-
-
- -
-
- Compete
-
-
- -
-
- Tracks
-
-
- -
-
- Community
-
-
-
-
-
-
-
-
-
-
,
- "link": "/challenges",
- "title": "All Challenges",
- },
- Object {
- "icon":
,
- "link": "https://arena.topcoder-dev.com",
- "title": "Competitive Programming",
- },
- ],
- "title": "Compete",
- },
- Object {
- "items": Array [
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/community/competitive-programming",
- "title": "Competitive Programming",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/community/data-science/",
- "title": "Data Science",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/community/design",
- "title": "Design",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/community/development",
- "title": "Development",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/community/qa",
- "title": "QA",
- },
- ],
- "title": "Tracks",
- "url": "https://www.topcoder-dev.com/community/learn",
- },
- Object {
- "items": Array [
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder.com/tco",
- "title": "TCO",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/community/member-programs",
- "title": "Programs",
- },
- Object {
- "icon":
,
- "link": "https://apps.topcoder-dev.com/forums",
- "title": "Forums",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/community/statistics",
- "title": "Statistics",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/community/events",
- "title": "Events",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/blog",
- "title": "Blog",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/thrive",
- "title": "Thrive",
- },
- ],
- "title": "Community",
- },
- ]
- }
- open={[Function]}
- opened={false}
- profile={Object {}}
- userMenu={
- Object {
- "items": Array [
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/my-dashboard",
- "title": "Dashboard",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "/members/undefined",
- "title": "My Profile",
- },
- Object {
- "icon":
,
- "link": "https://community.topcoder-dev.com/PactsMemberServlet?module=PaymentHistory&full_list=false",
- "title": "Payments",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "/settings/profile",
- "title": "Settings",
- },
- Object {
- "enforceA": true,
- "icon":
,
- "link": "https://www.topcoder-dev.com/logout",
- "title": "Log Out",
- },
- ],
- "title": "User",
- }
- }
- />
-
-`;
diff --git a/__tests__/shared/components/TopcoderHeader/desktop/SubMenu/__snapshots__/index.jsx.snap b/__tests__/shared/components/TopcoderHeader/desktop/SubMenu/__snapshots__/index.jsx.snap
deleted file mode 100644
index 4e034058ff..0000000000
--- a/__tests__/shared/components/TopcoderHeader/desktop/SubMenu/__snapshots__/index.jsx.snap
+++ /dev/null
@@ -1,18 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`Matches shallow shapshot 1`] = `
-
-`;
diff --git a/__tests__/shared/components/TopcoderHeader/desktop/SubMenu/index.jsx b/__tests__/shared/components/TopcoderHeader/desktop/SubMenu/index.jsx
deleted file mode 100644
index 3e91b14a24..0000000000
--- a/__tests__/shared/components/TopcoderHeader/desktop/SubMenu/index.jsx
+++ /dev/null
@@ -1,50 +0,0 @@
-import React from 'react';
-import _ from 'lodash';
-import Renderer from 'react-test-renderer/shallow';
-import TU from 'react-dom/test-utils';
-import SubMenu from 'components/TopcoderHeader/desktop/SubMenu';
-
-test('Matches shallow shapshot', () => {
- const renderer = new Renderer();
-
- renderer.render((
-
- ));
- expect(renderer.getRenderOutput()).toMatchSnapshot();
-});
-
-class Wrapper extends React.Component {
- componentDidMount() {}
-
- render() {
- return ;
- }
-}
-
-const closeMenu = jest.fn();
-const instance = TU.renderIntoDocument(());
-
-test('closeMenu cancelled', () => {
- const menus = TU.scryRenderedDOMComponentsWithTag(instance, 'ul');
- expect(menus).toHaveLength(1);
- TU.Simulate.mouseLeave(menus[0], { pageY: 1 });
- expect(closeMenu).not.toHaveBeenCalled();
-});
-
-test('closeMenu executed', () => {
- const menus = TU.scryRenderedDOMComponentsWithTag(instance, 'ul');
- expect(menus).toHaveLength(1);
- TU.Simulate.mouseLeave(menus[0], { pageY: -1 });
- expect(closeMenu).toHaveBeenCalled();
-});
diff --git a/__tests__/shared/components/TopcoderHeader/index.jsx b/__tests__/shared/components/TopcoderHeader/index.jsx
deleted file mode 100644
index 7012d92b18..0000000000
--- a/__tests__/shared/components/TopcoderHeader/index.jsx
+++ /dev/null
@@ -1,216 +0,0 @@
-/* eslint-env browser */
-
-import _ from 'lodash';
-import React from 'react';
-import TopcoderHeader from 'components/TopcoderHeader';
-import TU from 'react-dom/test-utils';
-
-import { JU } from 'topcoder-react-utils';
-
-const mockCloseMenu = jest.fn();
-const mockCloseSearch = jest.fn();
-const mockOpenMenu = jest.fn();
-const mockOpenSearch = jest.fn();
-
-function styleNameMatch(item, styleName) {
- return item && item.className && item.className.match(styleName);
-}
-
-test('Default render', () => {
- JU.shallowSnapshot((
-
- ));
-});
-
-test('Render with open menu', () => {
- JU.shallowSnapshot((
- ,
- link: '/link',
- title: 'Title',
- }],
- }}
- openMobileMenu={_.noop}
- openSearch={_.noop}
- />
- ));
-});
-
-test('Render with specified profile', () => {
- JU.shallowSnapshot((
-
- ));
-});
-
-describe.skip('User input handling', () => {
- let dom;
- beforeAll(() => {
- dom = JU.renderDom((
-
- ));
- });
- beforeEach(() => {
- jest.clearAllMocks();
- });
-
- test.skip('main-menu-item opens sub-menu when hovered', () => {
- const items = TU.findAllInRenderedTree(dom, item => item && item.className && item.className.match(/main-menu-item/));
- expect(items.length).toBeGreaterThan(1);
- TU.Simulate.mouseEnter(items[0]);
- expect(mockOpenMenu).toHaveBeenCalled();
- });
-
- test.skip('main-menu-item closes sub-menu when mouse leaves downward', () => {
- const items = TU.findAllInRenderedTree(dom, item => item && item.className && item.className.match(/main-menu-item/));
- expect(items.length).toBeGreaterThan(1);
- TU.Simulate.mouseLeave(items[0], { pageY: -1 });
- expect(mockCloseMenu).not.toHaveBeenCalled();
- });
-
- test.skip('main-menu-item closes sub-menu when mouse leaves not downards', () => {
- const items = TU.findAllInRenderedTree(dom, item => item && item.className && item.className.match(/main-menu-item/));
- expect(items.length).toBeGreaterThan(1);
- TU.Simulate.mouseLeave(items[0], { pageY: -2 });
- expect(mockCloseMenu).toHaveBeenCalled();
- });
-
- test.skip('user-menu handle opens sub-menu when hovered', () => {
- const items = TU.findAllInRenderedTree(dom, item => item && item.className && item.className.match(/user-menu/));
- expect(items.length).toBeGreaterThan(1);
- TU.Simulate.mouseEnter(items[0]);
- expect(mockOpenMenu).toHaveBeenCalled();
- });
-
- test.skip('user-menu handle closes sub-menu when mouse leaves downwards', () => {
- const items = TU.findAllInRenderedTree(dom, item => item && item.className && item.className.match(/user-menu/));
- expect(items.length).toBeGreaterThan(1);
- TU.Simulate.mouseLeave(items[0], { pageY: -1 });
- expect(mockCloseMenu).not.toHaveBeenCalled();
- });
-
- test.skip('user-menu closes sub-menu when mouse leaves not downards', () => {
- const items = TU.findAllInRenderedTree(dom, item => item && item.className && item.className.match(/user-menu/));
- expect(items.length).toBeGreaterThan(1);
- TU.Simulate.mouseLeave(items[0], { pageY: -2 });
- expect(mockCloseMenu).toHaveBeenCalled();
- });
-
- test('search-icon opens search when hovered', () => {
- const items = TU.findAllInRenderedTree(dom, item => item && item.className && item.className.match(/search-icon/));
- expect(items.length).toBe(1);
- TU.Simulate.mouseEnter(items[0]);
- expect(mockOpenSearch).toHaveBeenCalled();
- });
-
- test('search-icon closes search when mouse leaves downwards', () => {
- const items = TU.findAllInRenderedTree(dom, item => item && item.className && item.className.match(/search-icon/));
- expect(items.length).toBe(1);
- TU.Simulate.mouseLeave(items[0], { pageY: -1 });
- expect(mockCloseSearch).not.toHaveBeenCalled();
- });
-
- test('search-icon closes search when mouse leaves not downards', () => {
- const items = TU.findAllInRenderedTree(dom, item => item && item.className && item.className.match(/search-icon/));
- expect(items.length).toBe(1);
- TU.Simulate.mouseLeave(items[0], { pageY: -2 });
- expect(mockCloseSearch).toHaveBeenCalled();
- });
-
- test('sub-menu closes when mouse leave downwards', () => {
- const items = TU.findAllInRenderedTree(dom, item => styleNameMatch(item, 'closed-menu'));
- expect(items.length).toBe(1);
- TU.Simulate.mouseLeave(items[0], { pageY: 1 });
- expect(mockCloseMenu).toHaveBeenCalled();
- });
-
- test('search-field closes when mouse leaves downwards', () => {
- const items = TU.findAllInRenderedTree(dom, item => styleNameMatch(item, 'search-field'));
- expect(items.length).toBe(1);
- TU.Simulate.mouseLeave(items[0], { pageY: 1 });
- expect(mockCloseSearch).toHaveBeenCalled();
- });
-
- test('search-field won\'t close', () => {
- const items = TU.findAllInRenderedTree(dom, item => styleNameMatch(item, 'search-field'));
- expect(items.length).toBe(1);
- TU.Simulate.mouseLeave(items[0], { pageY: -1 });
- expect(mockCloseSearch).not.toHaveBeenCalled();
- });
-
- test('Enter submits search field', () => {
- const items = TU.findAllInRenderedTree(dom, item => styleNameMatch(item, 'search-field'));
- expect(items.length).toBe(1);
- expect(items[0].children.length).toBe(1);
- const input = items[0].children[0];
- expect(input.tagName).toBe('INPUT');
- TU.Simulate.keyPress(input, {
- key: 'Enter',
- target: {
- value: 'SEARCH',
- },
- });
- /* TODO: The commented out string below does not work with jest:
- * window.location comes from jsdom and works differently from
- * browser's window.location. Should be investigated how to make
- * this check properly. */
- // expect(window.location).toHaveBeenCalledWith('/search/members?q=SEARCH');
- });
-
- test('Other key won\'t submit', () => {
- const items = TU.findAllInRenderedTree(dom, item => styleNameMatch(item, 'search-field'));
- expect(items.length).toBe(1);
- expect(items[0].children.length).toBe(1);
- const input = items[0].children[0];
- expect(input.tagName).toBe('INPUT');
- TU.Simulate.keyPress(input, {
- key: 'A',
- target: {
- value: 'SEARCH',
- },
- });
- });
-});
diff --git a/__tests__/shared/components/TopcoderHeader/mobile/Menu.jsx b/__tests__/shared/components/TopcoderHeader/mobile/Menu.jsx
deleted file mode 100644
index 75b1e61a83..0000000000
--- a/__tests__/shared/components/TopcoderHeader/mobile/Menu.jsx
+++ /dev/null
@@ -1,23 +0,0 @@
-import _ from 'lodash';
-import React from 'react';
-import R from 'react-test-renderer/shallow';
-import Menu from 'components/TopcoderHeader/mobile/Menu';
-
-const renderer = new R();
-
-test('Matches snapshot', () => {
- renderer.render((
- ,
- link: '/LINK',
- title: 'Item title',
- }],
- }]}
- />
- ));
- expect(renderer.getRenderOutput()).toMatchSnapshot();
-});
diff --git a/__tests__/shared/components/TopcoderHeader/mobile/Search.jsx b/__tests__/shared/components/TopcoderHeader/mobile/Search.jsx
deleted file mode 100644
index dc3901808c..0000000000
--- a/__tests__/shared/components/TopcoderHeader/mobile/Search.jsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import _ from 'lodash';
-import React from 'react';
-import Renderer from 'react-test-renderer/shallow';
-import Search from 'components/TopcoderHeader/mobile/Search';
-import TU from 'react-dom/test-utils';
-
-class SearchWrapper extends React.Component {
- componentDidMount() {}
-
- render() {
- return (
-
- );
- }
-}
-
-test('Matches shallow shapshot', () => {
- const renderer = new Renderer();
- renderer.render();
- expect(renderer.getRenderOutput()).toMatchSnapshot();
-});
-
-const page = TU.renderIntoDocument();
-
-test.skip('Handles Enter key', () => {
- const items = TU.scryRenderedDOMComponentsWithClass(page, 'search');
- const input = _.find(items[0].children, item => item && item.tagName === 'INPUT');
- TU.Simulate.keyPress(input, {
- key: 'Enter',
- target: {
- value: 'SEARCH',
- },
- });
- /* TODO: We want to check here that /search/members?q=SEARCH
- * was put into window.location, but inside jest test window.location
- * comes from jsdom, and it is not really changed (at least,
- * checking window.location returns a weird data structure,
- * what is the way to access set url is not that clear).
- * Should be investigated. */
-});
diff --git a/__tests__/shared/components/TopcoderHeader/mobile/SubMenu.jsx b/__tests__/shared/components/TopcoderHeader/mobile/SubMenu.jsx
deleted file mode 100644
index 5664fa9230..0000000000
--- a/__tests__/shared/components/TopcoderHeader/mobile/SubMenu.jsx
+++ /dev/null
@@ -1,21 +0,0 @@
-import React from 'react';
-import R from 'react-test-renderer/shallow';
-import SubMenu from 'components/TopcoderHeader/mobile/SubMenu';
-
-const renderer = new R();
-
-test('Matches snapshot', () => {
- renderer.render((
- ,
- link: '/LINK',
- title: 'Item title',
- }],
- }}
- />
- ));
- expect(renderer.getRenderOutput()).toMatchSnapshot();
-});
diff --git a/__tests__/shared/components/TopcoderHeader/mobile/UserMenu.jsx b/__tests__/shared/components/TopcoderHeader/mobile/UserMenu.jsx
deleted file mode 100644
index b1ad54d59f..0000000000
--- a/__tests__/shared/components/TopcoderHeader/mobile/UserMenu.jsx
+++ /dev/null
@@ -1,24 +0,0 @@
-import React from 'react';
-import Rnd from 'react-test-renderer/shallow';
-import UserMenu from 'components/TopcoderHeader/mobile/UserMenu';
-
-const rnd = new Rnd();
-
-test('Snapshot match', () => {
- rnd.render((
- ,
- link: '/link',
- title: 'Item title',
- }],
- }}
- profile={{
- handle: 'username',
- }}
- />
- ));
- expect(rnd.getRenderOutput()).toMatchSnapshot();
-});
diff --git a/__tests__/shared/components/TopcoderHeader/mobile/__snapshots__/Menu.jsx.snap b/__tests__/shared/components/TopcoderHeader/mobile/__snapshots__/Menu.jsx.snap
deleted file mode 100644
index a708f428ff..0000000000
--- a/__tests__/shared/components/TopcoderHeader/mobile/__snapshots__/Menu.jsx.snap
+++ /dev/null
@@ -1,51 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`Matches snapshot 1`] = `
-
-
-
- [ topcoder ]
-
- ×
-
-
-
-
-
-
,
- "link": "/LINK",
- "title": "Item title",
- },
- ],
- "title": "Menu title",
- }
- }
- />
-
-`;
diff --git a/__tests__/shared/components/TopcoderHeader/mobile/__snapshots__/Search.jsx.snap b/__tests__/shared/components/TopcoderHeader/mobile/__snapshots__/Search.jsx.snap
deleted file mode 100644
index 41cd1908c9..0000000000
--- a/__tests__/shared/components/TopcoderHeader/mobile/__snapshots__/Search.jsx.snap
+++ /dev/null
@@ -1,20 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`Matches shallow shapshot 1`] = `
-
-
-
-
-`;
diff --git a/__tests__/shared/components/TopcoderHeader/mobile/__snapshots__/SubMenu.jsx.snap b/__tests__/shared/components/TopcoderHeader/mobile/__snapshots__/SubMenu.jsx.snap
deleted file mode 100644
index 97bd8033a4..0000000000
--- a/__tests__/shared/components/TopcoderHeader/mobile/__snapshots__/SubMenu.jsx.snap
+++ /dev/null
@@ -1,22 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`Matches snapshot 1`] = `
-
-`;
diff --git a/__tests__/shared/components/TopcoderHeader/mobile/__snapshots__/UserMenu.jsx.snap b/__tests__/shared/components/TopcoderHeader/mobile/__snapshots__/UserMenu.jsx.snap
deleted file mode 100644
index 9b6a9fd282..0000000000
--- a/__tests__/shared/components/TopcoderHeader/mobile/__snapshots__/UserMenu.jsx.snap
+++ /dev/null
@@ -1,45 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`Snapshot match 1`] = `
-
-
-
,
- "link": "/link",
- "title": "Item title",
- },
- ],
- "title": "Title",
- }
- }
- />
-
-`;
diff --git a/__tests__/shared/containers/__snapshots__/TopcoderHeader.jsx.snap b/__tests__/shared/containers/__snapshots__/TopcoderHeader.jsx.snap
index 594b9e1c6f..1c2bdc7866 100644
--- a/__tests__/shared/containers/__snapshots__/TopcoderHeader.jsx.snap
+++ b/__tests__/shared/containers/__snapshots__/TopcoderHeader.jsx.snap
@@ -1,19 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Matches shallow snapshot 1`] = `
- {
+ const [activeLevel1Id, setActiveLevel1Id] = useState();
+ const [path, setPath] = useState();
+ const [openMore, setOpenMore] = useState(true);
+
+ const handleChangeLevel1Id = (menuId) => {
+ setActiveLevel1Id(menuId);
+ };
+
+ const handleCloseOpenMore = () => {
+ setOpenMore(false);
+ };
+
+ const handleChangeOpenMore = (changedOpenMore) => {
+ setOpenMore(changedOpenMore);
+ };
+
+ const handleSwitchMenu = () => {
+ setActiveLevel1Id(config.HEADER_MENU[0].id);
+ };
+
+ let normalizedProfile = profile && _.clone(profile);
+ if (profile) {
+ normalizedProfile.photoURL = (_.has(profile, 'photoURL') && profile.photoURL !== null)
+ ? `${config.CDN.PUBLIC}/avatar/${encodeURIComponent(profile.photoURL)}?size=32` : '';
+ } else {
+ normalizedProfile = null;
+ }
+
+ useEffect(() => {
+ setPath(window.location.pathname);
+ }, []);
+ if (TopNavRef) {
+ return (
+
+
+ )}
+ logo={}
+ theme={config.HEADER_MENU_THEME}
+ currentLevel1Id={activeLevel1Id}
+ onChangeLevel1Id={handleChangeLevel1Id}
+ path={path}
+ openMore={openMore}
+ setOpenMore={handleChangeOpenMore}
+ loggedIn={!_.isEmpty(profile)}
+ profileHandle={profile ? profile.handle : ''}
+ />
+
+ );
+ }
+
+ return ();
+};
+
+Header.defaultProps = {
+ profile: null,
+};
+
+Header.propTypes = {
+ profile: PT.shape({
+ photoURL: PT.string,
+ handle: PT.string,
+ }),
+};
+
+export default Header;
diff --git a/src/shared/containers/TopcoderHeader.js b/src/shared/containers/TopcoderHeader.js
index 56971e94db..2f6b060f9f 100644
--- a/src/shared/containers/TopcoderHeader.js
+++ b/src/shared/containers/TopcoderHeader.js
@@ -2,15 +2,19 @@
* Container for the standard Topcoder header.
*/
+import _ from 'lodash';
import actions from 'actions/topcoder_header';
-import TopcoderHeader from 'components/TopcoderHeader';
+import TopcoderHeader from 'components/Header';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
export default connect(
state => ({
...state.topcoderHeader,
- profile: state.auth.profile,
+ profile: {
+ ...state.auth.profile,
+ ..._.pickBy({ roles: state.auth.user ? state.auth.user.roles : undefined }),
+ },
}),
dispatch => bindActionCreators(actions.topcoderHeader, dispatch),
)(TopcoderHeader);
diff --git a/src/shared/routes/Topcoder/styles.scss b/src/shared/routes/Topcoder/styles.scss
index dba87220c9..1af7c46852 100644
--- a/src/shared/routes/Topcoder/styles.scss
+++ b/src/shared/routes/Topcoder/styles.scss
@@ -8,5 +8,6 @@
display: flex;
flex: 1 0 auto;
position: relative;
+ z-index: 0;
}
}