Skip to content

Commit

Permalink
mitxonline dashboard crashes when courserun has no upgrade deadline (#…
Browse files Browse the repository at this point in the history
…2362)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
cp-at-mit and pre-commit-ci[bot] authored Aug 28, 2024
1 parent 78d3c89 commit 21a4188
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 6 deletions.
14 changes: 8 additions & 6 deletions frontend/public/src/components/EnrolledItemCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,12 +438,14 @@ export class EnrolledItemCard extends React.Component<
<strong>Upgrade today</strong> and, upon passing, receive your
certificate signed by MIT faculty to highlight the knowledge and
skills you've gained from this MITx course.{" "}
<b>
Upgrade expires:{" "}
{formatPrettyDateTimeAmPmTz(
parseDateString(enrollment.run.upgrade_deadline)
)}
</b>
{enrollment.run.upgrade_deadline ? (
<b>
Upgrade expires:{" "}
{formatPrettyDateTimeAmPmTz(
parseDateString(enrollment.run.upgrade_deadline)
)}
</b>
) : null}
</div>
</div>
) : null
Expand Down
42 changes: 42 additions & 0 deletions frontend/public/src/components/EnrolledItemCard_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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())
})
})

0 comments on commit 21a4188

Please sign in to comment.