diff --git a/templates/partials/packages/comment_form.html b/templates/partials/packages/comment_form.html
index 5368e784..9222d6e9 100644
--- a/templates/partials/packages/comment_form.html
+++ b/templates/partials/packages/comment_form.html
@@ -33,7 +33,7 @@ Routes:
- {% if comment and not request.user.notified(pkgbase) %}
+ {% if not request.user.notified(pkgbase) %}
diff --git a/test/test_pkgbase_routes.py b/test/test_pkgbase_routes.py
index 124eb71f..a5c93451 100644
--- a/test/test_pkgbase_routes.py
+++ b/test/test_pkgbase_routes.py
@@ -400,18 +400,36 @@ def test_pkgbase_comments(
client: TestClient, maintainer: User, user: User, package: Package
):
"""This test includes tests against the following routes:
+ - GET /pkgbase/{name} (to check notification checkbox)
- POST /pkgbase/{name}/comments
- GET /pkgbase/{name} (to check comments)
- Tested against a comment created with the POST route
- GET /pkgbase/{name}/comments/{id}/form
- Tested against a comment created with the POST route
"""
+ cookies = {"AURSID": maintainer.login(Request(), "testPassword")}
+ pkgbasename = package.PackageBase.Name
+
+ endpoint = f"/pkgbase/{pkgbasename}"
+ with client as request:
+ request.cookies = cookies
+ resp = request.get(
+ endpoint,
+ follow_redirects=True,
+ )
+ assert resp.status_code == int(HTTPStatus.OK)
+
+ # Make sure we got our checkbox for enabling notifications
+ root = parse_root(resp.text)
+ input = root.find('//input[@id="id_enable_notifications"]')
+ assert input is not None
+
+ # create notification
with db.begin():
user.CommentNotify = 1
db.create(PackageNotification, PackageBase=package.PackageBase, User=user)
- cookies = {"AURSID": maintainer.login(Request(), "testPassword")}
- pkgbasename = package.PackageBase.Name
+ # post a comment
endpoint = f"/pkgbase/{pkgbasename}/comments"
with client as request:
request.cookies = cookies
@@ -442,6 +460,11 @@ def test_pkgbase_comments(
assert bodies[0].text.strip() == "Test comment."
comment_id = headers[0].attrib["id"].split("-")[-1]
+ # Since we've enabled notifications already,
+ # there should be no checkbox on our page
+ input = root.find('//input[@id="id_enable_notifications"]')
+ assert input is None
+
# Test the non-javascript version of comment editing by
# visiting the /pkgbase/{name}/comments/{id}/edit route.
with client as request: