Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.100.2 #2381

Merged
merged 6 commits into from
Sep 3, 2024
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
8 changes: 8 additions & 0 deletions RELEASE.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Release Notes
=============

Version 0.100.2
---------------

- Update dependency webpack to v5.94.0 [SECURITY] (#2370)
- Fix typo in unenrollment email (#2369)
- Most relevant run should be determined in the backend only (#2363)
- mitxonline dashboard crashes when courserun has no upgrade deadline (#2362)

Version 0.100.1 (Released September 03, 2024)
---------------

Expand Down
2 changes: 1 addition & 1 deletion courses/templates/mail/course_run_unenrollment/body.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<td style="padding: 20px; font-family: sans-serif; font-size: 15px; line-height: 20px; color: #555555;">
<p style="margin: 0 0 10px;">Dear {{ user.name }},</p>
<p style="margin: 0 0 10px;">
You have been unenrolled in
You have been unenrolled from
{% if enrollment.run.start_date %}
{{ enrollment.run.course_number }} {{ enrollment.run.course.title }} starting {{ enrollment.run.start_date|date:"F j, Y"}}.
{% else %}
Expand Down
2 changes: 1 addition & 1 deletion courses/templates/mail/course_run_unenrollment/subject.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
You have been unenrolled in {{ enrollment.run.course_number }} {{ enrollment.run.course.title }}.
You have been unenrolled from {{ enrollment.run.course_number }} {{ enrollment.run.course.title }}.
2 changes: 1 addition & 1 deletion frontend/public/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"video.js": "7.21.6",
"videojs-youtube": "2.6.1",
"waait": "1.0.5",
"webpack": "5.76.0",
"webpack": "5.94.0",
"webpack-bundle-analyzer": "^4.6.1",
"webpack-bundle-tracker": "1.4.0",
"webpack-cli": "4.10.0",
Expand Down
50 changes: 42 additions & 8 deletions frontend/public/src/components/CourseProductDetailEnroll_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,20 @@ describe("CourseProductDetailEnrollShallowRender", () => {

it("checks for enroll now button", async () => {
const courseRun = makeCourseRunDetail()
courseRun.is_enrollable = true
course.courseruns = [courseRun]
course.next_run_id = courseRun.id
const { inner } = await renderPage(
{
entities: {
courseRuns: [courseRun]
courseRuns: [courseRun],
courses: [course]
},
queries: {
courses: {
isPending: false,
status: 200
},
courseRuns: {
isPending: false,
status: 200
Expand All @@ -103,10 +111,13 @@ describe("CourseProductDetailEnrollShallowRender", () => {
{}
)

assert.equal(inner.find(".enroll-now").at(0).text(), "Enroll Now")
assert.equal(
inner.find(".btn-enrollment-button").at(0).text(),
"Enroll Now"
)
})

it("checks for enroll now button should appear disabled if enrollment start in future", async () => {
it("checks for Access Course Materials button should appear disabled if no enrollable runs", async () => {
const courseRun = makeCourseRunDetail()
courseRun["is_enrollable"] = false
const course = makeCourseDetailNoRuns()
Expand All @@ -125,13 +136,15 @@ describe("CourseProductDetailEnrollShallowRender", () => {
},
{}
)
assert.isTrue(inner.find(".enroll-now").at(0).exists())
assert.isTrue(inner.find(".enroll-now").at(0).prop("disabled"))
assert.isTrue(inner.find(".btn-enrollment-button").at(0).exists())
assert.isTrue(inner.find(".btn-enrollment-button").at(0).prop("disabled"))
})

it("checks for enroll now button should appear if enrollment start not in future", async () => {
const courseRun = makeCourseRunDetail()
courseRun.is_enrollable = true
const course = makeCourseDetailNoRuns()
course.next_run_id = courseRun.id
course.courseruns = [courseRun]
const { inner } = await renderPage(
{
Expand Down Expand Up @@ -161,7 +174,9 @@ describe("CourseProductDetailEnrollShallowRender", () => {
is_archived: true,
upgrade_deadline: null
}
courseRun.is_enrollable = true
const course = makeCourseDetailNoRuns()
course.next_run_id = courseRun.id
course.courseruns = [courseRun]
const { inner } = await renderPage(
{
Expand All @@ -187,10 +202,15 @@ describe("CourseProductDetailEnrollShallowRender", () => {

it("checks for form-based enrollment form if there is no product", async () => {
const courseRun = makeCourseRunDetail()
courseRun.is_enrollable = true
const course = makeCourseDetailNoRuns()
course.next_run_id = courseRun.id
course.courseruns = [courseRun]
const { inner } = await renderPage(
{
entities: {
courseRuns: [courseRun]
courseRuns: [courseRun],
courses: [course]
},
queries: {
courseRuns: {
Expand Down Expand Up @@ -244,6 +264,7 @@ describe("CourseProductDetailEnrollShallowRender", () => {

const course = makeCourseDetailNoRuns()
course.courseruns = courseRuns
course.next_run_id = courseRun.id

const entities = {
currentUser: userExists ? currentUser : makeAnonymousUser(),
Expand Down Expand Up @@ -280,6 +301,7 @@ describe("CourseProductDetailEnrollShallowRender", () => {
}
}
const course = makeCourseDetailNoRuns()
course.next_run_id = courseRun.id
course.courseruns = [courseRun]
isFinancialAssistanceAvailableStub.returns(true)
const { inner } = await renderPage(
Expand Down Expand Up @@ -339,6 +361,7 @@ describe("CourseProductDetailEnrollShallowRender", () => {
courseRun["is_self_paced"] = false
}
const course = makeCourseDetailNoRuns()
course.next_run_id = courseRun.id
course.courseruns = [courseRun]
const entities = {
currentUser: currentUser,
Expand Down Expand Up @@ -372,7 +395,8 @@ describe("CourseProductDetailEnrollShallowRender", () => {
}
const course = {
...makeCourseDetailWithRuns(),
courseruns: [courseRun]
courseruns: [courseRun],
next_run_id: courseRun.id
}

const entities = {
Expand Down Expand Up @@ -451,6 +475,7 @@ describe("CourseProductDetailEnrollShallowRender", () => {
}
]
course.courseruns = [courseRun]
course.next_run_id = courseRun.id
const { inner } = await renderPage(
{
entities: {
Expand Down Expand Up @@ -495,6 +520,7 @@ describe("CourseProductDetailEnrollShallowRender", () => {
}
}
]
course.next_run_id = courseRun.id
course.courseruns = [courseRun]
const { inner } = await renderPage(
{
Expand Down Expand Up @@ -543,6 +569,7 @@ describe("CourseProductDetailEnrollShallowRender", () => {
}
]
isFinancialAssistanceAvailableStub.returns(false)
course.next_run_id = courseRun.id
course.courseruns = [courseRun]
const { inner } = await renderPage(
{
Expand Down Expand Up @@ -632,6 +659,7 @@ describe("CourseProductDetailEnrollShallowRender", () => {
product_flexible_price: {}
}
]
course.next_run_id = courseRun.id
course.courseruns = [courseRun]
const { inner } = await renderPage(
{
Expand Down Expand Up @@ -663,6 +691,7 @@ describe("CourseProductDetailEnrollShallowRender", () => {
if (multiples) {
courseRuns.push(courseRun)
}
course.next_run_id = courseRun.id
course.courseruns = courseRuns

const { inner } = await renderPage({
Expand Down Expand Up @@ -715,6 +744,7 @@ describe("CourseProductDetailEnrollShallowRender", () => {
courseRun["is_upgradable"] = false
const courseRuns = [courseRun]
courseRuns.push(courseRun)
course.next_run_id = courseRun.id
course.courseruns = courseRuns

const { inner } = await renderPage({
Expand Down Expand Up @@ -754,6 +784,7 @@ describe("CourseProductDetailEnrollShallowRender", () => {
}
const courseRuns = [courseRun]
courseRuns.push(runWithMixedInfo)
course.next_run_id = courseRun.id
course.courseruns = courseRuns

const { inner } = await renderPage({
Expand Down Expand Up @@ -828,7 +859,8 @@ describe("CourseProductDetailEnrollShallowRender", () => {
]
const course = {
...makeCourseDetailWithRuns(),
courseruns: [pastCourseRun, currentCourseRun]
courseruns: [pastCourseRun, currentCourseRun],
next_run_id: currentCourseRun.id
}

const { inner } = await renderPage({
Expand Down Expand Up @@ -884,6 +916,7 @@ describe("CourseProductDetailEnrollShallowRender", () => {
} else {
courseRun["start_date"] = moment().subtract(10, "months").toISOString()
}
course.next_run_id = courseRun.id
course.courseruns = [courseRun]

const entities = {
Expand Down Expand Up @@ -953,6 +986,7 @@ describe("CourseProductDetailEnrollShallowRender", () => {
}

course.courseruns = courseRuns
course.next_run_id = courseRun.id

const entities = {
currentUser: userExists ? currentUser : makeAnonymousUser(),
Expand Down
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())
})
})
37 changes: 0 additions & 37 deletions frontend/public/src/lib/courseApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,6 @@ export const getFirstRelevantRun = (
/*
Finds the next most relevant course run:
- If the course has a next_run_id, return that run
- If there are future runs, return the run closer to now
- If all runs are in the past, return the most recently ended run
- If there are no runs, return null

Args:
Expand All @@ -235,40 +233,5 @@ export const getFirstRelevantRun = (
if (course.next_run_id) {
return courseRuns.find(run => run.id === course.next_run_id)
}

const now = moment()
const enrollableRuns = courseRuns.filter(run => run.is_enrollable)
if (enrollableRuns.length > 0) {
if (
enrollableRuns.some(
run => run.start_date && moment(run.start_date).isSameOrAfter(now)
)
) {
return enrollableRuns
.filter(
run => run.start_date && moment(run.start_date).isSameOrAfter(now)
)
.reduce((prev, curr) =>
moment(curr.start_date).isBefore(moment(prev.start_date)) ?
curr :
prev
)
}

return enrollableRuns
.filter(run => run.start_date && moment(run.start_date).isBefore(now))
.reduce((prev, curr) =>
moment(curr.start_date).isBefore(moment(prev.start_date)) ? prev : curr
)
}
// no enrollable runs, then check for future runs
const futureRuns = courseRuns.filter(
run => run.start_date && moment(run.start_date).isSameOrAfter(now)
)
if (futureRuns.length > 0) {
return futureRuns.reduce((prev, curr) =>
moment(curr.start_date).isBefore(moment(prev.start_date)) ? curr : prev
)
}
return null
}
Loading
Loading