@@ -61,23 +61,12 @@ export const CertificateBanner = ({ cardId }) => {
|
||||
);
|
||||
}
|
||||
if (certificate.isDownloadable) {
|
||||
if (certificate.certPreviewUrl) {
|
||||
return (
|
||||
<Banner variant="success" icon={CheckCircle}>
|
||||
{formatMessage(messages.certReady)}
|
||||
{' '}
|
||||
<Hyperlink destination={certificate.certPreviewUrl}>
|
||||
{formatMessage(messages.viewCertificate)}
|
||||
</Hyperlink>
|
||||
</Banner>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Banner variant="success" icon={CheckCircle}>
|
||||
{formatMessage(messages.certReady)}
|
||||
{' '}
|
||||
<Hyperlink destination={certificate.certDownloadUrl}>
|
||||
{formatMessage(messages.downloadCertificate)}
|
||||
<Hyperlink destination={certificate.certPreviewUrl}>
|
||||
{formatMessage(messages.viewCertificate)}
|
||||
</Hyperlink>
|
||||
</Banner>
|
||||
);
|
||||
|
||||
@@ -8,6 +8,9 @@ export const useAccessMessage = ({ cardId }) => {
|
||||
const { formatMessage, formatDate } = useIntl();
|
||||
const enrollment = appHooks.useCardEnrollmentData(cardId);
|
||||
const courseRun = appHooks.useCardCourseRunData(cardId);
|
||||
if (!courseRun.isStarted) {
|
||||
return formatMessage(messages.courseStarts, { startDate: courseRun.startDate });
|
||||
}
|
||||
if (enrollment.isEnrolled) {
|
||||
if (enrollment.isAudit) {
|
||||
const {
|
||||
|
||||
@@ -80,8 +80,10 @@ describe('CourseCardDetails hooks', () => {
|
||||
isAuditAccessExpired: false,
|
||||
};
|
||||
const courseRunData = {
|
||||
isStarted: true,
|
||||
isFinished: false,
|
||||
endDate: '10/20/1000',
|
||||
startDate: '10/10/1000',
|
||||
endDate: '10/20/2000',
|
||||
};
|
||||
const runHook = ({ enrollment = {}, courseRun = {} }) => {
|
||||
appHooks.useCardCourseRunData.mockReturnValueOnce({
|
||||
@@ -101,6 +103,19 @@ describe('CourseCardDetails hooks', () => {
|
||||
expect(appHooks.useCardEnrollmentData).toHaveBeenCalledWith(cardId);
|
||||
});
|
||||
|
||||
describe('if not started yet', () => {
|
||||
it('returns accessExpired message with accessExpirationDate from cardData', () => {
|
||||
runHook({
|
||||
enrollment: { isAudit: true, isAuditAccessExpired: true },
|
||||
courseRun: { isStarted: false },
|
||||
});
|
||||
expect(out).toEqual(formatMessage(
|
||||
messages.courseStarts,
|
||||
{ startDate: dateFormatter(formatDate, courseRunData.startDate) },
|
||||
));
|
||||
});
|
||||
});
|
||||
|
||||
describe('if audit, and expired', () => {
|
||||
it('returns accessExpired message with accessExpirationDate from cardData', () => {
|
||||
runHook({ enrollment: { isAudit: true, isAuditAccessExpired: true } });
|
||||
|
||||
@@ -21,6 +21,11 @@ export const messages = StrictDict({
|
||||
description: 'Course ending message on course card.',
|
||||
defaultMessage: 'Course ends {endDate}',
|
||||
},
|
||||
courseStarts: {
|
||||
id: 'learner-dash.courseCard.CourseCardDetails.courseStarts',
|
||||
description: 'Course start date message on course card.',
|
||||
defaultMessage: 'Course starts {startDate}',
|
||||
},
|
||||
unknownProviderName: {
|
||||
id: 'learner-dash.courseCard.CourseCardDetails.unknownProviderName',
|
||||
description: 'Provider name display when name is unknown',
|
||||
|
||||
@@ -21,10 +21,6 @@ export const ProgramCard = ({ data }) => {
|
||||
messages.courses,
|
||||
{ numCourses: data.numberOfCourses },
|
||||
);
|
||||
const durationMessage = formatMessage(
|
||||
messages.duration,
|
||||
{ numWeeks: data.estimatedNumberOfWeeks },
|
||||
);
|
||||
return (
|
||||
<Card
|
||||
className="program-card d-inline-block bg-primary-500 text-white pb-3.5"
|
||||
@@ -46,7 +42,7 @@ export const ProgramCard = ({ data }) => {
|
||||
<Icon src={Program} className="d-inline-block" /> {data.programType}
|
||||
</Badge>
|
||||
<div className="program-summary mt-2">
|
||||
{numCoursesMessage} • {durationMessage}
|
||||
{numCoursesMessage}
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
@@ -55,7 +51,6 @@ export const ProgramCard = ({ data }) => {
|
||||
ProgramCard.propTypes = {
|
||||
data: PropTypes.shape({
|
||||
bannerUrl: PropTypes.string,
|
||||
estimatedNumberOfWeeks: PropTypes.number,
|
||||
logoUrl: PropTypes.string,
|
||||
numberOfCourses: PropTypes.number,
|
||||
programType: PropTypes.string,
|
||||
|
||||
@@ -5,7 +5,6 @@ import ProgramCard from './ProgramCard';
|
||||
|
||||
const props = {
|
||||
data: {
|
||||
estimatedNumberOfWeeks: 1,
|
||||
numberOfCourses: 2,
|
||||
bannerUrl: 'props.data.bannerUrl',
|
||||
logoUrl: 'props.data.logoUrl',
|
||||
|
||||
@@ -50,8 +50,6 @@ exports[`RelatedProgramsModal ProgramCard snapshot 1`] = `
|
||||
className="program-summary mt-2"
|
||||
>
|
||||
2 Courses
|
||||
•
|
||||
1 Weeks
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
@@ -48,8 +48,6 @@ dateSixMonthsFromNow.setDate(dateSixMonthsFromNow.getDate() + 180);
|
||||
export const courseCard = StrictDict({
|
||||
certificates: mkCardSelector(({ certificates }) => ({
|
||||
availableDate: certificates.availableDate,
|
||||
certDownloadUrl: certificates.certDownloadUrl,
|
||||
honorCertDownloadUrl: certificates.honorCertDownloadUrl,
|
||||
certPreviewUrl: certificates.certPreviewUrl,
|
||||
isDownloadable: certificates.isDownloadable,
|
||||
isEarnedButUnavailable: certificates.isEarned && !certificates.isAvailable,
|
||||
@@ -68,6 +66,7 @@ export const courseCard = StrictDict({
|
||||
isStarted: courseRun.isStarted,
|
||||
isFinished: courseRun.isFinished,
|
||||
minPassingGrade: courseRun.minPassingGrade,
|
||||
startDate: courseRun.startDate,
|
||||
})),
|
||||
enrollment: mkCardSelector(({ enrollment }) => {
|
||||
if (enrollment == null) {
|
||||
@@ -111,7 +110,6 @@ export const courseCard = StrictDict({
|
||||
relatedPrograms: mkCardSelector(({ relatedPrograms }) => ({
|
||||
list: relatedPrograms.map(program => ({
|
||||
bannerUrl: program.bannerUrl,
|
||||
estimatedNumberOfWeeks: program.estimatedNumberOfWeeks,
|
||||
logoUrl: program.logoUrl,
|
||||
numberOfCourses: program.numberOfCourses,
|
||||
programType: program.programType,
|
||||
|
||||
@@ -1,26 +1,9 @@
|
||||
import fakeData from 'data/services/lms/fakeData/courses';
|
||||
/*
|
||||
import { StrictDict } from 'utils';
|
||||
import { locationId } from 'data/constants/app';
|
||||
import { paramKeys } from './constants';
|
||||
import { get } from './utils';
|
||||
import urls from './urls';
|
||||
import {
|
||||
client,
|
||||
get,
|
||||
post,
|
||||
stringifyUrl,
|
||||
} from './utils';
|
||||
*/
|
||||
|
||||
/*********************************************************************************
|
||||
* GET Actions
|
||||
*********************************************************************************/
|
||||
const initializeList = () => Promise.resolve({
|
||||
courses: [
|
||||
...fakeData.courseRunData,
|
||||
...fakeData.entitlementData,
|
||||
],
|
||||
...fakeData.globalData,
|
||||
});
|
||||
const initializeList = () => get(urls.init).then(({ data }) => data);
|
||||
|
||||
export default { initializeList };
|
||||
|
||||
@@ -22,7 +22,6 @@ export const relatedPrograms = [
|
||||
programUrl: 'www.edx/my-program',
|
||||
programType: 'MicroBachelors Program',
|
||||
numberOfCourses: 3,
|
||||
estimatedNumberOfWeeks: 4,
|
||||
},
|
||||
{
|
||||
provider: 'University of Maryland',
|
||||
@@ -33,7 +32,6 @@ export const relatedPrograms = [
|
||||
programType: 'MicroBachelors Program',
|
||||
programTypeUrl: 'www.edx/my-program-type',
|
||||
numberOfCourses: 3,
|
||||
estimatedNumberOfWeeks: 4,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -48,8 +46,10 @@ const logos = {
|
||||
science: 'https://courses.edx.org/asset-v1:HarvardX+PH525.5x+3T2020+type@thumbnail+block@course_image-375x200.jpg',
|
||||
};
|
||||
|
||||
const farPastDate = '11/11/1900';
|
||||
const pastDate = '11/11/2000';
|
||||
const futureDate = '11/11/3030';
|
||||
const farFutureDate = '11/11/4040';
|
||||
const soonDate = new Date();
|
||||
soonDate.setDate(soonDate.getDate() + 60);
|
||||
const soonDateStr = soonDate.toDateString();
|
||||
@@ -102,7 +102,8 @@ const globalData = {
|
||||
export const genCourseRunData = (data = {}) => ({
|
||||
isStarted: false,
|
||||
isArchived: false,
|
||||
endDate: futureDate,
|
||||
startDate: data.isStarted ? farPastDate : futureDate,
|
||||
endDate: farFutureDate,
|
||||
minPassingGrade: 70,
|
||||
homeUrl: 'edx.com/courses/my-course-url/home',
|
||||
marketingUrl: 'edx.com/courses/my-course-url/marketing',
|
||||
@@ -319,7 +320,6 @@ export const courseRuns = [
|
||||
isAvailable: true,
|
||||
isDownloadable: true,
|
||||
availableDate: pastDate,
|
||||
certDownloadUrl: logos.social,
|
||||
certPreviewUrl: logos.edx,
|
||||
},
|
||||
},
|
||||
@@ -339,7 +339,6 @@ export const courseRuns = [
|
||||
isAvailable: true,
|
||||
isDownloadable: true,
|
||||
availableDate: pastDate,
|
||||
certDownloadUrl: logos.social,
|
||||
},
|
||||
},
|
||||
// verified, course archived, learner finished, cert earned, downloadable (web + link)
|
||||
@@ -359,7 +358,6 @@ export const courseRuns = [
|
||||
isAvailable: true,
|
||||
isDownloadable: true,
|
||||
availableDate: pastDate,
|
||||
certDownloadUrl: logos.social,
|
||||
certPreviewUrl: logos.edx,
|
||||
},
|
||||
},
|
||||
@@ -471,7 +469,6 @@ export const courseRuns = [
|
||||
isAvailable: true,
|
||||
isDownloadable: true,
|
||||
availableDate: pastDate,
|
||||
certDownloadUrl: logos.social,
|
||||
certPreviewUrl: logos.edx,
|
||||
},
|
||||
},
|
||||
@@ -523,7 +520,6 @@ export const courseRuns = [
|
||||
isAvailable: true,
|
||||
isDownloadable: true,
|
||||
availableDate: pastDate,
|
||||
certDownloadUrl: logos.social,
|
||||
certPreviewUrl: logos.edx,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -4,7 +4,9 @@ import { configuration } from 'config';
|
||||
const baseUrl = `${configuration.LMS_BASE_URL}`;
|
||||
|
||||
const api = `${baseUrl}/api/`;
|
||||
const init = `${api}/learner_home/mock/init`;
|
||||
|
||||
export default StrictDict({
|
||||
api,
|
||||
init,
|
||||
});
|
||||
|
||||
@@ -155,8 +155,8 @@ describe('ESG app integration tests', () => {
|
||||
[
|
||||
courseData.provider.name,
|
||||
courseData.course.courseNumber,
|
||||
appMessages.withValues.CourseCardDetails.accessExpires({
|
||||
accessExpirationDate: courseData.enrollment.accessExpirationDate,
|
||||
appMessages.withValues.CourseCardDetails.courseStarts({
|
||||
startDate: courseData.courseRun.startDate,
|
||||
}),
|
||||
].forEach(value => inspector.verifyTextIncludes(cardDetails, value));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user