test(sveta): Write test: admin page renders participation notification defaults row
Outcome: done Changed: tests/e2e/admin/notifications.py:53-90 Verified by: `python3 -m py_compile tests/e2e/admin/notifications.py` — compile: pass Findings: - New test `test_admin_page_renders_participation_defaults` at `tests/e2e/admin/notifications.py:53` fetches `GET /admin/notifications` with the admin's X-API-KEY and asserts the participation notification type row renders with label "Post participation", description "Someone else comments on a post you also commented on", and the correct default channel states: in_app=checked, push=checked, telegram=unchecked (matching `_NOTIFICATION_CHANNEL_DEFAULTS` at `devplacepy/database/notifications.py:34`) - `NOTIFICATION_TYPES` at `devplacepy/database/notifications.py:15` includes `participation` with `label: "Post participation"` and description referencing "post you also commented on" - `_notification_defaults_view()` at `devplacepy/routers/admin/notifications.py:24-34` iterates all `NOTIFICATION_TYPES` unconditionally, so participation is always included in the admin page - Admin template `devplacepy/templates/admin_notifications.html:25-53` renders every `notification_defaults` entry with a table row containing data-toggle inputs for each channel - Test follows existing patterns in the file: uses `requests` with `X-API-KEY` header, same `alice` fixture unpacking, same `_user_notification_prefs` helper Open: Full test suite (`make test`) cannot run in this container — the environment has Python 3.11.2 but the project `require Typosaurus-Run: 33c1c53eb8d34b528ee5beab574476fb Typosaurus-Node: 950b129728bf4645b401c9210089f9f5 Typosaurus-Agent: @sveta Refs: #132
This commit is contained in:
parent
51a31395a4
commit
9eb1cc6cfa
@ -46,3 +46,44 @@ def test_member_cannot_set_default(bob):
|
||||
)
|
||||
assert response.status_code in (302, 303, 403)
|
||||
assert get_notification_default("level", "push") is True
|
||||
|
||||
|
||||
def test_admin_page_renders_participation_defaults(alice):
|
||||
_, admin_user = alice
|
||||
admin = _user_notification_prefs(admin_user["username"])
|
||||
response = requests.get(
|
||||
f"{BASE_URL}/admin/notifications",
|
||||
headers={"X-API-KEY": admin["api_key"]},
|
||||
allow_redirects=False,
|
||||
)
|
||||
assert response.status_code == 200
|
||||
html = response.text
|
||||
|
||||
assert "Post participation" in html, (
|
||||
"Admin notifications page should contain 'Post participation' label"
|
||||
)
|
||||
assert "Someone else comments on a post you also commented on" in html, (
|
||||
"Admin notifications page should contain participation description"
|
||||
)
|
||||
|
||||
assert 'data-type="participation" data-channel="in_app"' in html, (
|
||||
"Participation in_app row should exist"
|
||||
)
|
||||
assert 'data-type="participation" data-channel="in_app" checked' in html, (
|
||||
"Participation in_app default should be checked (on)"
|
||||
)
|
||||
|
||||
assert 'data-type="participation" data-channel="push"' in html, (
|
||||
"Participation push row should exist"
|
||||
)
|
||||
assert 'data-type="participation" data-channel="push" checked' in html, (
|
||||
"Participation push default should be checked (on)"
|
||||
)
|
||||
|
||||
assert 'data-type="participation" data-channel="telegram"' in html, (
|
||||
"Participation telegram row should exist"
|
||||
)
|
||||
assert (
|
||||
'data-type="participation" data-channel="telegram" checked' not in html
|
||||
), "Participation telegram default should NOT be checked (off)"
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user