@edx/frontend-plugin-learner-dashboard 1.6.1 → 1.7.0
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.
- package/dist/course-banner/Banner.js +40 -0
- package/dist/course-banner/Banner.js.map +1 -0
- package/dist/course-banner/CourseBanner.js +71 -0
- package/dist/course-banner/CourseBanner.js.map +1 -0
- package/dist/course-banner/formatDate.js +25 -0
- package/dist/course-banner/formatDate.js.map +1 -0
- package/dist/course-banner/index.js +35 -0
- package/dist/course-banner/index.js.map +1 -0
- package/dist/course-banner/messages.js +46 -0
- package/dist/course-banner/messages.js.map +1 -0
- package/dist/data/redux/app/selectors/courseCard.js +4 -0
- package/dist/data/redux/app/selectors/courseCard.js.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -0
- package/dist/setupTest.js +12 -23
- package/dist/setupTest.js.map +1 -1
- package/dist/testUtils.js +26 -1
- package/dist/testUtils.js.map +1 -1
- package/package.json +2 -1
- package/src/course-banner/Banner.jsx +26 -0
- package/src/course-banner/Banner.test.jsx +36 -0
- package/src/course-banner/CourseBanner.jsx +76 -0
- package/src/course-banner/CourseBanner.test.jsx +172 -0
- package/src/course-banner/__snapshots__/Banner.test.jsx.snap +31 -0
- package/src/course-banner/__snapshots__/CourseBanner.test.jsx.snap +63 -0
- package/src/course-banner/formatDate.js +14 -0
- package/src/course-banner/index.jsx +22 -0
- package/src/course-banner/messages.js +41 -0
- package/src/data/redux/app/selectors/courseCard.js +6 -0
- package/src/data/redux/app/selectors/courseCard.test.js +16 -0
- package/src/index.jsx +8 -1
- package/src/setupTest.js +11 -21
- package/src/testUtils.js +20 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.Banner = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _paragon = require("@openedx/paragon");
|
|
10
|
+
var _icons = require("@openedx/paragon/icons");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
const Banner = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
children,
|
|
16
|
+
variant,
|
|
17
|
+
icon,
|
|
18
|
+
className
|
|
19
|
+
} = _ref;
|
|
20
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_paragon.Alert, {
|
|
21
|
+
variant: variant,
|
|
22
|
+
className: className,
|
|
23
|
+
icon: icon,
|
|
24
|
+
children: children
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
exports.Banner = Banner;
|
|
28
|
+
Banner.defaultProps = {
|
|
29
|
+
icon: _icons.Info,
|
|
30
|
+
variant: 'info',
|
|
31
|
+
className: 'mb-0'
|
|
32
|
+
};
|
|
33
|
+
Banner.propTypes = {
|
|
34
|
+
variant: _propTypes.default.string,
|
|
35
|
+
icon: _propTypes.default.func,
|
|
36
|
+
children: _propTypes.default.node.isRequired,
|
|
37
|
+
className: _propTypes.default.string
|
|
38
|
+
};
|
|
39
|
+
var _default = exports.default = Banner;
|
|
40
|
+
//# sourceMappingURL=Banner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Banner.js","names":["_react","_interopRequireDefault","require","_propTypes","_paragon","_icons","_jsxRuntime","e","__esModule","default","Banner","_ref","children","variant","icon","className","jsx","Alert","exports","defaultProps","Info","propTypes","PropTypes","string","func","node","isRequired","_default"],"sources":["../../src/course-banner/Banner.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\n\nimport { Alert } from '@openedx/paragon';\nimport { Info } from '@openedx/paragon/icons';\n\nexport const Banner = ({\n children, variant, icon, className,\n}) => (\n <Alert variant={variant} className={className} icon={icon}>\n {children}\n </Alert>\n);\nBanner.defaultProps = {\n icon: Info,\n variant: 'info',\n className: 'mb-0',\n};\nBanner.propTypes = {\n variant: PropTypes.string,\n icon: PropTypes.func,\n children: PropTypes.node.isRequired,\n className: PropTypes.string,\n};\n\nexport default Banner;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAA8C,IAAAI,WAAA,GAAAJ,OAAA;AAAA,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEvC,MAAMG,MAAM,GAAGC,IAAA;EAAA,IAAC;IACrBC,QAAQ;IAAEC,OAAO;IAAEC,IAAI;IAAEC;EAC3B,CAAC,GAAAJ,IAAA;EAAA,oBACC,IAAAL,WAAA,CAAAU,GAAA,EAACZ,QAAA,CAAAa,KAAK;IAACJ,OAAO,EAAEA,OAAQ;IAACE,SAAS,EAAEA,SAAU;IAACD,IAAI,EAAEA,IAAK;IAAAF,QAAA,EACvDA;EAAQ,CACJ,CAAC;AAAA,CACT;AAACM,OAAA,CAAAR,MAAA,GAAAA,MAAA;AACFA,MAAM,CAACS,YAAY,GAAG;EACpBL,IAAI,EAAEM,WAAI;EACVP,OAAO,EAAE,MAAM;EACfE,SAAS,EAAE;AACb,CAAC;AACDL,MAAM,CAACW,SAAS,GAAG;EACjBR,OAAO,EAAES,kBAAS,CAACC,MAAM;EACzBT,IAAI,EAAEQ,kBAAS,CAACE,IAAI;EACpBZ,QAAQ,EAAEU,kBAAS,CAACG,IAAI,CAACC,UAAU;EACnCX,SAAS,EAAEO,kBAAS,CAACC;AACvB,CAAC;AAAC,IAAAI,QAAA,GAAAT,OAAA,CAAAT,OAAA,GAEaC,MAAM","ignoreList":[]}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _paragon = require("@openedx/paragon");
|
|
10
|
+
var _i18n = require("@edx/frontend-platform/i18n");
|
|
11
|
+
var _hooks = _interopRequireDefault(require("../data/redux/hooks"));
|
|
12
|
+
var _formatDate = require("./formatDate");
|
|
13
|
+
var _Banner = _interopRequireDefault(require("./Banner"));
|
|
14
|
+
var _messages = _interopRequireDefault(require("./messages"));
|
|
15
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
+
/* eslint-disable import/no-named-as-default-member */
|
|
18
|
+
/* eslint-disable import/no-named-as-default */
|
|
19
|
+
|
|
20
|
+
const CourseBanner = _ref => {
|
|
21
|
+
let {
|
|
22
|
+
cardId
|
|
23
|
+
} = _ref;
|
|
24
|
+
const {
|
|
25
|
+
isVerified,
|
|
26
|
+
isAuditAccessExpired,
|
|
27
|
+
canUpgrade,
|
|
28
|
+
coursewareAccess = {}
|
|
29
|
+
} = _hooks.default.useCardEnrollmentData(cardId);
|
|
30
|
+
const courseRun = _hooks.default.useCardCourseRunData(cardId);
|
|
31
|
+
const {
|
|
32
|
+
formatMessage
|
|
33
|
+
} = (0, _i18n.useIntl)();
|
|
34
|
+
const formatDate = (0, _formatDate.useFormatDate)();
|
|
35
|
+
const {
|
|
36
|
+
hasUnmetPrerequisites,
|
|
37
|
+
isStaff,
|
|
38
|
+
isTooEarly
|
|
39
|
+
} = coursewareAccess;
|
|
40
|
+
if (isVerified) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
44
|
+
children: [isAuditAccessExpired && (canUpgrade ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Banner.default, {
|
|
45
|
+
children: [formatMessage(_messages.default.auditAccessExpired), ' ', formatMessage(_messages.default.upgradeToAccess)]
|
|
46
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Banner.default, {
|
|
47
|
+
children: [formatMessage(_messages.default.auditAccessExpired), ' ', /*#__PURE__*/(0, _jsxRuntime.jsx)(_paragon.Hyperlink, {
|
|
48
|
+
isInline: true,
|
|
49
|
+
destination: "",
|
|
50
|
+
children: formatMessage(_messages.default.findAnotherCourse)
|
|
51
|
+
})]
|
|
52
|
+
})), courseRun.isActive && !canUpgrade && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Banner.default, {
|
|
53
|
+
children: [formatMessage(_messages.default.upgradeDeadlinePassed), ' ', /*#__PURE__*/(0, _jsxRuntime.jsx)(_paragon.Hyperlink, {
|
|
54
|
+
isInline: true,
|
|
55
|
+
destination: courseRun.marketingUrl || '',
|
|
56
|
+
children: formatMessage(_messages.default.exploreCourseDetails)
|
|
57
|
+
})]
|
|
58
|
+
}), !isStaff && isTooEarly && courseRun.startDate && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Banner.default, {
|
|
59
|
+
children: formatMessage(_messages.default.courseHasNotStarted, {
|
|
60
|
+
startDate: formatDate(courseRun.startDate)
|
|
61
|
+
})
|
|
62
|
+
}), !isStaff && hasUnmetPrerequisites && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Banner.default, {
|
|
63
|
+
children: formatMessage(_messages.default.prerequisitesNotMet)
|
|
64
|
+
})]
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
CourseBanner.propTypes = {
|
|
68
|
+
cardId: _propTypes.default.string.isRequired
|
|
69
|
+
};
|
|
70
|
+
var _default = exports.default = CourseBanner;
|
|
71
|
+
//# sourceMappingURL=CourseBanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CourseBanner.js","names":["_react","_interopRequireDefault","require","_propTypes","_paragon","_i18n","_hooks","_formatDate","_Banner","_messages","_jsxRuntime","e","__esModule","default","CourseBanner","_ref","cardId","isVerified","isAuditAccessExpired","canUpgrade","coursewareAccess","reduxHooks","useCardEnrollmentData","courseRun","useCardCourseRunData","formatMessage","useIntl","formatDate","useFormatDate","hasUnmetPrerequisites","isStaff","isTooEarly","jsxs","Fragment","children","messages","auditAccessExpired","upgradeToAccess","jsx","Hyperlink","isInline","destination","findAnotherCourse","isActive","upgradeDeadlinePassed","marketingUrl","exploreCourseDetails","startDate","courseHasNotStarted","prerequisitesNotMet","propTypes","PropTypes","string","isRequired","_default","exports"],"sources":["../../src/course-banner/CourseBanner.jsx"],"sourcesContent":["/* eslint-disable import/no-named-as-default-member */\n/* eslint-disable import/no-named-as-default */\nimport React from 'react';\nimport PropTypes from 'prop-types';\n\nimport { Hyperlink } from '@openedx/paragon';\nimport { useIntl } from '@edx/frontend-platform/i18n';\n\nimport reduxHooks from '../data/redux/hooks';\nimport { useFormatDate } from './formatDate';\nimport Banner from './Banner';\nimport messages from './messages';\n\nconst CourseBanner = ({ cardId }) => {\n const {\n isVerified,\n isAuditAccessExpired,\n canUpgrade,\n coursewareAccess = {},\n } = reduxHooks.useCardEnrollmentData(cardId);\n const courseRun = reduxHooks.useCardCourseRunData(cardId);\n const { formatMessage } = useIntl();\n const formatDate = useFormatDate();\n\n const { hasUnmetPrerequisites, isStaff, isTooEarly } = coursewareAccess;\n\n if (isVerified) { return null; }\n\n return (\n <>\n {isAuditAccessExpired\n && (canUpgrade ? (\n <Banner>\n {formatMessage(messages.auditAccessExpired)}\n {' '}\n {formatMessage(messages.upgradeToAccess)}\n </Banner>\n ) : (\n <Banner>\n {formatMessage(messages.auditAccessExpired)}\n {' '}\n <Hyperlink isInline destination=\"\">\n {formatMessage(messages.findAnotherCourse)}\n </Hyperlink>\n </Banner>\n ))}\n\n {courseRun.isActive && !canUpgrade && (\n <Banner>\n {formatMessage(messages.upgradeDeadlinePassed)}\n {' '}\n <Hyperlink isInline destination={courseRun.marketingUrl || ''}>\n {formatMessage(messages.exploreCourseDetails)}\n </Hyperlink>\n </Banner>\n )}\n\n {(!isStaff && isTooEarly && courseRun.startDate) && (\n <Banner>\n {formatMessage(messages.courseHasNotStarted, {\n startDate: formatDate(courseRun.startDate),\n })}\n </Banner>\n )}\n {(!isStaff && hasUnmetPrerequisites) && (\n <Banner>{formatMessage(messages.prerequisitesNotMet)}</Banner>\n )}\n </>\n );\n};\n\nCourseBanner.propTypes = {\n cardId: PropTypes.string.isRequired,\n};\n\nexport default CourseBanner;\n"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,SAAA,GAAAR,sBAAA,CAAAC,OAAA;AAAkC,IAAAQ,WAAA,GAAAR,OAAA;AAAA,SAAAD,uBAAAU,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAXlC;AACA;;AAYA,MAAMG,YAAY,GAAGC,IAAA,IAAgB;EAAA,IAAf;IAAEC;EAAO,CAAC,GAAAD,IAAA;EAC9B,MAAM;IACJE,UAAU;IACVC,oBAAoB;IACpBC,UAAU;IACVC,gBAAgB,GAAG,CAAC;EACtB,CAAC,GAAGC,cAAU,CAACC,qBAAqB,CAACN,MAAM,CAAC;EAC5C,MAAMO,SAAS,GAAGF,cAAU,CAACG,oBAAoB,CAACR,MAAM,CAAC;EACzD,MAA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oB;MAAC,CACpC,CAAC;IAAA,CACN,CACT,EAEC,CAAChB,OAAO,IAAIC,UAAU,IAAIR,SAAS,CAACwB,SAAS,iBAC7C,IAAArC,WAAA,CAAA4B,GAAA,EAAC9B,OAAA,CAAAK,OAAM;MAAAqB,QAAA,EACJT,aAAa,CAACU,iBAAQ,CAACa,mBAAmB,EAAE;QAC3CD,SAAS,EAAEpB,UAAU,CAACJ,SAAS,CAACwB,SAAS;MAC3C,CAAC;IAAC,CACI,CACT,EACC,CAACjB,OAAO,IAAID,qBAAqB,iBACjC,IAAAnB,WAAA,CAAA4B,GAAA,EAAC9B,OAAA,CAAAK,OAAM;MAAAqB,QAAA,EAAET,aAAa,CAACU,iBAAQ,CAACc,mBAAmB;IAAC,CAAS,CAC9D;EAAA,CACD,CAAC;AAEP,CAAC;AAEDnC,YAAY,CAACoC,SAAS,GAAG;EACvBlC,MAAM,EAAEmC,kBAAS,CAACC,MAAM,CAACC;AAC3B,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA1C,OAAA,GAEaC,YAAY","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useFormatDate = exports.dateFormatter = void 0;
|
|
7
|
+
var _moment = _interopRequireDefault(require("moment"));
|
|
8
|
+
var _i18n = require("@edx/frontend-platform/i18n");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const dateFormatter = (formatDate, date) => formatDate((0, _moment.default)(date).toDate(), {
|
|
11
|
+
year: 'numeric',
|
|
12
|
+
month: 'long',
|
|
13
|
+
day: 'numeric'
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// Hook
|
|
17
|
+
exports.dateFormatter = dateFormatter;
|
|
18
|
+
const useFormatDate = () => {
|
|
19
|
+
const {
|
|
20
|
+
formatDate
|
|
21
|
+
} = (0, _i18n.useIntl)();
|
|
22
|
+
return date => dateFormatter(formatDate, date);
|
|
23
|
+
};
|
|
24
|
+
exports.useFormatDate = useFormatDate;
|
|
25
|
+
//# sourceMappingURL=formatDate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatDate.js","names":["_moment","_interopRequireDefault","require","_i18n","e","__esModule","default","dateFormatter","formatDate","date","moment","toDate","year","month","day","exports","useFormatDate","useIntl"],"sources":["../../src/course-banner/formatDate.js"],"sourcesContent":["import moment from 'moment';\nimport { useIntl } from '@edx/frontend-platform/i18n';\n\nexport const dateFormatter = (formatDate, date) => formatDate(moment(date).toDate(), {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n});\n\n// Hook\nexport const useFormatDate = () => {\n const { formatDate } = useIntl();\n return (date) => dateFormatter(formatDate, date);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAAsD,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE/C,MAAMG,aAAa,GAAGA,CAACC,UAAU,EAAEC,IAAI,KAAKD,UAAU,CAAC,IAAAE,eAAM,EAACD,IAAI,CAAC,CAACE,MAAM,CAAC,CAAC,EAAE;EACnFC,IAAI,EAAE,SAAS;EACfC,KAAK,EAAE,MAAM;EACbC,GAAG,EAAE;AACP,CAAC,CAAC;;AAEF;AAAAC,OAAA,CAAAR,aAAA,GAAAA,aAAA;AACO,MAAMS,aAAa,GAAGA,CAAA,KAAM;EACjC,MAAM;IAAER;EAAW,CAAC,GAAG,IAAAS,aAAO,EAAC,CAAC;EAChC,OAAQR,IAAI,IAAKF,aAAa,CAACC,UAAU,EAAEC,IAAI,CAAC;AAClD,CAAC;AAACM,OAAA,CAAAC,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactRedux = require("react-redux");
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _CourseBanner = _interopRequireDefault(require("./CourseBanner"));
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
const CourseBannerWithProvider = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
content,
|
|
16
|
+
cardId
|
|
17
|
+
} = _ref;
|
|
18
|
+
const {
|
|
19
|
+
store
|
|
20
|
+
} = content;
|
|
21
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRedux.Provider, {
|
|
22
|
+
store: store,
|
|
23
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CourseBanner.default, {
|
|
24
|
+
cardId: cardId
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
CourseBannerWithProvider.propTypes = {
|
|
29
|
+
content: _propTypes.default.shape({
|
|
30
|
+
store: _propTypes.default.shape({})
|
|
31
|
+
}),
|
|
32
|
+
cardId: _propTypes.default.string.isRequired
|
|
33
|
+
};
|
|
34
|
+
var _default = exports.default = CourseBannerWithProvider;
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_reactRedux","_propTypes","_CourseBanner","_jsxRuntime","e","__esModule","default","CourseBannerWithProvider","_ref","content","cardId","store","jsx","Provider","children","propTypes","PropTypes","shape","string","isRequired","_default","exports"],"sources":["../../src/course-banner/index.jsx"],"sourcesContent":["import React from 'react';\nimport { Provider } from 'react-redux';\nimport PropTypes from 'prop-types';\nimport CourseBanner from './CourseBanner';\n\nconst CourseBannerWithProvider = ({ content, cardId }) => {\n const { store } = content;\n return (\n <Provider store={store}>\n <CourseBanner cardId={cardId} />\n </Provider>\n );\n};\n\nCourseBannerWithProvider.propTypes = {\n content: PropTypes.shape({\n store: PropTypes.shape({}),\n }),\n cardId: PropTypes.string.isRequired,\n};\n\nexport default CourseBannerWithProvider;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,aAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAA0C,IAAAI,WAAA,GAAAJ,OAAA;AAAA,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE1C,MAAMG,wBAAwB,GAAGC,IAAA,IAAyB;EAAA,IAAxB;IAAEC,OAAO;IAAEC;EAAO,CAAC,GAAAF,IAAA;EACnD,MAAM;IAAEG;EAAM,CAAC,GAAGF,OAAO;EACzB,oBACE,IAAAN,WAAA,CAAAS,GAAA,EAACZ,WAAA,CAAAa,QAAQ;IAACF,KAAK,EAAEA,KAAM;IAAAG,QAAA,eACrB,IAAAX,WAAA,CAAAS,GAAA,EAACV,aAAA,CAAAI,OAAY;MAACI,MAAM,EAAEA;IAAO,CAAE;EAAC,CACxB,CAAC;AAEf,CAAC;AAEDH,wBAAwB,CAACQ,SAAS,GAAG;EACnCN,OAAO,EAAEO,kBAAS,CAACC,KAAK,CAAC;IACvBN,KAAK,EAAEK,kBAAS,CAACC,KAAK,CAAC,CAAC,CAAC;EAC3B,CAAC,CAAC;EACFP,MAAM,EAAEM,kBAAS,CAACE,MAAM,CAACC;AAC3B,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAf,OAAA,GAEaC,wBAAwB","ignoreList":[]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _i18n = require("@edx/frontend-platform/i18n");
|
|
8
|
+
const messages = (0, _i18n.defineMessages)({
|
|
9
|
+
auditAccessExpired: {
|
|
10
|
+
id: 'learner-dash.courseCard.banners.auditAccessExpired',
|
|
11
|
+
description: 'Audit access expiration banner message',
|
|
12
|
+
defaultMessage: 'Your audit access to this course has expired.'
|
|
13
|
+
},
|
|
14
|
+
upgradeToAccess: {
|
|
15
|
+
id: 'learner-dash.courseCard.banners.upgradeToAccess',
|
|
16
|
+
description: 'Upgrade prompt for audit-expired learners that can still upgrade',
|
|
17
|
+
defaultMessage: 'Upgrade now to access your course again.'
|
|
18
|
+
},
|
|
19
|
+
findAnotherCourse: {
|
|
20
|
+
id: 'learner-dash.courseCard.banners.findAnotherCourse',
|
|
21
|
+
description: 'Action prompt taking learners to course exploration',
|
|
22
|
+
defaultMessage: 'Find another course'
|
|
23
|
+
},
|
|
24
|
+
upgradeDeadlinePassed: {
|
|
25
|
+
id: 'learner-dash.courseCard.banners.upgradeDeadlinePassed',
|
|
26
|
+
description: 'Audit upgrade deadline passed banner message',
|
|
27
|
+
defaultMessage: 'Your upgrade deadline for this course has passed. To upgrade, enroll in a session that is farther in the future.'
|
|
28
|
+
},
|
|
29
|
+
exploreCourseDetails: {
|
|
30
|
+
id: 'learner-dash.courseCard.banners.exploreCourseDetails',
|
|
31
|
+
description: 'Action prompt taking learners to course details page',
|
|
32
|
+
defaultMessage: 'Explore course details.'
|
|
33
|
+
},
|
|
34
|
+
prerequisitesNotMet: {
|
|
35
|
+
id: 'learner-dash.courseCard.banners.prerequisitesNotMet',
|
|
36
|
+
description: 'Message to learners with unmet prerequisites',
|
|
37
|
+
defaultMessage: 'You can\'t access this course just yet because you have not met the pre-requisites.'
|
|
38
|
+
},
|
|
39
|
+
courseHasNotStarted: {
|
|
40
|
+
id: 'learner-dash.courseCard.banners.courseHasNotStarted',
|
|
41
|
+
description: 'Course has not started message',
|
|
42
|
+
defaultMessage: 'You can\'t access this course just yet because the course hasn\'t started yet. The course will start on {startDate}.'
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
var _default = exports.default = messages;
|
|
46
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","names":["_i18n","require","messages","defineMessages","auditAccessExpired","id","description","defaultMessage","upgradeToAccess","findAnotherCourse","upgradeDeadlinePassed","exploreCourseDetails","prerequisitesNotMet","courseHasNotStarted","_default","exports","default"],"sources":["../../src/course-banner/messages.js"],"sourcesContent":["import { defineMessages } from '@edx/frontend-platform/i18n';\n\nconst messages = defineMessages({\n auditAccessExpired: {\n id: 'learner-dash.courseCard.banners.auditAccessExpired',\n description: 'Audit access expiration banner message',\n defaultMessage: 'Your audit access to this course has expired.',\n },\n upgradeToAccess: {\n id: 'learner-dash.courseCard.banners.upgradeToAccess',\n description: 'Upgrade prompt for audit-expired learners that can still upgrade',\n defaultMessage: 'Upgrade now to access your course again.',\n },\n findAnotherCourse: {\n id: 'learner-dash.courseCard.banners.findAnotherCourse',\n description: 'Action prompt taking learners to course exploration',\n defaultMessage: 'Find another course',\n },\n upgradeDeadlinePassed: {\n id: 'learner-dash.courseCard.banners.upgradeDeadlinePassed',\n description: 'Audit upgrade deadline passed banner message',\n defaultMessage: 'Your upgrade deadline for this course has passed. To upgrade, enroll in a session that is farther in the future.',\n },\n exploreCourseDetails: {\n id: 'learner-dash.courseCard.banners.exploreCourseDetails',\n description: 'Action prompt taking learners to course details page',\n defaultMessage: 'Explore course details.',\n },\n prerequisitesNotMet: {\n id: 'learner-dash.courseCard.banners.prerequisitesNotMet',\n description: 'Message to learners with unmet prerequisites',\n defaultMessage: 'You can\\'t access this course just yet because you have not met the pre-requisites.',\n },\n courseHasNotStarted: {\n id: 'learner-dash.courseCard.banners.courseHasNotStarted',\n description: 'Course has not started message',\n defaultMessage: 'You can\\'t access this course just yet because the course hasn\\'t started yet. The course will start on {startDate}.',\n },\n});\n\nexport default messages;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAEA,MAAMC,QAAQ,GAAG,IAAAC,oBAAc,EAAC;EAC9BC,kBAAkB,EAAE;IAClBC,EAAE,EAAE,oDAAoD;IACxDC,WAAW,EAAE,wCAAwC;IACrDC,cAAc,EAAE;EAClB,CAAC;EACDC,eAAe,EAAE;IACfH,EAAE,EAAE,iDAAiD;IACrDC,WAAW,EAAE,kEAAkE;IAC/EC,cAAc,EAAE;EAClB,CAAC;EACDE,iBAAiB,EAAE;IACjBJ,EAAE,EAAE,mDAAmD;IACvDC,WAAW,EAAE,qDAAqD;IAClEC,cAAc,EAAE;EAClB,CAAC;EACDG,qBAAqB,EAAE;IACrBL,EAAE,EAAE,uDAAuD;IAC3DC,WAAW,EAAE,8CAA8C;IAC3DC,cAAc,EAAE;EAClB,CAAC;EACDI,oBAAoB,EAAE;IACpBN,EAAE,EAAE,sDAAsD;IAC1DC,WAAW,EAAE,sDAAsD;IACnEC,cAAc,EAAE;EAClB,CAAC;EACDK,mBAAmB,EAAE;IACnBP,EAAE,EAAE,qDAAqD;IACzDC,WAAW,EAAE,8CAA8C;IAC3DC,cAAc,EAAE;EAClB,CAAC;EACDM,mBAAmB,EAAE;IACnBR,EAAE,EAAE,qDAAqD;IACzDC,WAAW,EAAE,gCAAgC;IAC7CC,cAAc,EAAE;EAClB;AACF,CAAC,CAAC;AAAC,IAAAO,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEYd,QAAQ","ignoreList":[]}
|
|
@@ -8,11 +8,13 @@ var _constants = require("../constants");
|
|
|
8
8
|
var _simpleSelectors = require("./simpleSelectors");
|
|
9
9
|
// Selectors for retrieving course card data in the redux store
|
|
10
10
|
|
|
11
|
+
const loadDateVal = date => date ? new Date(date) : null;
|
|
11
12
|
const courseCard = exports.courseCard = {
|
|
12
13
|
course: (0, _simpleSelectors.mkCardSelector)(_simpleSelectors.cardSimpleSelectors.course, course => ({
|
|
13
14
|
courseName: course.courseName
|
|
14
15
|
})),
|
|
15
16
|
courseRun: (0, _simpleSelectors.mkCardSelector)(_simpleSelectors.cardSimpleSelectors.courseRun, courseRun => courseRun === null ? {} : {
|
|
17
|
+
startDate: loadDateVal(courseRun.startDate),
|
|
16
18
|
upgradeUrl: courseRun.upgradeUrl,
|
|
17
19
|
courseId: courseRun.courseId
|
|
18
20
|
}),
|
|
@@ -33,7 +35,9 @@ const courseCard = exports.courseCard = {
|
|
|
33
35
|
};
|
|
34
36
|
}
|
|
35
37
|
return {
|
|
38
|
+
coursewareAccess: enrollment.coursewareAccess,
|
|
36
39
|
isEnrolled: enrollment.isEnrolled,
|
|
40
|
+
isAuditAccessExpired: enrollment.isAuditAccessExpired,
|
|
37
41
|
isVerified: enrollment.isVerified,
|
|
38
42
|
isExecEd2UCourse: _constants.EXECUTIVE_EDUCATION_COURSE_MODES.includes(enrollment.mode),
|
|
39
43
|
canUpgrade: enrollment.canUpgrade
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"courseCard.js","names":["_constants","require","_simpleSelectors","courseCard","exports","course","mkCardSelector","cardSimpleSelectors","courseName","courseRun","upgradeUrl","courseId","entitlement","Object","keys","length","isEntitlement","enrollment","isEnrolled","isVerified","isExecEd2UCourse","EXECUTIVE_EDUCATION_COURSE_MODES","includes","mode","canUpgrade","courseProvider","name","_default","default"],"sources":["../../../../../src/data/redux/app/selectors/courseCard.js"],"sourcesContent":["// Selectors for retrieving course card data in the redux store\n\nimport { EXECUTIVE_EDUCATION_COURSE_MODES } from '../constants';\nimport { cardSimpleSelectors, mkCardSelector } from './simpleSelectors';\n\nexport const courseCard = {\n course: mkCardSelector(\n cardSimpleSelectors.course,\n (course) => ({\n courseName: course.courseName,\n }),\n ),\n courseRun: mkCardSelector(\n cardSimpleSelectors.courseRun,\n (courseRun) => (courseRun === null ? {} : {\n upgradeUrl: courseRun.upgradeUrl,\n courseId: courseRun.courseId,\n }),\n ),\n entitlement: mkCardSelector(\n cardSimpleSelectors.entitlement,\n (entitlement) => {\n if (!entitlement || Object.keys(entitlement).length === 0) {\n return { isEntitlement: false };\n }\n return {\n isEntitlement: true,\n };\n },\n ),\n enrollment: mkCardSelector(\n cardSimpleSelectors.enrollment,\n (enrollment) => {\n if (enrollment == null) {\n return { isEnrolled: false };\n }\n return {\n isEnrolled: enrollment.isEnrolled,\n isVerified: enrollment.isVerified,\n isExecEd2UCourse: EXECUTIVE_EDUCATION_COURSE_MODES.includes(enrollment.mode),\n canUpgrade: enrollment.canUpgrade,\n };\n },\n ),\n courseProvider: mkCardSelector(\n cardSimpleSelectors.courseProvider,\n (courseProvider) => ({ name: courseProvider?.name }),\n ),\n};\n\nexport default courseCard;\n"],"mappings":";;;;;;AAEA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAHA;;
|
|
1
|
+
{"version":3,"file":"courseCard.js","names":["_constants","require","_simpleSelectors","loadDateVal","date","Date","courseCard","exports","course","mkCardSelector","cardSimpleSelectors","courseName","courseRun","startDate","upgradeUrl","courseId","entitlement","Object","keys","length","isEntitlement","enrollment","isEnrolled","coursewareAccess","isAuditAccessExpired","isVerified","isExecEd2UCourse","EXECUTIVE_EDUCATION_COURSE_MODES","includes","mode","canUpgrade","courseProvider","name","_default","default"],"sources":["../../../../../src/data/redux/app/selectors/courseCard.js"],"sourcesContent":["// Selectors for retrieving course card data in the redux store\n\nimport { EXECUTIVE_EDUCATION_COURSE_MODES } from '../constants';\nimport { cardSimpleSelectors, mkCardSelector } from './simpleSelectors';\n\nconst loadDateVal = (date) => (date ? new Date(date) : null);\n\nexport const courseCard = {\n course: mkCardSelector(\n cardSimpleSelectors.course,\n (course) => ({\n courseName: course.courseName,\n }),\n ),\n courseRun: mkCardSelector(\n cardSimpleSelectors.courseRun,\n (courseRun) => (courseRun === null ? {} : {\n startDate: loadDateVal(courseRun.startDate),\n upgradeUrl: courseRun.upgradeUrl,\n courseId: courseRun.courseId,\n }),\n ),\n entitlement: mkCardSelector(\n cardSimpleSelectors.entitlement,\n (entitlement) => {\n if (!entitlement || Object.keys(entitlement).length === 0) {\n return { isEntitlement: false };\n }\n return {\n isEntitlement: true,\n };\n },\n ),\n enrollment: mkCardSelector(\n cardSimpleSelectors.enrollment,\n (enrollment) => {\n if (enrollment == null) {\n return { isEnrolled: false };\n }\n return {\n coursewareAccess: enrollment.coursewareAccess,\n isEnrolled: enrollment.isEnrolled,\n\n isAuditAccessExpired: enrollment.isAuditAccessExpired,\n isVerified: enrollment.isVerified,\n isExecEd2UCourse: EXECUTIVE_EDUCATION_COURSE_MODES.includes(enrollment.mode),\n canUpgrade: enrollment.canUpgrade,\n };\n },\n ),\n courseProvider: mkCardSelector(\n cardSimpleSelectors.courseProvider,\n (courseProvider) => ({ name: courseProvider?.name }),\n ),\n};\n\nexport default courseCard;\n"],"mappings":";;;;;;AAEA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAHA;;AAKA,MAAME,WAAW,GAAIC,IAAI,IAAMA,IAAI,GAAG,IAAIC,IAAI,CAACD,IAAI,CAAC,GAAG,IAAK;AAErD,MAAME,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG;EACxBE,MAAM,EAAE,IAAAC,+BAAc,EACpBC,oCAAmB,CAACF,MAAM,EACzBA,MAAM,KAAM;IACXG,UAAU,EAAEH,MAAM,CAACG;EACrB,CAAC,CACH,CAAC;EACDC,SAAS,EAAE,IAAAH,+BAAc,EACvBC,oCAAmB,CAACE,SAAS,EAC5BA,SAAS,IAAMA,SAAS,KAAK,IAAI,GAAG,CAAC,CAAC,GAAG;IACxCC,SAAS,EAAEV,WAAW,CAACS,SAAS,CAACC,SAAS,CAAC;IAC3CC,UAAU,EAAEF,SAAS,CAACE,UAAU;IAChCC,QAAQ,EAAEH,SAAS,CAACG;EACtB,CACF,CAAC;EACDC,WAAW,EAAE,IAAAP,+BAAc,EACzBC,oCAAmB,CAACM,WAAW,EAC9BA,WAAW,IAAK;IACf,IAAI,CAACA,WAAW,IAAIC,MAAM,CAACC,IAAI,CAACF,WAAW,CAAC,CAACG,MAAM,KAAK,CAAC,EAAE;MACzD,OAAO;QAAEC,aAAa,EAAE;MAAM,CAAC;IACjC;IACA,OAAO;MACLA,aAAa,EAAE;IACjB,CAAC;EACH,CACF,CAAC;EACDC,UAAU,EAAE,IAAAZ,+BAAc,EACxBC,oCAAmB,CAACW,UAAU,EAC7BA,UAAU,IAAK;IACd,IAAIA,UAAU,IAAI,IAAI,EAAE;MACtB,OAAO;QAAEC,UAAU,EAAE;MAAM,CAAC;IAC9B;IACA,OAAO;MACLC,gBAAgB,EAAEF,UAAU,CAACE,gBAAgB;MAC7CD,UAAU,EAAED,UAAU,CAACC,UAAU;MAEjCE,oBAAoB,EAAEH,UAAU,CAACG,oBAAoB;MACrDC,UAAU,EAAEJ,UAAU,CAACI,UAAU;MACjCC,gBAAgB,EAAEC,2CAAgC,CAACC,QAAQ,CAACP,UAAU,CAACQ,IAAI,CAAC;MAC5EC,UAAU,EAAET,UAAU,CAACS;IACzB,CAAC;EACH,CACF,CAAC;EACDC,cAAc,EAAE,IAAAtB,+BAAc,EAC5BC,oCAAmB,CAACqB,cAAc,EACjCA,cAAc,KAAM;IAAEC,IAAI,EAAED,cAAc,EAAEC;EAAK,CAAC,CACrD;AACF,CAAC;AAAC,IAAAC,QAAA,GAAA1B,OAAA,CAAA2B,OAAA,GAEa5B,UAAU","ignoreList":[]}
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,12 @@ Object.defineProperty(exports, "CohesionWrapper", {
|
|
|
9
9
|
return _index.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
+
Object.defineProperty(exports, "CourseBanner", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _courseBanner.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
12
18
|
Object.defineProperty(exports, "EnterpriseDashboardModal", {
|
|
13
19
|
enumerable: true,
|
|
14
20
|
get: function () {
|
|
@@ -40,6 +46,7 @@ Object.defineProperty(exports, "UserDashboardMenu", {
|
|
|
40
46
|
}
|
|
41
47
|
});
|
|
42
48
|
var _index = _interopRequireDefault(require("./cohesion-wrapper/index"));
|
|
49
|
+
var _courseBanner = _interopRequireDefault(require("./course-banner"));
|
|
43
50
|
var _index2 = _interopRequireDefault(require("./dashboard-modal/index"));
|
|
44
51
|
var _index3 = _interopRequireDefault(require("./chatbot/index"));
|
|
45
52
|
var _upgradeButton = _interopRequireDefault(require("./upgrade-button"));
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_index","_interopRequireDefault","require","_index2","_index3","_upgradeButton","_index4","_index5","e","__esModule","default"],"sources":["../src/index.jsx"],"sourcesContent":["import CohesionWrapper from './cohesion-wrapper/index';\nimport EnterpriseDashboardModal from './dashboard-modal/index';\nimport HelpChatbot from './chatbot/index';\nimport UpgradeButton from './upgrade-button';\nimport UserCareerMenu from './career-menu/index';\nimport UserDashboardMenu from './dashboard-menu/index';\n\nexport {\n CohesionWrapper
|
|
1
|
+
{"version":3,"file":"index.js","names":["_index","_interopRequireDefault","require","_courseBanner","_index2","_index3","_upgradeButton","_index4","_index5","e","__esModule","default"],"sources":["../src/index.jsx"],"sourcesContent":["import CohesionWrapper from './cohesion-wrapper/index';\nimport CourseBanner from './course-banner';\nimport EnterpriseDashboardModal from './dashboard-modal/index';\nimport HelpChatbot from './chatbot/index';\nimport UpgradeButton from './upgrade-button';\nimport UserCareerMenu from './career-menu/index';\nimport UserDashboardMenu from './dashboard-menu/index';\n\nexport {\n CohesionWrapper,\n CourseBanner,\n EnterpriseDashboardModal,\n HelpChatbot,\n UpgradeButton,\n UserCareerMenu,\n UserDashboardMenu,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,OAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,cAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,OAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,OAAA,GAAAP,sBAAA,CAAAC,OAAA;AAAuD,SAAAD,uBAAAQ,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
|
package/dist/package.json
CHANGED
package/dist/setupTest.js
CHANGED
|
@@ -29,29 +29,18 @@ jest.mock('@src/generic/messages', () => jest.fn(() => {}), {
|
|
|
29
29
|
|
|
30
30
|
// Mock the `formatMessage` utility from i18n
|
|
31
31
|
// For working with shallow renders in tests via @edx/react-unit-test-utils
|
|
32
|
-
jest.mock('@edx/frontend-platform/i18n', () =>
|
|
33
|
-
|
|
34
|
-
formatMessage
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
values
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
Object.keys(values).forEach(key => {
|
|
48
|
-
// eslint-disable-next-line
|
|
49
|
-
message = message.replaceAll(`{${key}}`, values[key]);
|
|
50
|
-
});
|
|
51
|
-
return message;
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
}));
|
|
32
|
+
jest.mock('@edx/frontend-platform/i18n', () => {
|
|
33
|
+
const {
|
|
34
|
+
formatMessage
|
|
35
|
+
} = jest.requireActual('./testUtils');
|
|
36
|
+
const formatDate = jest.fn(date => new Date(date).toLocaleDateString()).mockName('useIntl.formatDate');
|
|
37
|
+
return _objectSpread(_objectSpread({}, jest.requireActual('@edx/frontend-platform/i18n')), {}, {
|
|
38
|
+
useIntl: () => ({
|
|
39
|
+
formatMessage,
|
|
40
|
+
formatDate
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
});
|
|
55
44
|
|
|
56
45
|
/* eslint-disable no-console */
|
|
57
46
|
const supressWarningBlock = callback => {
|
package/dist/setupTest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupTest.js","names":["require","_react","_interopRequireDefault","_propTypes","_react2","_frontendPlatform","_i18n","_logging","_jsxRuntime","e","__esModule","default","_objectDestructuringEmpty","t","TypeError","ownKeys","r","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","String","Number","mergeConfig","process","env","jest","mock","fn","virtual","
|
|
1
|
+
{"version":3,"file":"setupTest.js","names":["require","_react","_interopRequireDefault","_propTypes","_react2","_frontendPlatform","_i18n","_logging","_jsxRuntime","e","__esModule","default","_objectDestructuringEmpty","t","TypeError","ownKeys","r","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","String","Number","mergeConfig","process","env","jest","mock","fn","virtual","formatMessage","requireActual","formatDate","date","Date","toLocaleDateString","mockName","useIntl","supressWarningBlock","callback","originalConsoleWarning","console","warn","MockLoggingService","constructor","infoString","log","errorString","initializeIntl","loggingService","configureLogging","config","getConfig","configureI18n","messages","exports","render","ui","_ref","undefined","renderOptions","assign","Wrapper","_ref2","children","jsx","IntlProvider","locale","propTypes","PropTypes","node","isRequired","rtlRender","wrapper","_default"],"sources":["../src/setupTest.js"],"sourcesContent":["import 'core-js/stable';\nimport 'regenerator-runtime/runtime';\nimport '@testing-library/jest-dom'; // eslint-disable-line import/no-extraneous-dependencies\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { render as rtlRender } from '@testing-library/react'; // eslint-disable-line import/no-extraneous-dependencies\nimport { getConfig, mergeConfig } from '@edx/frontend-platform';\nimport { configure as configureI18n, IntlProvider } from '@edx/frontend-platform/i18n';\nimport { configure as configureLogging } from '@edx/frontend-platform/logging';\n\nmergeConfig({\n ...process.env,\n});\n\njest.mock('@src/generic/messages', () => jest.fn(() => { }), { virtual: true });\n\n// Mock the `formatMessage` utility from i18n\n// For working with shallow renders in tests via @edx/react-unit-test-utils\njest.mock('@edx/frontend-platform/i18n', () => {\n const { formatMessage } = jest.requireActual('./testUtils');\n const formatDate = jest.fn(date => new Date(date).toLocaleDateString()).mockName('useIntl.formatDate');\n return {\n ...jest.requireActual('@edx/frontend-platform/i18n'),\n useIntl: () => ({\n formatMessage,\n formatDate,\n }),\n };\n});\n\n/* eslint-disable no-console */\nconst supressWarningBlock = (callback) => {\n const originalConsoleWarning = console.warn;\n console.warn = jest.fn();\n callback();\n console.warn = originalConsoleWarning;\n};\n/* eslint-enable no-console */\n\nclass MockLoggingService {\n // eslint-disable-next-line no-console\n logInfo = jest.fn(infoString => console.log(infoString));\n\n // eslint-disable-next-line no-console\n logError = jest.fn(errorString => console.log(errorString));\n}\n\nexport const initializeIntl = () => {\n const loggingService = configureLogging(MockLoggingService, {\n config: getConfig(),\n });\n\n // i18n doesn't have a service class to return.\n // ignore missing/unexpect locale warnings from @edx/frontend-platform/i18n\n // it is unnecessary and not relevant to the tests\n supressWarningBlock(() => configureI18n({\n config: getConfig(),\n loggingService,\n messages: [],\n }));\n};\n\nfunction render(\n ui,\n {\n ...renderOptions\n } = {},\n) {\n const Wrapper = ({ children }) => (\n // eslint-disable-next-line react/jsx-filename-extension\n <IntlProvider locale=\"en\">\n {children}\n </IntlProvider>\n );\n\n Wrapper.propTypes = {\n children: PropTypes.node.isRequired,\n };\n\n return rtlRender(ui, { wrapper: Wrapper, ...renderOptions });\n}\n\nexport default render;\n"],"mappings":";;;;;;AAAAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,UAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AAA+E,IAAAQ,WAAA,GAAAR,OAAA;AAAA,SAAAE,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,0BAAAC,CAAA,gBAAAA,CAAA,YAAAC,SAAA,yBAAAD,CAAA;AAAA,SAAAE,QAAAN,CAAA,EAAAO,CAAA,QAAAH,CAAA,GAAAI,MAAA,CAAAC,IAAA,CAAAT,CAAA,OAAAQ,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAV,CAAA,GAAAO,CAAA,KAAAI,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAL,CAAA,WAAAC,MAAA,CAAAK,wBAAA,CAAAb,CAAA,EAAAO,CAAA,EAAAO,UAAA,OAAAV,CAAA,CAAAW,IAAA,CAAAC,KAAA,CAAAZ,CAAA,EAAAO,CAAA,YAAAP,CAAA;AAAA,SAAAa,cAAAjB,CAAA,aAAAO,CAAA,MAAAA,CAAA,GAAAW,SAAA,CAAAC,MAAA,EAAAZ,CAAA,UAAAH,CAAA,WAAAc,SAAA,CAAAX,CAAA,IAAAW,SAAA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Ac,GAAG,IAAAC,kBAAgB,EAACP,kBAAkB,EAAE;IAC1DQ,MAAM,EAAE,IAAAC,2BAAS,EAAC;EACpB,CAAC,CAAC;;EAEF;EACA;EACA;EACAd,mBAAmB,CAAC,MAAM,IAAAe,eAAa,EAAC;IACtCF,MAAM,EAAE,IAAAC,2BAAS,EAAC,CAAC;IACnBH,cAAc;IACdK,QAAQ,EAAE;EACZ,CAAC,CAAC,CAAC;AACL,CAAC;AAACC,OAAA,CAAAP,cAAA,GAAAA,cAAA;AAEF,SAASQ,MAAMA,CACbC,EAAE,EAIF;EAAA,IAAAC,IAAA,GAAArD,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAsD,SAAA,GAAAtD,SAAA,MADI,CAAC,CAAC;EAAA,IADDuD,aAAa,GAAAjE,MAAA,CAAAkE,MAAA,MAAAvE,yBAAA,CAAAoE,IAAA,GAAAA,IAAA;EAGlB,MAAMI,OAAO,GAAGC,KAAA;IAAA,IAAC;MAAEC;IAAS,CAAC,GAAAD,KAAA;IAAA;MAAA;MAC3B;MACA,IAAA7E,WAAA,CAAA+E,GAAA,EAACjF,KAAA,CAAAkF,YAAY;QAACC,MAAM,EAAC,IAAI;QAAAH,QAAA,EACtBA;MAAQ,CACG;IAAC;EAAA,CAChB;EAEDF,OAAO,CAACM,SAAS,GAAG;IAClBJ,QAAQ,EAAEK,kBAAS,CAACC,IAAI,CAACC;EAC3B,CAAC;EAED,OAAO,IAAAC,cAAS,EAACf,EAAE,EAAArD,aAAA;IAAIqE,OAAO,EAAEX;EAAO,GAAKF,aAAa,CAAE,CAAC;AAC9D;AAAC,IAAAc,QAAA,GAAAnB,OAAA,CAAAlE,OAAA,GAEcmE,MAAM","ignoreList":[]}
|
package/dist/testUtils.js
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.MockUseState = void 0;
|
|
6
|
+
exports.formatMessage = exports.MockUseState = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
10
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
11
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -85,5 +86,29 @@ class MockUseState {
|
|
|
85
86
|
return _objectSpread({}, this.hooks.state);
|
|
86
87
|
}
|
|
87
88
|
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Mocked formatMessage provided by react-intl
|
|
92
|
+
*/
|
|
88
93
|
exports.MockUseState = MockUseState;
|
|
94
|
+
const formatMessage = (msg, values) => {
|
|
95
|
+
let message = msg.defaultMessage;
|
|
96
|
+
if (values === undefined) {
|
|
97
|
+
return message;
|
|
98
|
+
}
|
|
99
|
+
// check if value is not a primitive type.
|
|
100
|
+
if (Object.values(values).filter(value => Object(value) === value).length) {
|
|
101
|
+
// eslint-disable-next-line react/jsx-filename-extension
|
|
102
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("format-message-function", {
|
|
103
|
+
message: msg,
|
|
104
|
+
values
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
Object.keys(values).forEach(key => {
|
|
108
|
+
// eslint-disable-next-line
|
|
109
|
+
message = message.replaceAll(`{${key}}`, values[key]);
|
|
110
|
+
});
|
|
111
|
+
return message;
|
|
112
|
+
};
|
|
113
|
+
exports.formatMessage = formatMessage;
|
|
89
114
|
//# sourceMappingURL=testUtils.js.map
|
package/dist/testUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testUtils.js","names":["_react","_interopRequireDefault","require","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","MockUseState","constructor","hooks","oldState","setState","stateVals","mock","bind","restore","mockVal","testGetter","state","reduce","obj","key","jest","fn","val","expectInitializedWith","expect","toHaveBeenCalledWith","expectSetStateCalledWith","mockReturnValueOnce","test","testValue","useState","spyOn","react","mockImplementationOnce","toEqual","values","exports"],"sources":["../src/testUtils.js"],"sourcesContent":["import react from 'react';\n\nexport class MockUseState {\n constructor(hooks) {\n this.hooks = hooks;\n this.oldState = null;\n this.setState = {};\n this.stateVals = {};\n\n this.mock = this.mock.bind(this);\n this.restore = this.restore.bind(this);\n this.mockVal = this.mockVal.bind(this);\n this.testGetter = this.testGetter.bind(this);\n }\n\n /**\n * @return {object} - dict of state object keys\n */\n get keys() {\n return Object.keys(this.hooks.state).reduce(\n (obj, key) => ({ ...obj, [key]: key }),\n {},\n );\n }\n\n /**\n * Replace the hook module's state object with a mocked version, initialized to default values.\n */\n mock() {\n this.oldState = this.hooks.state;\n Object.keys(this.keys).forEach(key => {\n this.hooks.state[key] = jest.fn(val => {\n this.stateVals[key] = val;\n return [val, this.setState[key]];\n });\n });\n this.setState = Object.keys(this.keys).reduce(\n (obj, key) => ({\n ...obj,\n [key]: jest.fn(val => {\n this.hooks.state[key] = val;\n }),\n }),\n {},\n );\n }\n\n expectInitializedWith(key, value) {\n expect(this.hooks.state[key]).toHaveBeenCalledWith(value);\n }\n\n expectSetStateCalledWith(key, value) {\n expect(this.setState[key]).toHaveBeenCalledWith(value);\n }\n\n /**\n * Restore the hook module's state object to the actual code.\n */\n restore() {\n this.hooks.state = this.oldState;\n }\n\n /**\n * Mock the state getter associated with a single key to return a specific value one time.\n * @param {string} key - state key (from this.keys)\n * @param {any} val - new value to be returned by the useState call.\n */\n mockVal(key, val) {\n this.hooks.state[key].mockReturnValueOnce([val, this.setState[key]]);\n }\n\n testGetter(key) {\n test(`${key} state getter should return useState passthrough`, () => {\n const testValue = 'some value';\n const useState = (val) => ({ useState: val });\n jest.spyOn(react, 'useState').mockImplementationOnce(useState);\n expect(this.hooks.state[key](testValue)).toEqual(useState(testValue));\n });\n }\n\n get values() {\n return { ...this.hooks.state };\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA0B,SAAAD,
|
|
1
|
+
{"version":3,"file":"testUtils.js","names":["_react","_interopRequireDefault","require","_jsxRuntime","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","MockUseState","constructor","hooks","oldState","setState","stateVals","mock","bind","restore","mockVal","testGetter","state","reduce","obj","key","jest","fn","val","expectInitializedWith","expect","toHaveBeenCalledWith","expectSetStateCalledWith","mockReturnValueOnce","test","testValue","useState","spyOn","react","mockImplementationOnce","toEqual","values","exports","formatMessage","msg","message","defaultMessage","undefined","jsx","replaceAll"],"sources":["../src/testUtils.js"],"sourcesContent":["import react from 'react';\n\nexport class MockUseState {\n constructor(hooks) {\n this.hooks = hooks;\n this.oldState = null;\n this.setState = {};\n this.stateVals = {};\n\n this.mock = this.mock.bind(this);\n this.restore = this.restore.bind(this);\n this.mockVal = this.mockVal.bind(this);\n this.testGetter = this.testGetter.bind(this);\n }\n\n /**\n * @return {object} - dict of state object keys\n */\n get keys() {\n return Object.keys(this.hooks.state).reduce(\n (obj, key) => ({ ...obj, [key]: key }),\n {},\n );\n }\n\n /**\n * Replace the hook module's state object with a mocked version, initialized to default values.\n */\n mock() {\n this.oldState = this.hooks.state;\n Object.keys(this.keys).forEach(key => {\n this.hooks.state[key] = jest.fn(val => {\n this.stateVals[key] = val;\n return [val, this.setState[key]];\n });\n });\n this.setState = Object.keys(this.keys).reduce(\n (obj, key) => ({\n ...obj,\n [key]: jest.fn(val => {\n this.hooks.state[key] = val;\n }),\n }),\n {},\n );\n }\n\n expectInitializedWith(key, value) {\n expect(this.hooks.state[key]).toHaveBeenCalledWith(value);\n }\n\n expectSetStateCalledWith(key, value) {\n expect(this.setState[key]).toHaveBeenCalledWith(value);\n }\n\n /**\n * Restore the hook module's state object to the actual code.\n */\n restore() {\n this.hooks.state = this.oldState;\n }\n\n /**\n * Mock the state getter associated with a single key to return a specific value one time.\n * @param {string} key - state key (from this.keys)\n * @param {any} val - new value to be returned by the useState call.\n */\n mockVal(key, val) {\n this.hooks.state[key].mockReturnValueOnce([val, this.setState[key]]);\n }\n\n testGetter(key) {\n test(`${key} state getter should return useState passthrough`, () => {\n const testValue = 'some value';\n const useState = (val) => ({ useState: val });\n jest.spyOn(react, 'useState').mockImplementationOnce(useState);\n expect(this.hooks.state[key](testValue)).toEqual(useState(testValue));\n });\n }\n\n get values() {\n return { ...this.hooks.state };\n }\n}\n\n/**\n * Mocked formatMessage provided by react-intl\n */\nexport const formatMessage = (msg, values) => {\n let message = msg.defaultMessage;\n if (values === undefined) {\n return message;\n }\n // check if value is not a primitive type.\n if (Object.values(values).filter(value => Object(value) === value).length) {\n // eslint-disable-next-line react/jsx-filename-extension\n return <format-message-function {...{ message: msg, values }} />;\n }\n Object.keys(values).forEach((key) => {\n // eslint-disable-next-line\n message = message.replaceAll(`{${key}}`, values[key]);\n });\n return message;\n};\n"],"mappings":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KAAKM,SAAS,EAAE;IACxB,OAAOF,OAAO;EAChB;EACA;EACA,IAAI/D,MAAM,CAAC2D,MAAM,CAACA,MAAM,CAAC,CAACvD,MAAM,CAACc,KAAK,IAAIlB,MAAM,CAACkB,KAAK,CAAC,KAAKA,KAAK,CAAC,CAACP,MAAM,EAAE;IACzE;IACA,oBAAO,IAAAlB,WAAA,CAAAyE,GAAA;MAA+BH,OAAO,EAAED,GAAG;MAAEH;IAAM,CAAK,CAAC;EAClE;EACA3D,MAAM,CAACC,IAAI,CAAC0D,MAAM,CAAC,CAAC/C,OAAO,CAAE+B,GAAG,IAAK;IACnC;IACAoB,OAAO,GAAGA,OAAO,CAACI,UAAU,CAAC,IAAIxB,GAAG,GAAG,EAAEgB,MAAM,CAAChB,GAAG,CAAC,CAAC;EACvD,CAAC,CAAC;EACF,OAAOoB,OAAO;AAChB,CAAC;AAACH,OAAA,CAAAC,aAAA,GAAAA,aAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edx/frontend-plugin-learner-dashboard",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Repository for Learner Dashboard MFE frontend plugins",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
"@edx/frontend-platform": "^8.1.0",
|
|
59
59
|
"@openedx/paragon": "^22.7.0",
|
|
60
60
|
"core-js": "^3.38.1",
|
|
61
|
+
"moment": "^2.30.1",
|
|
61
62
|
"prop-types": "15.8.1",
|
|
62
63
|
"react": "17.0.2",
|
|
63
64
|
"regenerator-runtime": "0.14.1"
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import { Alert } from '@openedx/paragon';
|
|
5
|
+
import { Info } from '@openedx/paragon/icons';
|
|
6
|
+
|
|
7
|
+
export const Banner = ({
|
|
8
|
+
children, variant, icon, className,
|
|
9
|
+
}) => (
|
|
10
|
+
<Alert variant={variant} className={className} icon={icon}>
|
|
11
|
+
{children}
|
|
12
|
+
</Alert>
|
|
13
|
+
);
|
|
14
|
+
Banner.defaultProps = {
|
|
15
|
+
icon: Info,
|
|
16
|
+
variant: 'info',
|
|
17
|
+
className: 'mb-0',
|
|
18
|
+
};
|
|
19
|
+
Banner.propTypes = {
|
|
20
|
+
variant: PropTypes.string,
|
|
21
|
+
icon: PropTypes.func,
|
|
22
|
+
children: PropTypes.node.isRequired,
|
|
23
|
+
className: PropTypes.string,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default Banner;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// TODO: search for and remove all of these eslint lint disables now that it is disables in eslintrc
|
|
2
|
+
/* eslint-disable import/no-named-as-default */
|
|
3
|
+
import { shallow } from '@edx/react-unit-test-utils';
|
|
4
|
+
|
|
5
|
+
import { Alert } from '@openedx/paragon';
|
|
6
|
+
|
|
7
|
+
import Banner from './Banner';
|
|
8
|
+
|
|
9
|
+
jest.mock('@openedx/paragon', () => ({
|
|
10
|
+
...jest.requireActual('@openedx/paragon'),
|
|
11
|
+
Alert: () => 'Alert',
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
describe('Banner', () => {
|
|
15
|
+
const props = {
|
|
16
|
+
children: 'Hello, world!',
|
|
17
|
+
};
|
|
18
|
+
describe('snapshot', () => {
|
|
19
|
+
test('renders default banner', () => {
|
|
20
|
+
const wrapper = shallow(<Banner {...props} />);
|
|
21
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
22
|
+
|
|
23
|
+
expect(wrapper.instance.findByType(Alert)[0].props.variant).toEqual('info');
|
|
24
|
+
});
|
|
25
|
+
test('renders with variants', () => {
|
|
26
|
+
const wrapper = shallow(<Banner {...props} variant="success" />);
|
|
27
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
28
|
+
|
|
29
|
+
expect(wrapper.instance.findByType(Alert)[0].props.variant).toEqual('success');
|
|
30
|
+
});
|
|
31
|
+
test('renders with custom class', () => {
|
|
32
|
+
const wrapper = shallow(<Banner {...props} className="custom-class" />);
|
|
33
|
+
expect(wrapper.snapshot).toMatchSnapshot();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/* eslint-disable import/no-named-as-default-member */
|
|
2
|
+
/* eslint-disable import/no-named-as-default */
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
|
|
6
|
+
import { Hyperlink } from '@openedx/paragon';
|
|
7
|
+
import { useIntl } from '@edx/frontend-platform/i18n';
|
|
8
|
+
|
|
9
|
+
import reduxHooks from '../data/redux/hooks';
|
|
10
|
+
import { useFormatDate } from './formatDate';
|
|
11
|
+
import Banner from './Banner';
|
|
12
|
+
import messages from './messages';
|
|
13
|
+
|
|
14
|
+
const CourseBanner = ({ cardId }) => {
|
|
15
|
+
const {
|
|
16
|
+
isVerified,
|
|
17
|
+
isAuditAccessExpired,
|
|
18
|
+
canUpgrade,
|
|
19
|
+
coursewareAccess = {},
|
|
20
|
+
} = reduxHooks.useCardEnrollmentData(cardId);
|
|
21
|
+
const courseRun = reduxHooks.useCardCourseRunData(cardId);
|
|
22
|
+
const { formatMessage } = useIntl();
|
|
23
|
+
const formatDate = useFormatDate();
|
|
24
|
+
|
|
25
|
+
const { hasUnmetPrerequisites, isStaff, isTooEarly } = coursewareAccess;
|
|
26
|
+
|
|
27
|
+
if (isVerified) { return null; }
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<>
|
|
31
|
+
{isAuditAccessExpired
|
|
32
|
+
&& (canUpgrade ? (
|
|
33
|
+
<Banner>
|
|
34
|
+
{formatMessage(messages.auditAccessExpired)}
|
|
35
|
+
{' '}
|
|
36
|
+
{formatMessage(messages.upgradeToAccess)}
|
|
37
|
+
</Banner>
|
|
38
|
+
) : (
|
|
39
|
+
<Banner>
|
|
40
|
+
{formatMessage(messages.auditAccessExpired)}
|
|
41
|
+
{' '}
|
|
42
|
+
<Hyperlink isInline destination="">
|
|
43
|
+
{formatMessage(messages.findAnotherCourse)}
|
|
44
|
+
</Hyperlink>
|
|
45
|
+
</Banner>
|
|
46
|
+
))}
|
|
47
|
+
|
|
48
|
+
{courseRun.isActive && !canUpgrade && (
|
|
49
|
+
<Banner>
|
|
50
|
+
{formatMessage(messages.upgradeDeadlinePassed)}
|
|
51
|
+
{' '}
|
|
52
|
+
<Hyperlink isInline destination={courseRun.marketingUrl || ''}>
|
|
53
|
+
{formatMessage(messages.exploreCourseDetails)}
|
|
54
|
+
</Hyperlink>
|
|
55
|
+
</Banner>
|
|
56
|
+
)}
|
|
57
|
+
|
|
58
|
+
{(!isStaff && isTooEarly && courseRun.startDate) && (
|
|
59
|
+
<Banner>
|
|
60
|
+
{formatMessage(messages.courseHasNotStarted, {
|
|
61
|
+
startDate: formatDate(courseRun.startDate),
|
|
62
|
+
})}
|
|
63
|
+
</Banner>
|
|
64
|
+
)}
|
|
65
|
+
{(!isStaff && hasUnmetPrerequisites) && (
|
|
66
|
+
<Banner>{formatMessage(messages.prerequisitesNotMet)}</Banner>
|
|
67
|
+
)}
|
|
68
|
+
</>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
CourseBanner.propTypes = {
|
|
73
|
+
cardId: PropTypes.string.isRequired,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export default CourseBanner;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shallow } from '@edx/react-unit-test-utils';
|
|
3
|
+
import { Hyperlink } from '@openedx/paragon';
|
|
4
|
+
|
|
5
|
+
import { useCardCourseRunData, useCardEnrollmentData } from '../data/redux/hooks';
|
|
6
|
+
import { formatMessage } from '../testUtils';
|
|
7
|
+
import CourseBanner from './CourseBanner';
|
|
8
|
+
|
|
9
|
+
import messages from './messages';
|
|
10
|
+
|
|
11
|
+
jest.mock('@openedx/paragon', () => ({
|
|
12
|
+
...jest.requireActual('@openedx/paragon'),
|
|
13
|
+
Hyperlink: () => 'Hyperlink',
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
jest.mock('moment', () => ({
|
|
17
|
+
__esModule: true,
|
|
18
|
+
default: (date) => ({
|
|
19
|
+
toDate: jest.fn().mockReturnValue(date),
|
|
20
|
+
}),
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
jest.mock('./Banner', () => 'Banner');
|
|
24
|
+
jest.mock('../data/redux/hooks', () => ({
|
|
25
|
+
useCardCourseRunData: jest.fn(),
|
|
26
|
+
useCardEnrollmentData: jest.fn(),
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
const cardId = 'my-test-course-number';
|
|
30
|
+
|
|
31
|
+
let el;
|
|
32
|
+
|
|
33
|
+
const enrollmentData = {
|
|
34
|
+
isVerified: false,
|
|
35
|
+
canUpgrade: false,
|
|
36
|
+
isAuditAccessExpired: false,
|
|
37
|
+
coursewareAccess: {
|
|
38
|
+
hasUnmetPrerequisites: false,
|
|
39
|
+
isStaff: false,
|
|
40
|
+
isTooEarly: false,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
const courseRunData = {
|
|
44
|
+
isActive: false,
|
|
45
|
+
startDate: '11/11/3030',
|
|
46
|
+
marketingUrl: 'marketing-url',
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const render = (overrides = {}) => {
|
|
50
|
+
const {
|
|
51
|
+
courseRun = {},
|
|
52
|
+
enrollment = {},
|
|
53
|
+
} = overrides;
|
|
54
|
+
useCardCourseRunData.mockReturnValueOnce({
|
|
55
|
+
...courseRunData,
|
|
56
|
+
...courseRun,
|
|
57
|
+
});
|
|
58
|
+
useCardEnrollmentData.mockReturnValueOnce({
|
|
59
|
+
...enrollmentData,
|
|
60
|
+
...enrollment,
|
|
61
|
+
});
|
|
62
|
+
el = shallow(<CourseBanner cardId={cardId} />);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
describe('CourseBanner', () => {
|
|
66
|
+
test('initializes data with course number from enrollment, course and course run data', () => {
|
|
67
|
+
render();
|
|
68
|
+
expect(useCardCourseRunData).toHaveBeenCalledWith(cardId);
|
|
69
|
+
expect(useCardEnrollmentData).toHaveBeenCalledWith(cardId);
|
|
70
|
+
});
|
|
71
|
+
test('no display if learner is verified', () => {
|
|
72
|
+
render({ enrollment: { isVerified: true } });
|
|
73
|
+
expect(el.isEmptyRender()).toEqual(true);
|
|
74
|
+
});
|
|
75
|
+
describe('audit access expired, can upgrade', () => {
|
|
76
|
+
beforeEach(() => {
|
|
77
|
+
render({ enrollment: { isAuditAccessExpired: true, canUpgrade: true } });
|
|
78
|
+
});
|
|
79
|
+
test('snapshot: (auditAccessExpired, upgradeToAccess)', () => {
|
|
80
|
+
expect(el.snapshot).toMatchSnapshot();
|
|
81
|
+
});
|
|
82
|
+
test('messages: (auditAccessExpired, upgradeToAccess)', () => {
|
|
83
|
+
expect(el.instance.children[0].children[0].el).toContain(messages.auditAccessExpired.defaultMessage);
|
|
84
|
+
expect(el.instance.children[0].children[2].el).toContain(messages.upgradeToAccess.defaultMessage);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
describe('audit access expired, cannot upgrade', () => {
|
|
88
|
+
beforeEach(() => {
|
|
89
|
+
render({ enrollment: { isAuditAccessExpired: true } });
|
|
90
|
+
});
|
|
91
|
+
test('snapshot: (auditAccessExpired, findAnotherCourse hyperlink)', () => {
|
|
92
|
+
expect(el.snapshot).toMatchSnapshot();
|
|
93
|
+
});
|
|
94
|
+
test('messages: (auditAccessExpired, upgradeToAccess)', () => {
|
|
95
|
+
expect(el.instance.children[0].children[0].el).toContain(messages.auditAccessExpired.defaultMessage);
|
|
96
|
+
expect(el.instance.findByType(Hyperlink)[0].children[0].el).toEqual(messages.findAnotherCourse.defaultMessage);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
describe('course run active and cannot upgrade', () => {
|
|
100
|
+
beforeEach(() => {
|
|
101
|
+
render({ courseRun: { isActive: true } });
|
|
102
|
+
});
|
|
103
|
+
test('snapshot: (upgradseDeadlinePassed, exploreCourseDetails hyperlink)', () => {
|
|
104
|
+
expect(el.snapshot).toMatchSnapshot();
|
|
105
|
+
});
|
|
106
|
+
test('messages: (upgradseDeadlinePassed, exploreCourseDetails hyperlink)', () => {
|
|
107
|
+
expect(el.instance.children[0].children[0].el).toContain(messages.upgradeDeadlinePassed.defaultMessage);
|
|
108
|
+
const link = el.instance.findByType(Hyperlink);
|
|
109
|
+
expect(link[0].children[0].el).toEqual(messages.exploreCourseDetails.defaultMessage);
|
|
110
|
+
expect(link[0].props.destination).toEqual(courseRunData.marketingUrl);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
test('no display if audit access not expired and (course is not active or can upgrade)', () => {
|
|
114
|
+
render();
|
|
115
|
+
// isEmptyRender() isn't true because the minimal is <Fragment />
|
|
116
|
+
expect(el.instance.children).toEqual([]);
|
|
117
|
+
render({ enrollment: { canUpgrade: true }, courseRun: { isActive: true } });
|
|
118
|
+
expect(el.instance.children).toEqual([]);
|
|
119
|
+
});
|
|
120
|
+
describe('unmet prerequisites', () => {
|
|
121
|
+
beforeEach(() => {
|
|
122
|
+
render({ enrollment: { coursewareAccess: { hasUnmetPrerequisites: true } } });
|
|
123
|
+
});
|
|
124
|
+
test('snapshot: unmetPrerequisites', () => {
|
|
125
|
+
expect(el.snapshot).toMatchSnapshot();
|
|
126
|
+
});
|
|
127
|
+
test('messages: prerequisitesNotMet', () => {
|
|
128
|
+
expect(el.instance.children[0].children[0].el).toContain(messages.prerequisitesNotMet.defaultMessage);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
describe('too early', () => {
|
|
132
|
+
describe('no start date', () => {
|
|
133
|
+
beforeEach(() => {
|
|
134
|
+
render({ enrollment: { coursewareAccess: { isTooEarly: true } }, courseRun: { startDate: null } });
|
|
135
|
+
});
|
|
136
|
+
test('snapshot', () => expect(el.snapshot).toMatchSnapshot());
|
|
137
|
+
test('messages', () => expect(el.instance.children).toEqual([]));
|
|
138
|
+
});
|
|
139
|
+
describe('has start date', () => {
|
|
140
|
+
beforeEach(() => {
|
|
141
|
+
render({ enrollment: { coursewareAccess: { isTooEarly: true } } });
|
|
142
|
+
});
|
|
143
|
+
test('snapshot', () => expect(el.snapshot).toMatchSnapshot());
|
|
144
|
+
|
|
145
|
+
test('messages: courseHasNotStarted', () => {
|
|
146
|
+
expect(el.instance.children[0].children[0].el).toContain(
|
|
147
|
+
formatMessage(messages.courseHasNotStarted, { startDate: courseRunData.startDate }),
|
|
148
|
+
);
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
describe('staff', () => {
|
|
153
|
+
beforeEach(() => {
|
|
154
|
+
render({ enrollment: { coursewareAccess: { isStaff: true } } });
|
|
155
|
+
});
|
|
156
|
+
test('snapshot: isStaff', () => {
|
|
157
|
+
expect(el.snapshot).toMatchSnapshot();
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
test('snapshot: stacking banners', () => {
|
|
161
|
+
render({
|
|
162
|
+
enrollment: {
|
|
163
|
+
coursewareAccess: {
|
|
164
|
+
isStaff: true,
|
|
165
|
+
isTooEarly: true,
|
|
166
|
+
hasUnmetPrerequisites: true,
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
expect(el.snapshot).toMatchSnapshot();
|
|
171
|
+
});
|
|
172
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Banner snapshot renders default banner 1`] = `
|
|
4
|
+
<Alert
|
|
5
|
+
className="mb-0"
|
|
6
|
+
icon={[Function]}
|
|
7
|
+
variant="info"
|
|
8
|
+
>
|
|
9
|
+
Hello, world!
|
|
10
|
+
</Alert>
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
exports[`Banner snapshot renders with custom class 1`] = `
|
|
14
|
+
<Alert
|
|
15
|
+
className="custom-class"
|
|
16
|
+
icon={[Function]}
|
|
17
|
+
variant="info"
|
|
18
|
+
>
|
|
19
|
+
Hello, world!
|
|
20
|
+
</Alert>
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
exports[`Banner snapshot renders with variants 1`] = `
|
|
24
|
+
<Alert
|
|
25
|
+
className="mb-0"
|
|
26
|
+
icon={[Function]}
|
|
27
|
+
variant="success"
|
|
28
|
+
>
|
|
29
|
+
Hello, world!
|
|
30
|
+
</Alert>
|
|
31
|
+
`;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`CourseBanner audit access expired, can upgrade snapshot: (auditAccessExpired, upgradeToAccess) 1`] = `
|
|
4
|
+
<Fragment>
|
|
5
|
+
<Banner>
|
|
6
|
+
Your audit access to this course has expired.
|
|
7
|
+
|
|
8
|
+
Upgrade now to access your course again.
|
|
9
|
+
</Banner>
|
|
10
|
+
</Fragment>
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
exports[`CourseBanner audit access expired, cannot upgrade snapshot: (auditAccessExpired, findAnotherCourse hyperlink) 1`] = `
|
|
14
|
+
<Fragment>
|
|
15
|
+
<Banner>
|
|
16
|
+
Your audit access to this course has expired.
|
|
17
|
+
|
|
18
|
+
<Hyperlink
|
|
19
|
+
destination=""
|
|
20
|
+
isInline={true}
|
|
21
|
+
>
|
|
22
|
+
Find another course
|
|
23
|
+
</Hyperlink>
|
|
24
|
+
</Banner>
|
|
25
|
+
</Fragment>
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
exports[`CourseBanner course run active and cannot upgrade snapshot: (upgradseDeadlinePassed, exploreCourseDetails hyperlink) 1`] = `
|
|
29
|
+
<Fragment>
|
|
30
|
+
<Banner>
|
|
31
|
+
Your upgrade deadline for this course has passed. To upgrade, enroll in a session that is farther in the future.
|
|
32
|
+
|
|
33
|
+
<Hyperlink
|
|
34
|
+
destination="marketing-url"
|
|
35
|
+
isInline={true}
|
|
36
|
+
>
|
|
37
|
+
Explore course details.
|
|
38
|
+
</Hyperlink>
|
|
39
|
+
</Banner>
|
|
40
|
+
</Fragment>
|
|
41
|
+
`;
|
|
42
|
+
|
|
43
|
+
exports[`CourseBanner snapshot: stacking banners 1`] = `<Fragment />`;
|
|
44
|
+
|
|
45
|
+
exports[`CourseBanner staff snapshot: isStaff 1`] = `<Fragment />`;
|
|
46
|
+
|
|
47
|
+
exports[`CourseBanner too early has start date snapshot 1`] = `
|
|
48
|
+
<Fragment>
|
|
49
|
+
<Banner>
|
|
50
|
+
You can't access this course just yet because the course hasn't started yet. The course will start on 11/11/3030.
|
|
51
|
+
</Banner>
|
|
52
|
+
</Fragment>
|
|
53
|
+
`;
|
|
54
|
+
|
|
55
|
+
exports[`CourseBanner too early no start date snapshot 1`] = `<Fragment />`;
|
|
56
|
+
|
|
57
|
+
exports[`CourseBanner unmet prerequisites snapshot: unmetPrerequisites 1`] = `
|
|
58
|
+
<Fragment>
|
|
59
|
+
<Banner>
|
|
60
|
+
You can't access this course just yet because you have not met the pre-requisites.
|
|
61
|
+
</Banner>
|
|
62
|
+
</Fragment>
|
|
63
|
+
`;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
import { useIntl } from '@edx/frontend-platform/i18n';
|
|
3
|
+
|
|
4
|
+
export const dateFormatter = (formatDate, date) => formatDate(moment(date).toDate(), {
|
|
5
|
+
year: 'numeric',
|
|
6
|
+
month: 'long',
|
|
7
|
+
day: 'numeric',
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
// Hook
|
|
11
|
+
export const useFormatDate = () => {
|
|
12
|
+
const { formatDate } = useIntl();
|
|
13
|
+
return (date) => dateFormatter(formatDate, date);
|
|
14
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Provider } from 'react-redux';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import CourseBanner from './CourseBanner';
|
|
5
|
+
|
|
6
|
+
const CourseBannerWithProvider = ({ content, cardId }) => {
|
|
7
|
+
const { store } = content;
|
|
8
|
+
return (
|
|
9
|
+
<Provider store={store}>
|
|
10
|
+
<CourseBanner cardId={cardId} />
|
|
11
|
+
</Provider>
|
|
12
|
+
);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
CourseBannerWithProvider.propTypes = {
|
|
16
|
+
content: PropTypes.shape({
|
|
17
|
+
store: PropTypes.shape({}),
|
|
18
|
+
}),
|
|
19
|
+
cardId: PropTypes.string.isRequired,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default CourseBannerWithProvider;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { defineMessages } from '@edx/frontend-platform/i18n';
|
|
2
|
+
|
|
3
|
+
const messages = defineMessages({
|
|
4
|
+
auditAccessExpired: {
|
|
5
|
+
id: 'learner-dash.courseCard.banners.auditAccessExpired',
|
|
6
|
+
description: 'Audit access expiration banner message',
|
|
7
|
+
defaultMessage: 'Your audit access to this course has expired.',
|
|
8
|
+
},
|
|
9
|
+
upgradeToAccess: {
|
|
10
|
+
id: 'learner-dash.courseCard.banners.upgradeToAccess',
|
|
11
|
+
description: 'Upgrade prompt for audit-expired learners that can still upgrade',
|
|
12
|
+
defaultMessage: 'Upgrade now to access your course again.',
|
|
13
|
+
},
|
|
14
|
+
findAnotherCourse: {
|
|
15
|
+
id: 'learner-dash.courseCard.banners.findAnotherCourse',
|
|
16
|
+
description: 'Action prompt taking learners to course exploration',
|
|
17
|
+
defaultMessage: 'Find another course',
|
|
18
|
+
},
|
|
19
|
+
upgradeDeadlinePassed: {
|
|
20
|
+
id: 'learner-dash.courseCard.banners.upgradeDeadlinePassed',
|
|
21
|
+
description: 'Audit upgrade deadline passed banner message',
|
|
22
|
+
defaultMessage: 'Your upgrade deadline for this course has passed. To upgrade, enroll in a session that is farther in the future.',
|
|
23
|
+
},
|
|
24
|
+
exploreCourseDetails: {
|
|
25
|
+
id: 'learner-dash.courseCard.banners.exploreCourseDetails',
|
|
26
|
+
description: 'Action prompt taking learners to course details page',
|
|
27
|
+
defaultMessage: 'Explore course details.',
|
|
28
|
+
},
|
|
29
|
+
prerequisitesNotMet: {
|
|
30
|
+
id: 'learner-dash.courseCard.banners.prerequisitesNotMet',
|
|
31
|
+
description: 'Message to learners with unmet prerequisites',
|
|
32
|
+
defaultMessage: 'You can\'t access this course just yet because you have not met the pre-requisites.',
|
|
33
|
+
},
|
|
34
|
+
courseHasNotStarted: {
|
|
35
|
+
id: 'learner-dash.courseCard.banners.courseHasNotStarted',
|
|
36
|
+
description: 'Course has not started message',
|
|
37
|
+
defaultMessage: 'You can\'t access this course just yet because the course hasn\'t started yet. The course will start on {startDate}.',
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export default messages;
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
import { EXECUTIVE_EDUCATION_COURSE_MODES } from '../constants';
|
|
4
4
|
import { cardSimpleSelectors, mkCardSelector } from './simpleSelectors';
|
|
5
5
|
|
|
6
|
+
const loadDateVal = (date) => (date ? new Date(date) : null);
|
|
7
|
+
|
|
6
8
|
export const courseCard = {
|
|
7
9
|
course: mkCardSelector(
|
|
8
10
|
cardSimpleSelectors.course,
|
|
@@ -13,6 +15,7 @@ export const courseCard = {
|
|
|
13
15
|
courseRun: mkCardSelector(
|
|
14
16
|
cardSimpleSelectors.courseRun,
|
|
15
17
|
(courseRun) => (courseRun === null ? {} : {
|
|
18
|
+
startDate: loadDateVal(courseRun.startDate),
|
|
16
19
|
upgradeUrl: courseRun.upgradeUrl,
|
|
17
20
|
courseId: courseRun.courseId,
|
|
18
21
|
}),
|
|
@@ -35,7 +38,10 @@ export const courseCard = {
|
|
|
35
38
|
return { isEnrolled: false };
|
|
36
39
|
}
|
|
37
40
|
return {
|
|
41
|
+
coursewareAccess: enrollment.coursewareAccess,
|
|
38
42
|
isEnrolled: enrollment.isEnrolled,
|
|
43
|
+
|
|
44
|
+
isAuditAccessExpired: enrollment.isAuditAccessExpired,
|
|
39
45
|
isVerified: enrollment.isVerified,
|
|
40
46
|
isExecEd2UCourse: EXECUTIVE_EDUCATION_COURSE_MODES.includes(enrollment.mode),
|
|
41
47
|
canUpgrade: enrollment.canUpgrade,
|
|
@@ -32,6 +32,7 @@ describe('courseCard selectors module', () => {
|
|
|
32
32
|
describe('courseRun selector', () => {
|
|
33
33
|
beforeEach(() => {
|
|
34
34
|
loadSelector(courseCard.courseRun, {
|
|
35
|
+
startDate: '2000-10-20',
|
|
35
36
|
upgradeUrl: 'test-upgrade-url',
|
|
36
37
|
courseId: 'test-course-id',
|
|
37
38
|
});
|
|
@@ -42,6 +43,9 @@ describe('courseCard selectors module', () => {
|
|
|
42
43
|
it('returns {} object if null courseRun received', () => {
|
|
43
44
|
expect(selector(null)).toEqual({});
|
|
44
45
|
});
|
|
46
|
+
it('passes startDate converted to date', () => {
|
|
47
|
+
expect(selected.startDate).toEqual(new Date(testData.startDate));
|
|
48
|
+
});
|
|
45
49
|
it('passes upgradeUrl', () => {
|
|
46
50
|
expect(selected.upgradeUrl).toEqual(testData.upgradeUrl);
|
|
47
51
|
});
|
|
@@ -51,6 +55,12 @@ describe('courseCard selectors module', () => {
|
|
|
51
55
|
});
|
|
52
56
|
describe('enrollment selector', () => {
|
|
53
57
|
const defaultData = {
|
|
58
|
+
coursewareAccess: {
|
|
59
|
+
isStaff: false,
|
|
60
|
+
hasUnmetPrereqs: false,
|
|
61
|
+
isTooEarly: false,
|
|
62
|
+
},
|
|
63
|
+
isAuditAccessExpired: 'test-is-audit-access-expired',
|
|
54
64
|
isEnrolled: 'test-is-enrolled',
|
|
55
65
|
isVerified: 'test-is-verified',
|
|
56
66
|
mode: 'default',
|
|
@@ -65,6 +75,9 @@ describe('courseCard selectors module', () => {
|
|
|
65
75
|
it('returns { isEnrolled: false } object if null enrollment received', () => {
|
|
66
76
|
expect(selector(null)).toEqual({ isEnrolled: false });
|
|
67
77
|
});
|
|
78
|
+
it('passes coursewareAccess', () => {
|
|
79
|
+
expect(selected.coursewareAccess).toEqual(testData.coursewareAccess);
|
|
80
|
+
});
|
|
68
81
|
it('passes isEnrolled', () => {
|
|
69
82
|
expect(selected.isEnrolled).toEqual(testData.isEnrolled);
|
|
70
83
|
});
|
|
@@ -74,6 +87,9 @@ describe('courseCard selectors module', () => {
|
|
|
74
87
|
it('passes canUpgrade', () => {
|
|
75
88
|
expect(selected.canUpgrade).toEqual(testData.canUpgrade);
|
|
76
89
|
});
|
|
90
|
+
it('passes isAuditAccessExpired', () => {
|
|
91
|
+
expect(selected.isAuditAccessExpired).toEqual(testData.isAuditAccessExpired);
|
|
92
|
+
});
|
|
77
93
|
it('returns isExecEd2UCourse: false if mode is not in EXECUTIVE_EDUCATION_COURSE_MODES', () => {
|
|
78
94
|
expect(selected.isExecEd2UCourse).toEqual(false);
|
|
79
95
|
});
|
package/src/index.jsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import CohesionWrapper from './cohesion-wrapper/index';
|
|
2
|
+
import CourseBanner from './course-banner';
|
|
2
3
|
import EnterpriseDashboardModal from './dashboard-modal/index';
|
|
3
4
|
import HelpChatbot from './chatbot/index';
|
|
4
5
|
import UpgradeButton from './upgrade-button';
|
|
@@ -6,5 +7,11 @@ import UserCareerMenu from './career-menu/index';
|
|
|
6
7
|
import UserDashboardMenu from './dashboard-menu/index';
|
|
7
8
|
|
|
8
9
|
export {
|
|
9
|
-
CohesionWrapper,
|
|
10
|
+
CohesionWrapper,
|
|
11
|
+
CourseBanner,
|
|
12
|
+
EnterpriseDashboardModal,
|
|
13
|
+
HelpChatbot,
|
|
14
|
+
UpgradeButton,
|
|
15
|
+
UserCareerMenu,
|
|
16
|
+
UserDashboardMenu,
|
|
10
17
|
};
|
package/src/setupTest.js
CHANGED
|
@@ -16,27 +16,17 @@ jest.mock('@src/generic/messages', () => jest.fn(() => { }), { virtual: true });
|
|
|
16
16
|
|
|
17
17
|
// Mock the `formatMessage` utility from i18n
|
|
18
18
|
// For working with shallow renders in tests via @edx/react-unit-test-utils
|
|
19
|
-
jest.mock('@edx/frontend-platform/i18n', () =>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return <format-message-function {...{ message: msg, values }} />;
|
|
31
|
-
}
|
|
32
|
-
Object.keys(values).forEach((key) => {
|
|
33
|
-
// eslint-disable-next-line
|
|
34
|
-
message = message.replaceAll(`{${key}}`, values[key]);
|
|
35
|
-
});
|
|
36
|
-
return message;
|
|
37
|
-
},
|
|
38
|
-
}),
|
|
39
|
-
}));
|
|
19
|
+
jest.mock('@edx/frontend-platform/i18n', () => {
|
|
20
|
+
const { formatMessage } = jest.requireActual('./testUtils');
|
|
21
|
+
const formatDate = jest.fn(date => new Date(date).toLocaleDateString()).mockName('useIntl.formatDate');
|
|
22
|
+
return {
|
|
23
|
+
...jest.requireActual('@edx/frontend-platform/i18n'),
|
|
24
|
+
useIntl: () => ({
|
|
25
|
+
formatMessage,
|
|
26
|
+
formatDate,
|
|
27
|
+
}),
|
|
28
|
+
};
|
|
29
|
+
});
|
|
40
30
|
|
|
41
31
|
/* eslint-disable no-console */
|
|
42
32
|
const supressWarningBlock = (callback) => {
|
package/src/testUtils.js
CHANGED
|
@@ -82,3 +82,23 @@ export class MockUseState {
|
|
|
82
82
|
return { ...this.hooks.state };
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Mocked formatMessage provided by react-intl
|
|
88
|
+
*/
|
|
89
|
+
export const formatMessage = (msg, values) => {
|
|
90
|
+
let message = msg.defaultMessage;
|
|
91
|
+
if (values === undefined) {
|
|
92
|
+
return message;
|
|
93
|
+
}
|
|
94
|
+
// check if value is not a primitive type.
|
|
95
|
+
if (Object.values(values).filter(value => Object(value) === value).length) {
|
|
96
|
+
// eslint-disable-next-line react/jsx-filename-extension
|
|
97
|
+
return <format-message-function {...{ message: msg, values }} />;
|
|
98
|
+
}
|
|
99
|
+
Object.keys(values).forEach((key) => {
|
|
100
|
+
// eslint-disable-next-line
|
|
101
|
+
message = message.replaceAll(`{${key}}`, values[key]);
|
|
102
|
+
});
|
|
103
|
+
return message;
|
|
104
|
+
};
|