Skip to content

Commit 9bb4f27

Browse files
Fix close button on add to cart confirm modal (#3114)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 90027a1 commit 9bb4f27

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

frontend/public/src/components/CourseProductDetailEnroll.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,10 @@ export class CourseProductDetailEnroll extends React.Component<
292292
<strong>{course && course.title}</strong> added to your cart.
293293
</div>
294294
<div className="float-container">
295-
<button className="btn btn-gradient-white-to-blue btn-secondary close-dialog-btn">
295+
<button
296+
className="btn btn-gradient-white-to-blue btn-secondary close-dialog-btn"
297+
onClick={() => this.toggleCartConfirmationDialogVisibility()}
298+
>
296299
Close
297300
</button>
298301
<button

frontend/public/src/components/CourseProductDetailEnroll_test.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,4 +995,47 @@ describe("CourseProductDetailEnrollShallowRender", () => {
995995
}
996996
})
997997
})
998+
999+
it("closes add-to-cart confirmation dialog when Close button is clicked", async () => {
1000+
courseRun["products"] = [
1001+
{
1002+
id: 1,
1003+
price: 10
1004+
}
1005+
]
1006+
course.next_run_id = courseRun.id
1007+
course.courseruns = [courseRun]
1008+
1009+
const { inner } = await renderPage(
1010+
{
1011+
entities: {
1012+
courses: [course]
1013+
},
1014+
queries: {
1015+
courses: {
1016+
isPending: false,
1017+
status: 200
1018+
}
1019+
}
1020+
},
1021+
{ courseId: course.id }
1022+
)
1023+
1024+
inner.setState({ addedToCartDialogVisibility: true })
1025+
inner.update()
1026+
1027+
const modal = inner.find(".added-to-cart-modal")
1028+
assert.isTrue(modal.exists())
1029+
assert.isTrue(modal.prop("isOpen"))
1030+
1031+
const closeButton = modal.find(".close-dialog-btn")
1032+
assert.isTrue(closeButton.exists())
1033+
1034+
await closeButton.prop("onClick")()
1035+
inner.update()
1036+
1037+
const updatedModal = inner.find(".added-to-cart-modal")
1038+
assert.isFalse(updatedModal.prop("isOpen"))
1039+
assert.isFalse(inner.state("addedToCartDialogVisibility"))
1040+
})
9981041
})

0 commit comments

Comments
 (0)