Keep composers usable, group actions and notifications, and drop the tool-count cap

Comment and post layouts stay full width on small screens. Secondary actions live in the More menu. Notifications can be grouped and throttled, and Enter can submit when that profile setting is on. Emulated-tool models accept large catalogs, with reserved names aliased on the wire and the catalog cached per owner. A dropped service-worker navigation is retried once. The test server waits 120s to finish importing before it is stopped.
This commit is contained in:
2026-11-12 15:29:27 +01:00
parent dbdd0d29dd
commit 8a48e3ef85
103 changed files with 2680 additions and 378 deletions
+100
View File
@@ -0,0 +1,100 @@
# retoor <retoor@molodetz.nl>
import time
from datetime import datetime, timezone
import requests
from tests.conftest import BASE_URL
from devplacepy.database import get_table, refresh_snapshot
from devplacepy.utils import generate_uid
_counter = [0]
JSON = {"Accept": "application/json"}
def _signup():
_counter[0] += 1
name = f"ngrp{int(time.time() * 1000)}{_counter[0]}"
session = requests.Session()
session.post(
f"{BASE_URL}/auth/signup",
data={
"username": name,
"email": f"{name}@t.dev",
"password": "secret123",
"confirm_password": "secret123",
"birth_date": "1990-01-01",
"accept_terms": "1",
},
allow_redirects=True,
)
return session, name
def _seed(session, name, count=5):
refresh_snapshot()
user = get_table("users").find_one(username=name)
now = datetime.now(timezone.utc).isoformat()
table = get_table("notifications")
for i in range(count):
table.insert(
{
"uid": generate_uid(),
"user_uid": user["uid"],
"type": "vote",
"message": f"actor-{i} ++'d your post",
"related_uid": user["uid"],
"target_url": "/posts/seeded",
"read": False,
"created_at": now,
}
)
refresh_snapshot()
return user
def _wait_counts(session, expected):
deadline = time.time() + 20
counts = {}
while time.time() < deadline:
counts = session.get(f"{BASE_URL}/notifications/counts").json()
if counts.get("notifications") == expected:
return counts
time.sleep(0.5)
return counts
def test_grouped_page_and_counts(app_server):
session, name = _signup()
_seed(session, name)
counts = _wait_counts(session, 1)
assert counts["notifications"] == 1, counts
page = session.get(f"{BASE_URL}/notifications", headers=JSON)
data = page.json()
assert data["grouping"] is True
events = [
entry
for group in data["notification_groups"]
for entry in group["event_entries"]
]
assert len(events) == 1
assert events[0]["count"] == 5
html = session.get(f"{BASE_URL}/notifications")
assert "&times;5" in html.text or "×5" in html.text
def test_grouping_off_restores_row_counts(app_server):
session, name = _signup()
_seed(session, name)
resp = session.post(
f"{BASE_URL}/profile/{name}/notifications/grouping",
data={"value": "false"},
headers=JSON,
)
assert resp.status_code == 200
counts = _wait_counts(session, 5)
assert counts["notifications"] == 5, counts
page = session.get(f"{BASE_URL}/notifications", headers=JSON)
data = page.json()
assert data["grouping"] is False
+109
View File
@@ -0,0 +1,109 @@
# retoor <retoor@molodetz.nl>
import time
import requests
from tests.conftest import BASE_URL
_counter = [0]
JSON = {"Accept": "application/json"}
def _signup():
_counter[0] += 1
name = f"nset{int(time.time() * 1000)}{_counter[0]}"
session = requests.Session()
session.post(
f"{BASE_URL}/auth/signup",
data={
"username": name,
"email": f"{name}@t.dev",
"password": "secret123",
"confirm_password": "secret123",
"birth_date": "1990-01-01",
"accept_terms": "1",
},
allow_redirects=True,
)
return session, name
def _toggle(session, name, kind, value):
return session.post(
f"{BASE_URL}/profile/{name}/notifications/{kind}",
data={"value": "true" if value else "false"},
headers=JSON,
)
def test_owner_toggles_grouping_and_throttling(app_server):
session, name = _signup()
for kind, field in (("grouping", "notif_grouping_enabled"), ("throttling", "notif_throttle_enabled")):
resp = _toggle(session, name, kind, False)
assert resp.status_code == 200, resp.text[:200]
assert resp.json()["data"][field] is False
resp = _toggle(session, name, kind, True)
assert resp.status_code == 200, resp.text[:200]
assert resp.json()["data"][field] is True
def test_other_user_cannot_toggle(app_server):
_, target = _signup()
attacker, _ = _signup()
for kind in ("grouping", "throttling"):
resp = attacker.post(
f"{BASE_URL}/profile/{target}/notifications/{kind}",
data={"value": "false"},
headers=JSON,
allow_redirects=False,
)
assert resp.status_code == 403
def test_admin_can_toggle(app_server, seeded_db):
_, target = _signup()
admin = requests.Session()
admin.post(
f"{BASE_URL}/auth/login",
data={"email": seeded_db["alice"]["email"], "password": seeded_db["alice"]["password"]},
allow_redirects=True,
)
resp = admin.post(
f"{BASE_URL}/profile/{target}/notifications/grouping",
data={"value": "false"},
headers=JSON,
)
assert resp.status_code == 200, resp.text[:200]
assert resp.json()["data"]["notif_grouping_enabled"] is False
def test_owner_toggles_enter_to_submit(app_server):
session, name = _signup()
resp = session.post(
f"{BASE_URL}/profile/{name}/enter-to-submit",
data={"value": "false"},
headers=JSON,
)
assert resp.status_code == 200, resp.text[:200]
assert resp.json()["data"]["enter_to_submit"] is False
page = session.get(f"{BASE_URL}/profile/{name}", headers=JSON)
assert page.json()["enter_to_submit"] is False
resp = session.post(
f"{BASE_URL}/profile/{name}/enter-to-submit",
data={"value": "true"},
headers=JSON,
)
assert resp.json()["data"]["enter_to_submit"] is True
def test_other_user_cannot_toggle_enter_to_submit(app_server):
_, target = _signup()
attacker, _ = _signup()
resp = attacker.post(
f"{BASE_URL}/profile/{target}/enter-to-submit",
data={"value": "false"},
headers=JSON,
allow_redirects=False,
)
assert resp.status_code == 403