@nauedu/frontend-component-header 14.0.0-semantically-released

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/LICENSE +661 -0
  2. package/README.rst +113 -0
  3. package/dist/Avatar.js +45 -0
  4. package/dist/Avatar.js.map +1 -0
  5. package/dist/DesktopHeader.js +218 -0
  6. package/dist/DesktopHeader.js.map +1 -0
  7. package/dist/Header.js +86 -0
  8. package/dist/Header.js.map +1 -0
  9. package/dist/Header.messages.js +100 -0
  10. package/dist/Header.messages.js.map +1 -0
  11. package/dist/Header.test.jsx +127 -0
  12. package/dist/Icons.js +53 -0
  13. package/dist/Icons.js.map +1 -0
  14. package/dist/Logo.js +51 -0
  15. package/dist/Logo.js.map +1 -0
  16. package/dist/Menu/Menu.js +367 -0
  17. package/dist/Menu/Menu.js.map +1 -0
  18. package/dist/Menu/index.js +3 -0
  19. package/dist/Menu/index.js.map +1 -0
  20. package/dist/Menu/menu.scss +45 -0
  21. package/dist/MobileHeader.js +240 -0
  22. package/dist/MobileHeader.js.map +1 -0
  23. package/dist/__snapshots__/Header.test.jsx.snap +443 -0
  24. package/dist/generic/messages.js +15 -0
  25. package/dist/generic/messages.js.map +1 -0
  26. package/dist/i18n/index.js +31 -0
  27. package/dist/i18n/index.js.map +1 -0
  28. package/dist/i18n/messages/ar.json +30 -0
  29. package/dist/i18n/messages/ca.json +1 -0
  30. package/dist/i18n/messages/es_419.json +30 -0
  31. package/dist/i18n/messages/fr.json +30 -0
  32. package/dist/i18n/messages/fr_CA.json +30 -0
  33. package/dist/i18n/messages/he.json +1 -0
  34. package/dist/i18n/messages/id.json +1 -0
  35. package/dist/i18n/messages/ko_KR.json +2 -0
  36. package/dist/i18n/messages/pl.json +1 -0
  37. package/dist/i18n/messages/pt_BR.json +2 -0
  38. package/dist/i18n/messages/ru.json +1 -0
  39. package/dist/i18n/messages/th.json +1 -0
  40. package/dist/i18n/messages/uk.json +1 -0
  41. package/dist/i18n/messages/zh_CN.json +30 -0
  42. package/dist/index.js +6 -0
  43. package/dist/index.js.map +1 -0
  44. package/dist/index.scss +120 -0
  45. package/dist/learning-header/AnonymousUserMenu.js +24 -0
  46. package/dist/learning-header/AnonymousUserMenu.js.map +1 -0
  47. package/dist/learning-header/AuthenticatedUserDropdown.js +48 -0
  48. package/dist/learning-header/AuthenticatedUserDropdown.js.map +1 -0
  49. package/dist/learning-header/LearningHeader.js +121 -0
  50. package/dist/learning-header/LearningHeader.js.map +1 -0
  51. package/dist/learning-header/_header.scss +7 -0
  52. package/dist/learning-header/data/api.js +57 -0
  53. package/dist/learning-header/data/api.js.map +1 -0
  54. package/dist/learning-header/data/api.test.js +216 -0
  55. package/dist/learning-header/data/api.test.js.map +1 -0
  56. package/dist/learning-header/messages.js +40 -0
  57. package/dist/learning-header/messages.js.map +1 -0
  58. package/dist/setupTest.js +129 -0
  59. package/package.json +76 -0
