Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -176,17 +176,23 @@ describe.each([

test.each([
{
course: pastDashboardCourse(),
course: pastDashboardCourse({
enrollment: { status: EnrollmentStatus.Enrolled },
}),
expected: { labelPrefix: "View" },
case: "past",
},
{
course: currentDashboardCourse(),
course: currentDashboardCourse({
enrollment: { status: EnrollmentStatus.Enrolled },
}),
expected: { labelPrefix: "Continue" },
case: "current",
},
{
course: futureDashboardCourse(),
course: futureDashboardCourse({
enrollment: { status: EnrollmentStatus.Enrolled },
}),
expected: { labelPrefix: "Continue" },
label: "future",
},
Expand Down Expand Up @@ -515,12 +521,12 @@ describe.each([
)

test.each([
{ status: EnrollmentStatus.Completed },
{ status: EnrollmentStatus.Enrolled },
{ status: EnrollmentStatus.NotEnrolled },
{ status: EnrollmentStatus.Completed, expectedText: "View Course" },
{ status: EnrollmentStatus.Enrolled, expectedText: "Continue Course" },
{ status: EnrollmentStatus.NotEnrolled, expectedText: "Start Course" },
])(
"CoursewareButton switches to Enroll functionality when enrollment status is not enrolled or undefined",
({ status }) => {
"CoursewareButton shows correct text based on enrollment status ($status)",
({ status, expectedText }) => {
setupUserApis()
const course = dashboardCourse()
course.enrollment = {
Expand All @@ -534,15 +540,7 @@ describe.each([
const card = getCard()
const coursewareButton = within(card).getByTestId("courseware-button")

if (
status === EnrollmentStatus.NotEnrolled ||
status === undefined ||
!course.enrollment
) {
expect(coursewareButton).toHaveTextContent("Start Course")
} else {
expect(coursewareButton).toHaveTextContent("Continue Course")
}
expect(coursewareButton).toHaveTextContent(expectedText)
},
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,10 @@ const getCoursewareText = ({
if (!enrollmentStatus || enrollmentStatus === EnrollmentStatus.NotEnrolled) {
return `Start ${courseNoun}`
}
if (!endDate) return `Continue ${courseNoun}`
if (isInPast(endDate)) {
if (
(endDate && isInPast(endDate)) ||
enrollmentStatus === EnrollmentStatus.Completed
) {
return `View ${courseNoun}`
}
return `Continue ${courseNoun}`
Expand Down
Loading