Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const CourseEnrollments = ({ enrollments, isLoading }) => {
description: 'Message displayed when a learner has no course enrollments',
});

const enrollmentTypes = ['assignmentsForDisplay', 'inProgress', 'upcoming', 'completed'];
const enrollmentTypes = ['assignmentsForDisplay', 'inProgress', 'upcoming', 'savedForLater', 'completed'];
const flattenedEnrollments = enrollmentTypes.flatMap(type => enrollments?.[type] || []);
const hasEnrollments = flattenedEnrollments.length > 0;

Expand Down Expand Up @@ -60,6 +60,7 @@ CourseEnrollments.propTypes = {
completed: PropTypes.arrayOf(enrollmentShape),
inProgress: PropTypes.arrayOf(enrollmentShape),
upcoming: PropTypes.arrayOf(enrollmentShape),
savedForLater: PropTypes.arrayOf(enrollmentShape),
assignmentsForDisplay: PropTypes.arrayOf(enrollmentShape),
}).isRequired,
isLoading: PropTypes.bool.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
case 'upcoming': {
return (<Badge variant="info">Upcoming</Badge>);
}
case 'saved_for_later': {
return (<Badge variant="dark">Saved for later</Badge>);

Check warning on line 27 in src/components/PeopleManagement/LearnerDetailPage/EnrollmentCard.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/PeopleManagement/LearnerDetailPage/EnrollmentCard.jsx#L26-L27

Added lines #L26 - L27 were not covered by tests
}
default: {
return (<Badge variant="info">Assigned</Badge>);
}
Expand Down
23 changes: 19 additions & 4 deletions src/components/PeopleManagement/tests/CourseEnrollments.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ const mockEnrollments = {
courseRunStatus: 'completed',
},
],
savedForLater: [
{
uuid: '5',
courseKey: 'course-5',
displayName: 'Course 5',
courseRunStatus: 'saved_for_later',
},
],
assignmentsForDisplay: [
{
uuid: '4',
Expand Down Expand Up @@ -84,31 +92,38 @@ describe('CourseEnrollments', () => {
it('renders in-progress enrollments', () => {
renderComponent({ enrollments: mockEnrollments, isLoading: false });
const enrollmentCards = screen.getAllByTestId('enrollment-card');
expect(enrollmentCards).toHaveLength(4);
expect(enrollmentCards).toHaveLength(5);
expect(screen.getByText('Course 1')).toBeInTheDocument();
});

it('renders upcoming enrollments', () => {
renderComponent({ enrollments: mockEnrollments, isLoading: false });
const enrollmentCards = screen.getAllByTestId('enrollment-card');
expect(enrollmentCards).toHaveLength(4);
expect(enrollmentCards).toHaveLength(5);
expect(screen.getByText('Course 2')).toBeInTheDocument();
});

it('renders completed enrollments', () => {
renderComponent({ enrollments: mockEnrollments, isLoading: false });
const enrollmentCards = screen.getAllByTestId('enrollment-card');
expect(enrollmentCards).toHaveLength(4);
expect(enrollmentCards).toHaveLength(5);
expect(screen.getByText('Course 3')).toBeInTheDocument();
});

it('renders assigned enrollments', () => {
renderComponent({ enrollments: mockEnrollments, isLoading: false });
const enrollmentCards = screen.getAllByTestId('enrollment-card');
expect(enrollmentCards).toHaveLength(4);
expect(enrollmentCards).toHaveLength(5);
expect(screen.getByText('Course 4')).toBeInTheDocument();
});

it('renders saved for later enrollments', () => {
renderComponent({ enrollments: mockEnrollments, isLoading: false });
const enrollmentCards = screen.getAllByTestId('enrollment-card');
expect(enrollmentCards).toHaveLength(5);
expect(screen.getByText('Course 5')).toBeInTheDocument();
});

it('renders enrollments header', () => {
renderComponent({ enrollments: mockEnrollments, isLoading: false });
expect(screen.getByText('Enrollments')).toBeInTheDocument();
Expand Down