@@ -0,0 +1,216 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+
5
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
6
+
7
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
8
+
9
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
10
+
11
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12
+
13
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
14
+
15
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
16
+
17
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
18
+
19
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
20
+
21
+ function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
22
+
23
+ function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
24
+
25
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
26
+
27
+ function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
28
+
29
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
30
+
31
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
32
+
33
+ import { getConfig } from '@edx/frontend-platform';
34
+ import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
35
+ import getCourseLogoOrg from './api';
36
+ import { initializeMockApp } from '../../setupTest';
37
+ jest.mock('@edx/frontend-platform/auth');
38
+
39
+ var CustomError = /*#__PURE__*/function (_Error) {
40
+ _inherits(CustomError, _Error);
41
+
42
+ var _super = _createSuper(CustomError);
43
+
44
+ function CustomError(httpErrorStatus) {
45
+ var _this;
46
+
47
+ _classCallCheck(this, CustomError);
48
+
49
+ _this = _super.call(this);
50
+ _this.customAttributes = {
51
+ httpErrorStatus: httpErrorStatus
52
+ };
53
+ return _this;
54
+ }
55
+
56
+ return _createClass(CustomError);
57
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
58
+
59
+ describe('getCourseLogoOrg', function () {
60
+ beforeEach( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
61
+ return regeneratorRuntime.wrap(function _callee$(_context) {
62
+ while (1) {
63
+ switch (_context.prev = _context.next) {
64
+ case 0:
65
+ _context.next = 2;
66
+ return initializeMockApp();
67
+
68
+ case 2:
69
+ delete window.location;
70
+ getAuthenticatedHttpClient.mockReset();
71
+
72
+ case 4:
73
+ case "end":
74
+ return _context.stop();
75
+ }
76
+ }
77
+ }, _callee);
78
+ })));
79
+ it('should return the organization logo when the URL is valid', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
80
+ var logoOrg;
81
+ return regeneratorRuntime.wrap(function _callee3$(_context3) {
82
+ while (1) {
83
+ switch (_context3.prev = _context3.next) {
84
+ case 0:
85
+ window.location = new URL("".concat(getConfig().BASE_URL, "/learning/course/course-v1:edX+DemoX+Demo_Course/home"));
86
+ getAuthenticatedHttpClient.mockReturnValue({
87
+ get: function () {
88
+ var _get = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
89
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
90
+ while (1) {
91
+ switch (_context2.prev = _context2.next) {
92
+ case 0:
93
+ return _context2.abrupt("return", Promise.resolve({
94
+ data: {
95
+ logo: 'https://example.com/logo.svg'
96
+ }
97
+ }));
98
+
99
+ case 1:
100
+ case "end":
101
+ return _context2.stop();
102
+ }
103
+ }
104
+ }, _callee2);
105
+ }));
106
+
107
+ function get() {
108
+ return _get.apply(this, arguments);
109
+ }
110
+
111
+ return get;
112
+ }()
113
+ });
114
+ _context3.next = 4;
115
+ return getCourseLogoOrg();
116
+
117
+ case 4:
118
+ logoOrg = _context3.sent;
119
+ expect(logoOrg).toBe('https://example.com/logo.svg');
120
+
121
+ case 6:
122
+ case "end":
123
+ return _context3.stop();
124
+ }
125
+ }
126
+ }, _callee3);
127
+ })));
128
+ it('should return null when the organization logo is not found', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
129
+ var logoOrg;
130
+ return regeneratorRuntime.wrap(function _callee5$(_context5) {
131
+ while (1) {
132
+ switch (_context5.prev = _context5.next) {
133
+ case 0:
134
+ window.location = new URL("".concat(getConfig().BASE_URL, "/learning/course/course-v1:edX+DemoX+Nonexistent_Course/home"));
135
+ getAuthenticatedHttpClient.mockReturnValue({
136
+ get: function () {
137
+ var _get2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
138
+ return regeneratorRuntime.wrap(function _callee4$(_context4) {
139
+ while (1) {
140
+ switch (_context4.prev = _context4.next) {
141
+ case 0:
142
+ throw new CustomError(404);
143
+
144
+ case 1:
145
+ case "end":
146
+ return _context4.stop();
147
+ }
148
+ }
149
+ }, _callee4);
150
+ }));
151
+
152
+ function get() {
153
+ return _get2.apply(this, arguments);
154
+ }
155
+
156
+ return get;
157
+ }()
158
+ });
159
+ _context5.next = 4;
160
+ return getCourseLogoOrg();
161
+
162
+ case 4:
163
+ logoOrg = _context5.sent;
164
+ expect(logoOrg).toBeNull();
165
+
166
+ case 6:
167
+ case "end":
168
+ return _context5.stop();
169
+ }
170
+ }
171
+ }, _callee5);
172
+ })));
173
+ it('should throw an error when an unexpected error occurs', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() {
174
+ var customError;
175
+ return regeneratorRuntime.wrap(function _callee7$(_context7) {
176
+ while (1) {
177
+ switch (_context7.prev = _context7.next) {
178
+ case 0:
179
+ customError = new CustomError(500);
180
+ window.location = new URL("".concat(getConfig().BASE_URL, "/learning/course/course-v1:edX+DemoX+Demo_Course/home"));
181
+ getAuthenticatedHttpClient.mockReturnValue({
182
+ get: function () {
183
+ var _get3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
184
+ return regeneratorRuntime.wrap(function _callee6$(_context6) {
185
+ while (1) {
186
+ switch (_context6.prev = _context6.next) {
187
+ case 0:
188
+ throw customError;
189
+
190
+ case 1:
191
+ case "end":
192
+ return _context6.stop();
193
+ }
194
+ }
195
+ }, _callee6);
196
+ }));
197
+
198
+ function get() {
199
+ return _get3.apply(this, arguments);
200
+ }
201
+
202
+ return get;
203
+ }()
204
+ });
205
+ _context7.next = 5;
206
+ return expect(getCourseLogoOrg()).rejects.toThrow(customError);
207
+
208
+ case 5:
209
+ case "end":
210
+ return _context7.stop();
211
+ }
212
+ }
213
+ }, _callee7);
214
+ })));
215
+ });
216
+ //# sourceMappingURL=api.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/learning-header/data/api.test.js"],"names":["getConfig","getAuthenticatedHttpClient","getCourseLogoOrg","initializeMockApp","jest","mock","CustomError","httpErrorStatus","customAttributes","Error","describe","beforeEach","window","location","mockReset","it","URL","BASE_URL","mockReturnValue","get","Promise","resolve","data","logo","logoOrg","expect","toBe","toBeNull","customError","rejects","toThrow"],"mappings":"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","sourcesContent":["import { getConfig } from '@edx/frontend-platform';\nimport { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';\nimport getCourseLogoOrg from './api';\nimport { initializeMockApp } from '../../setupTest';\n\njest.mock('@edx/frontend-platform/auth');\n\nclass CustomError extends Error {\n constructor(httpErrorStatus) {\n super();\n this.customAttributes = {\n httpErrorStatus,\n };\n }\n}\n\ndescribe('getCourseLogoOrg', () => {\n beforeEach(async () => {\n // We need to mock AuthService to implicitly use `getAuthenticatedHttpClient` within `AppContext.Provider`.\n await initializeMockApp();\n delete window.location;\n getAuthenticatedHttpClient.mockReset();\n });\n\n it('should return the organization logo when the URL is valid', async () => {\n window.location = new URL(`${getConfig().BASE_URL}/learning/course/course-v1:edX+DemoX+Demo_Course/home`);\n getAuthenticatedHttpClient.mockReturnValue({\n get: async () => Promise.resolve({\n data: {\n logo: 'https://example.com/logo.svg',\n },\n }),\n });\n const logoOrg = await getCourseLogoOrg();\n expect(logoOrg).toBe('https://example.com/logo.svg');\n });\n\n it('should return null when the organization logo is not found', async () => {\n window.location = new URL(`${getConfig().BASE_URL}/learning/course/course-v1:edX+DemoX+Nonexistent_Course/home`);\n getAuthenticatedHttpClient.mockReturnValue({\n get: async () => {\n throw new CustomError(404);\n },\n });\n const logoOrg = await getCourseLogoOrg();\n expect(logoOrg).toBeNull();\n });\n\n it('should throw an error when an unexpected error occurs', async () => {\n const customError = new CustomError(500);\n window.location = new URL(`${getConfig().BASE_URL}/learning/course/course-v1:edX+DemoX+Demo_Course/home`);\n getAuthenticatedHttpClient.mockReturnValue({\n get: async () => {\n throw customError;\n },\n });\n await expect(getCourseLogoOrg()).rejects.toThrow(customError);\n });\n});\n"],"file":"api.test.js"}
@@ -0,0 +1,40 @@
1
+ import { defineMessages } from '@edx/frontend-platform/i18n';
2
+ var messages = defineMessages({
3
+ dashboard: {
4
+ id: 'header.menu.dashboard.label',
5
+ defaultMessage: 'Dashboard',
6
+ description: 'The text for the user menu Dashboard navigation link.'
7
+ },
8
+ help: {
9
+ id: 'header.help.label',
10
+ defaultMessage: 'Help',
11
+ description: 'The text for the link to the Help Center'
12
+ },
13
+ profile: {
14
+ id: 'header.menu.profile.label',
15
+ defaultMessage: 'Profile',
16
+ description: 'The text for the user menu Profile navigation link.'
17
+ },
18
+ account: {
19
+ id: 'header.menu.account.label',
20
+ defaultMessage: 'Account',
21
+ description: 'The text for the user menu Account navigation link.'
22
+ },
23
+ orderHistory: {
24
+ id: 'header.menu.orderHistory.label',
25
+ defaultMessage: 'Order History',
26
+ description: 'The text for the user menu Order History navigation link.'
27
+ },
28
+ skipNavLink: {
29
+ id: 'header.navigation.skipNavLink',
30
+ defaultMessage: 'Skip to main content.',
31
+ description: 'A link used by screen readers to allow users to skip to the main content of the page.'
32
+ },
33
+ signOut: {
34
+ id: 'header.menu.signOut.label',
35
+ defaultMessage: 'Sign Out',
36
+ description: 'The label for the user menu Sign Out action.'
37
+ }
38
+ });
39
+ export default messages;
40
+ //# sourceMappingURL=messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/learning-header/messages.js"],"names":["defineMessages","messages","dashboard","id","defaultMessage","description","help","profile","account","orderHistory","skipNavLink","signOut"],"mappings":"AAAA,SAASA,cAAT,QAA+B,6BAA/B;AAEA,IAAMC,QAAQ,GAAGD,cAAc,CAAC;AAC9BE,EAAAA,SAAS,EAAE;AACTC,IAAAA,EAAE,EAAE,6BADK;AAETC,IAAAA,cAAc,EAAE,WAFP;AAGTC,IAAAA,WAAW,EAAE;AAHJ,GADmB;AAM9BC,EAAAA,IAAI,EAAE;AACJH,IAAAA,EAAE,EAAE,mBADA;AAEJC,IAAAA,cAAc,EAAE,MAFZ;AAGJC,IAAAA,WAAW,EAAE;AAHT,GANwB;AAW9BE,EAAAA,OAAO,EAAE;AACPJ,IAAAA,EAAE,EAAE,2BADG;AAEPC,IAAAA,cAAc,EAAE,SAFT;AAGPC,IAAAA,WAAW,EAAE;AAHN,GAXqB;AAgB9BG,EAAAA,OAAO,EAAE;AACPL,IAAAA,EAAE,EAAE,2BADG;AAEPC,IAAAA,cAAc,EAAE,SAFT;AAGPC,IAAAA,WAAW,EAAE;AAHN,GAhBqB;AAqB9BI,EAAAA,YAAY,EAAE;AACZN,IAAAA,EAAE,EAAE,gCADQ;AAEZC,IAAAA,cAAc,EAAE,eAFJ;AAGZC,IAAAA,WAAW,EAAE;AAHD,GArBgB;AA0B9BK,EAAAA,WAAW,EAAE;AACXP,IAAAA,EAAE,EAAE,+BADO;AAEXC,IAAAA,cAAc,EAAE,uBAFL;AAGXC,IAAAA,WAAW,EAAE;AAHF,GA1BiB;AA+B9BM,EAAAA,OAAO,EAAE;AACPR,IAAAA,EAAE,EAAE,2BADG;AAEPC,IAAAA,cAAc,EAAE,UAFT;AAGPC,IAAAA,WAAW,EAAE;AAHN;AA/BqB,CAAD,CAA/B;AAsCA,eAAeJ,QAAf","sourcesContent":["import { defineMessages } from '@edx/frontend-platform/i18n';\n\nconst messages = defineMessages({\n dashboard: {\n id: 'header.menu.dashboard.label',\n defaultMessage: 'Dashboard',\n description: 'The text for the user menu Dashboard navigation link.',\n },\n help: {\n id: 'header.help.label',\n defaultMessage: 'Help',\n description: 'The text for the link to the Help Center',\n },\n profile: {\n id: 'header.menu.profile.label',\n defaultMessage: 'Profile',\n description: 'The text for the user menu Profile navigation link.',\n },\n account: {\n id: 'header.menu.account.label',\n defaultMessage: 'Account',\n description: 'The text for the user menu Account navigation link.',\n },\n orderHistory: {\n id: 'header.menu.orderHistory.label',\n defaultMessage: 'Order History',\n description: 'The text for the user menu Order History navigation link.',\n },\n skipNavLink: {\n id: 'header.navigation.skipNavLink',\n defaultMessage: 'Skip to main content.',\n description: 'A link used by screen readers to allow users to skip to the main content of the page.',\n },\n signOut: {\n id: 'header.menu.signOut.label',\n defaultMessage: 'Sign Out',\n description: 'The label for the user menu Sign Out action.',\n },\n});\n\nexport default messages;\n"],"file":"messages.js"}
@@ -0,0 +1,129 @@
1
+ /* eslint-disable import/no-extraneous-dependencies */
2
+
3
+ import Enzyme from 'enzyme';
4
+ import React from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import Adapter from 'enzyme-adapter-react-16';
7
+ import '@testing-library/jest-dom';
8
+ import '@testing-library/jest-dom/extend-expect';
9
+ import 'babel-polyfill';
10
+ import 'jest-chain';
11
+ import { getConfig, mergeConfig } from '@edx/frontend-platform';
12
+ import { configure as configureLogging } from '@edx/frontend-platform/logging';
13
+ import { configure as configureI18n } from '@edx/frontend-platform/i18n';
14
+ import { configure as configureAuth, MockAuthService } from '@edx/frontend-platform/auth';
15
+ import { render as rtlRender } from '@testing-library/react';
16
+ import { IntlProvider } from 'react-intl';
17
+ import AppProvider from '@edx/frontend-platform/react/AppProvider';
18
+ import appMessages from './i18n';
19
+
20
+ Enzyme.configure({ adapter: new Adapter() });
21
+
22
+ // These configuration values are usually set in webpack's EnvironmentPlugin however
23
+ // Jest does not use webpack so we need to set these so for testing
24
+ process.env.ACCESS_TOKEN_COOKIE_NAME = 'edx-jwt-cookie-header-payload';
25
+ process.env.BASE_URL = 'localhost:1995';
26
+ process.env.CREDENTIALS_BASE_URL = 'http://localhost:18150';
27
+ process.env.CSRF_TOKEN_API_PATH = '/csrf/api/v1/token';
28
+ process.env.ECOMMERCE_BASE_URL = 'http://localhost:18130';
29
+ process.env.LANGUAGE_PREFERENCE_COOKIE_NAME = 'openedx-language-preference';
30
+ process.env.LMS_BASE_URL = 'http://localhost:18000';
31
+ process.env.LOGIN_URL = 'http://localhost:18000/login';
32
+ process.env.LOGOUT_URL = 'http://localhost:18000/logout';
33
+ process.env.MARKETING_SITE_BASE_URL = 'http://localhost:18000';
34
+ process.env.ORDER_HISTORY_URL = 'localhost:1996/orders';
35
+ process.env.REFRESH_ACCESS_TOKEN_ENDPOINT = 'http://localhost:18000/login_refresh';
36
+ process.env.SEGMENT_KEY = 'segment_whoa';
37
+ process.env.SITE_NAME = 'edX';
38
+ process.env.USER_INFO_COOKIE_NAME = 'edx-user-info';
39
+ process.env.LOGO_URL = 'https://edx-cdn.org/v3/default/logo.svg';
40
+ process.env.LOGO_TRADEMARK_URL = 'https://edx-cdn.org/v3/default/logo-trademark.svg';
41
+ process.env.LOGO_WHITE_URL = 'https://edx-cdn.org/v3/default/logo-white.svg';
42
+ process.env.FAVICON_URL = 'https://edx-cdn.org/v3/default/favicon.ico';
43
+
44
+ class MockLoggingService {
45
+ logInfo = jest.fn();
46
+
47
+ logError = jest.fn();
48
+ }
49
+
50
+ export const authenticatedUser = {
51
+ userId: 'abc123',
52
+ username: 'Mock User',
53
+ roles: [],
54
+ administrator: false,
55
+ };
56
+
57
+ export function initializeMockApp() {
58
+ mergeConfig({
59
+ INSIGHTS_BASE_URL: process.env.INSIGHTS_BASE_URL || null,
60
+ STUDIO_BASE_URL: process.env.STUDIO_BASE_URL || null,
61
+ TWITTER_URL: process.env.TWITTER_URL || null,
62
+ BASE_URL: process.env.BASE_URL || null,
63
+ LMS_BASE_URL: process.env.LMS_BASE_URL || null,
64
+ LOGIN_URL: process.env.LOGIN_URL || null,
65
+ LOGOUT_URL: process.env.LOGOUT_URL || null,
66
+ REFRESH_ACCESS_TOKEN_ENDPOINT: process.env.REFRESH_ACCESS_TOKEN_ENDPOINT || null,
67
+ ACCESS_TOKEN_COOKIE_NAME: process.env.ACCESS_TOKEN_COOKIE_NAME || null,
68
+ CSRF_TOKEN_API_PATH: process.env.CSRF_TOKEN_API_PATH || null,
69
+ LOGO_URL: process.env.LOGO_URL || null,
70
+ SITE_NAME: process.env.SITE_NAME || null,
71
+
72
+ authenticatedUser: {
73
+ userId: 'abc123',
74
+ username: 'Mock User',
75
+ roles: [],
76
+ administrator: false,
77
+ },
78
+ });
79
+
80
+ const loggingService = configureLogging(MockLoggingService, {
81
+ config: getConfig(),
82
+ });
83
+ const authService = configureAuth(MockAuthService, {
84
+ config: getConfig(),
85
+ loggingService,
86
+ });
87
+
88
+ // i18n doesn't have a service class to return.
89
+ configureI18n({
90
+ config: getConfig(),
91
+ loggingService,
92
+ messages: [appMessages],
93
+ });
94
+
95
+ return { loggingService, authService };
96
+ }
97
+
98
+ function render(
99
+ ui,
100
+ {
101
+ store = null,
102
+ ...renderOptions
103
+ } = {},
104
+ ) {
105
+ function Wrapper({ children }) {
106
+ return (
107
+ // eslint-disable-next-line react/jsx-filename-extension
108
+ <IntlProvider locale="en">
109
+ <AppProvider store={store}>
110
+ {children}
111
+ </AppProvider>
112
+ </IntlProvider>
113
+ );
114
+ }
115
+
116
+ Wrapper.propTypes = {
117
+ children: PropTypes.node.isRequired,
118
+ };
119
+
120
+ return rtlRender(ui, { wrapper: Wrapper, ...renderOptions });
121
+ }
122
+
123
+ // Re-export everything.
124
+ export * from '@testing-library/react';
125
+
126
+ // Override `render` method.
127
+ export {
128
+ render,
129
+ };
package/package.json ADDED
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "@nauedu/frontend-component-header",
3
+ "version": "14.0.0-semantically-released",
4
+ "description": "NAU header for Open edX",
5
+ "main": "dist/index.js",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "scripts": {
10
+ "build": "make build",
11
+ "i18n_extract": "BABEL_ENV=i18n fedx-scripts babel src --quiet > /dev/null",
12
+ "lint": "fedx-scripts eslint --ext .js --ext .jsx .",
13
+ "snapshot": "fedx-scripts jest --updateSnapshot",
14
+ "start": "fedx-scripts webpack-dev-server --progress",
15
+ "test": "fedx-scripts jest --coverage"
16
+ },
17
+ "files": [
18
+ "/dist"
19
+ ],
20
+ "husky": {
21
+ "hooks": {
22
+ "pre-commit": "npm run lint"
23
+ }
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/fccn/frontend-component-header-nau.git"
28
+ },
29
+ "author": "edX",
30
+ "license": "AGPL-3.0",
31
+ "bugs": {
32
+ "url": "https://github.com/fccn/frontend-component-header-nau/issues"
33
+ },
34
+ "homepage": "https://github.com/fccn/frontend-component-header-nau#readme",
35
+ "devDependencies": {
36
+ "@edx/brand": "npm:@edx/brand-openedx@1.1.0",
37
+ "@edx/frontend-build": "9.1.1",
38
+ "@edx/frontend-platform": "1.15.1",
39
+ "@edx/paragon": "19.6.0",
40
+ "@testing-library/dom": "7.31.2",
41
+ "@testing-library/jest-dom": "5.16.2",
42
+ "@testing-library/react": "10.4.9",
43
+ "codecov": "3.8.3",
44
+ "enzyme": "3.11.0",
45
+ "enzyme-adapter-react-16": "1.15.6",
46
+ "husky": "7.0.4",
47
+ "jest": "27.5.0",
48
+ "jest-chain": "1.1.5",
49
+ "prop-types": "15.8.1",
50
+ "react": "16.14.0",
51
+ "react-dom": "16.14.0",
52
+ "react-redux": "7.2.6",
53
+ "react-router-dom": "5.3.0",
54
+ "react-test-renderer": "16.14.0",
55
+ "reactifex": "1.1.1",
56
+ "redux": "4.1.2",
57
+ "redux-saga": "1.1.3"
58
+ },
59
+ "dependencies": {
60
+ "@fortawesome/fontawesome-svg-core": "1.2.36",
61
+ "@fortawesome/free-brands-svg-icons": "5.15.4",
62
+ "@fortawesome/free-regular-svg-icons": "5.15.4",
63
+ "@fortawesome/free-solid-svg-icons": "5.15.4",
64
+ "@fortawesome/react-fontawesome": "^0.1.14",
65
+ "babel-polyfill": "6.26.0",
66
+ "react-responsive": "8.2.0",
67
+ "react-transition-group": "4.4.2"
68
+ },
69
+ "peerDependencies": {
70
+ "@edx/frontend-platform": "^1.8.0",
71
+ "@edx/paragon": ">= 7.0.0 < 20.0.0",
72
+ "prop-types": "^15.5.10",
73
+ "react": "^16.9.0",
74
+ "react-dom": "^16.9.0"
75
+ }
76
+ }