Skip to content

Commit

Permalink
Adding a test for archived courses (#1985)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkachel authored Nov 8, 2023
1 parent 254a635 commit 8039ce3
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 5 deletions.
10 changes: 5 additions & 5 deletions frontend/public/src/components/CourseInfoBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ export default class CourseInfoBox extends React.PureComponent<CourseInfoBoxProp
<>
<div className="enrollment-info-box componentized">
{isArchived ? (
<div className="row d-flex align-self-stretch callout callout-warning">
<div className="row d-flex align-self-stretch callout callout-warning course-archived-message">
<i className="material-symbols-outlined warning">error</i>
<p>
This course is no longer active, but you can still access
selected content.
</p>
</div>
) : null}
<div className="row d-flex align-items-center">
<div className="row d-flex align-items-center course-timing-message">
<div className="enrollment-info-icon">
<img
src="/static/images/products/start-date.png"
Expand All @@ -127,7 +127,7 @@ export default class CourseInfoBox extends React.PureComponent<CourseInfoBoxProp
) : null}
</div>
{course && course.page ? (
<div className="row d-flex align-items-top">
<div className="row d-flex align-items-top course-effort-message">
<div className="enrollment-info-icon">
<img
src="/static/images/products/effort.png"
Expand All @@ -149,15 +149,15 @@ export default class CourseInfoBox extends React.PureComponent<CourseInfoBoxProp
</div>
</div>
) : null}
<div className="row d-flex align-items-center">
<div className="row d-flex align-items-center course-pricing-message">
<div className="enrollment-info-icon">
<img src="/static/images/products/cost.png" alt="Cost" />
</div>
<div className="enrollment-info-text">
<b>Free</b>
</div>
</div>
<div className="row d-flex align-items-top">
<div className="row d-flex align-items-top course-certificate-message">
<div className="enrollment-info-icon">
<img
src="/static/images/products/certificate.png"
Expand Down
53 changes: 53 additions & 0 deletions frontend/public/src/components/CourseProductDetailEnroll_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,4 +620,57 @@ describe("CourseProductDetailEnroll", () => {
const enrolledItem = infobox.find(".more-dates-link.enrolled")
assert.isTrue(enrolledItem.exists())
})

it("CourseInfoBox renders the archived message if the course is archived", async () => {
const courseRun = {
...makeCourseRunDetail(),
is_self_paced: true,
enrollment_end: null,
enrollment_start: moment()
.subtract(1, "years")
.toISOString(),
start_date: moment()
.subtract(10, "months")
.toISOString(),
end_date: moment()
.subtract(7, "months")
.toISOString(),
upgrade_deadline: null
}
const course = {
...makeCourseDetailWithRuns(),
courseruns: [courseRun]
}

console.log(course)

const entities = {
currentUser: currentUser,
enrollments: [],
courseRuns: [courseRun],
courses: [course]
}

const { inner } = await renderPage({
entities: entities
})

assert.isTrue(inner.exists())
const infobox = inner.find("CourseInfoBox").dive()
assert.isTrue(infobox.exists())

const archivedMessage = infobox.find("div.course-archived-message")
assert.isTrue(archivedMessage.exists())

const contentAvailabilityMessage = infobox.find(
"div.course-timing-message div.enrollment-info-text"
)
assert.isTrue(contentAvailabilityMessage.exists())
assert.isTrue(
contentAvailabilityMessage
.first()
.text()
.includes("Course content available anytime")
)
})
})

0 comments on commit 8039ce3

Please sign in to comment.