mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix: show notification box when adding a comment
Currently, the "Enable notifications" checkbox is only shown when editing a comment. We should also show it when a new comment is about to be added. Signed-off-by: moson-mo <mo-son@mailbox.org>
This commit is contained in:
parent
65ba735f18
commit
36fd58d7a6
2 changed files with 26 additions and 3 deletions
|
@ -33,7 +33,7 @@ Routes:
|
|||
<button type="submit" class="button">
|
||||
{{ ("Save" if comment else "Add Comment") | tr }}
|
||||
</button>
|
||||
{% if comment and not request.user.notified(pkgbase) %}
|
||||
{% if not request.user.notified(pkgbase) %}
|
||||
<span class="comment-enable-notifications">
|
||||
<input type="checkbox" name="enable_notifications"
|
||||
id="id_enable_notifications" />
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Reference in a new issue