diff --git a/frontend/public/src/components/EnrolledItemCard.js b/frontend/public/src/components/EnrolledItemCard.js
index 59b0b6caa9..b1401129ac 100644
--- a/frontend/public/src/components/EnrolledItemCard.js
+++ b/frontend/public/src/components/EnrolledItemCard.js
@@ -438,12 +438,14 @@ export class EnrolledItemCard extends React.Component<
Upgrade today and, upon passing, receive your
certificate signed by MIT faculty to highlight the knowledge and
skills you've gained from this MITx course.{" "}
-
- Upgrade expires:{" "}
- {formatPrettyDateTimeAmPmTz(
- parseDateString(enrollment.run.upgrade_deadline)
- )}
-
+ {enrollment.run.upgrade_deadline ? (
+
+ Upgrade expires:{" "}
+ {formatPrettyDateTimeAmPmTz(
+ parseDateString(enrollment.run.upgrade_deadline)
+ )}
+
+ ) : null}
) : null
diff --git a/frontend/public/src/components/EnrolledItemCard_test.js b/frontend/public/src/components/EnrolledItemCard_test.js
index 6328d92b8d..6007db4f1c 100644
--- a/frontend/public/src/components/EnrolledItemCard_test.js
+++ b/frontend/public/src/components/EnrolledItemCard_test.js
@@ -253,4 +253,46 @@ describe("EnrolledItemCard", () => {
const modals = inner.find(`#${modalId}`)
assert.lengthOf(modals, 1)
})
+ ;["audit", "verified", "program"].forEach(mode => {
+ it(`renders the card for enrollment mode ${mode}`, async () => {
+ const testEnrollment =
+ mode === "program" ?
+ makeProgramEnrollment() :
+ makeCourseRunEnrollmentWithProduct()
+ userEnrollment = testEnrollment
+ enrollmentCardProps.enrollment = testEnrollment
+ const inner = await renderedCard()
+ const enrolledItems = inner.find(".enrolled-item")
+ assert.lengthOf(enrolledItems, 1)
+ const enrolledItem = enrolledItems.at(0)
+ if (mode !== "program") {
+ assert.equal(
+ enrolledItem.find("h2").text(),
+ userEnrollment.run.course.title
+ )
+ if (mode === "verified") {
+ const pricingLinks = inner.find(".pricing-links")
+ assert.isFalse(pricingLinks.exists())
+ }
+ } else {
+ assert.equal(
+ enrolledItem.find("h2").text(),
+ testEnrollment.program.title
+ )
+ }
+ })
+ })
+ it("Test", async () => {
+ const testEnrollment = makeCourseRunEnrollmentWithProduct()
+ userEnrollment = testEnrollment
+ enrollmentCardProps.enrollment = testEnrollment
+ enrollmentCardProps.enrollment.enrollment_mode = "audit"
+ const inner = await renderedCard()
+ const enrollmentExtraLinks = inner
+ .find(".enrolled-item")
+ .find(".certificate-upgrade-message")
+ assert.isTrue(enrollmentExtraLinks.exists())
+ const courseDetailsPageLink = enrollmentExtraLinks.find("b").at(0)
+ assert.isTrue(courseDetailsPageLink.exists())
+ })
})