AA-814: course grade footer fix (#455)

This commit is contained in:
Carla Duarte
2021-05-19 13:44:28 -04:00
committed by GitHub
parent 58e29d81be
commit 663bf7562b
5 changed files with 13 additions and 11 deletions

View File

@@ -281,13 +281,13 @@ describe('Outline Tab', () => {
],
});
await fetchAndRender();
expect(screen.getByRole('heading', { name: 'Upcoming Dates' })).toBeInTheDocument();
expect(screen.getByRole('heading', { name: 'Important dates' })).toBeInTheDocument();
});
it('does not render when course date blocks are not populated', async () => {
setMetadata({ is_enrolled: true });
await fetchAndRender();
expect(screen.queryByRole('heading', { name: 'Upcoming Dates' })).not.toBeInTheDocument();
expect(screen.queryByRole('heading', { name: 'Important dates' })).not.toBeInTheDocument();
});
it('sends analytics event onClick of upgrade link', async () => {

View File

@@ -22,7 +22,7 @@ const messages = defineMessages({
},
dates: {
id: 'learning.outline.dates',
defaultMessage: 'Upcoming Dates',
defaultMessage: 'Important dates',
},
editGoal: {
id: 'learning.outline.editGoal',

View File

@@ -40,15 +40,17 @@ function CourseGradeFooter({ intl, passingGrade }) {
if (isPassing) {
if (hasLetterGrades) {
const letterGrades = Object.keys(gradeRange);
const gradeIndex = letterGrades.indexOf(letterGrade);
const minGrade = gradeRange[letterGrade] * 100;
const maxGrade = gradeIndex > 0 ? gradeRange[letterGrades[gradeIndex - 1]] * 100 : 100;
const minGradeRangeCutoff = gradeRange[letterGrade] * 100;
const possibleMaxGradeRangeValues = [...Object.values(gradeRange).filter(
(grade) => (grade * 100 > minGradeRangeCutoff),
)];
const maxGradeRangeCutoff = possibleMaxGradeRangeValues.length ? Math.min(...possibleMaxGradeRangeValues) * 100
: 100;
footerText = intl.formatMessage(messages.courseGradeFooterPassingWithGrade, {
letterGrade,
minGrade: minGrade.toFixed(0),
maxGrade: maxGrade.toFixed(0),
minGrade: minGradeRangeCutoff.toFixed(0),
maxGrade: maxGradeRangeCutoff.toFixed(0),
});
} else {
footerText = intl.formatMessage(messages.courseGradeFooterGenericPassing);

View File

@@ -21,7 +21,7 @@ function CurrentGradeTooltip({ intl, tooltipClassName }) {
},
} = useModel('progress', courseId);
const currentGrade = percent * 100;
const currentGrade = Number((percent * 100).toFixed(0));
return (
<>

View File

@@ -24,7 +24,7 @@ function GradeBar({ intl, passingGrade }) {
},
} = useModel('progress', courseId);
const currentGrade = percent * 100;
const currentGrade = Number((percent * 100).toFixed(0));
const isLocked = lockedCount > 0;
const lockedTooltipClassName = isLocked ? 'locked-overlay' : '';