Keep composers usable, group actions and notifications, and drop the tool-count cap
DevPlace CI / test (push) Failing after 3h10m39s

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
+244 -4
View File
@@ -5,7 +5,6 @@ import time
from playwright.sync_api import expect
from tests.conftest import BASE_URL, paste_image
from devplacepy.database import get_table
import requests
def _seed_news_seo():
from datetime import datetime, timezone
from devplacepy.database import get_table
@@ -557,13 +556,15 @@ def _uid(username):
def _send_as(page, receiver_uid, content):
page.evaluate(
ok = page.evaluate(
"async ([uid, text]) => {"
" const body = new URLSearchParams({receiver_uid: uid, content: text});"
" await fetch('/messages/send', {method: 'POST', body, headers: {Accept: 'application/json'}});"
" const resp = await fetch('/messages/send', {method: 'POST', body, headers: {Accept: 'application/json'}});"
" return resp.ok;"
"}",
[receiver_uid, content],
)
assert ok, "seed message send must succeed"
def test_dock_icon_opens_chats_panel_then_a_docked_window(alice, bob):
@@ -666,7 +667,7 @@ def test_dock_is_absent_on_messages_page(alice):
def test_mobile_messages_icon_opens_the_messages_page(mobile_page):
page, _ = mobile_page
page.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
page.locator("[data-chat-panel-toggle]").first.click(force=True)
page.locator("[data-chat-panel-toggle]").first.click()
page.wait_for_url(f"{BASE_URL}/messages", wait_until="domcontentloaded")
@@ -686,3 +687,242 @@ def test_composer_plus_button_reveals_attach_tools(alice):
area.locator("textarea[name='content']").fill("typing tucks the tools away")
expect(upload).to_be_hidden()
expect(more).to_have_attribute("aria-expanded", "false")
def test_dock_window_plus_button_reveals_attach_tools(alice, bob):
page_a, _ = alice
_, user_b = bob
uid_b = _uid(user_b["username"])
page_a.goto(f"{BASE_URL}/profile/{user_b['username']}", wait_until="domcontentloaded")
page_a.locator(f"[data-chat-open='{uid_b}']").click()
window = page_a.locator(f".chat-window[data-chat-uid='{uid_b}']")
area = window.locator(".messages-input-area")
upload = area.locator("dp-upload .dp-upload-btn")
more = area.locator(".composer-more-btn")
expect(upload).to_be_hidden()
more.click()
expect(upload).to_be_visible()
expect(more).to_have_attribute("aria-expanded", "true")
area.locator("textarea[name='content']").fill("typing in the window")
expect(upload).to_be_hidden()
def test_dock_open_window_survives_navigation(alice, bob):
page_a, user_a = alice
page_b, user_b = bob
uid_b = _uid(user_b["username"])
msg = f"Restore me {int(time.time() * 1000)}"
_send_as(page_b, _uid(user_a["username"]), msg)
page_a.goto(f"{BASE_URL}/profile/{user_b['username']}", wait_until="domcontentloaded")
page_a.locator(f"[data-chat-open='{uid_b}']").click()
window = page_a.locator(f".chat-window[data-chat-uid='{uid_b}']")
window.locator(f".message-bubble:has-text('{msg}')").wait_for(state="visible")
page_a.goto(f"{BASE_URL}/projects", wait_until="domcontentloaded")
window = page_a.locator(f".chat-window[data-chat-uid='{uid_b}']")
window.locator(f".message-bubble:has-text('{msg}')").wait_for(state="visible")
expect(window.locator("textarea[name='content']")).to_be_visible()
def test_dock_panel_search_and_see_all(alice, bob):
page_a, _ = alice
_, user_b = bob
uid_b = _uid(user_b["username"])
page_a.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
page_a.locator("[data-chat-panel-toggle]").first.click()
panel = page_a.locator(".chat-panel")
expect(panel).to_be_visible()
expect(panel.locator(".chat-panel-footer")).to_have_attribute("href", "/messages")
panel.locator(".chat-panel-search-input").fill(user_b["username"])
item = panel.locator(f".conversation-item[data-conv-uid='{uid_b}']")
item.wait_for(state="visible")
item.click()
expect(panel).to_be_hidden()
expect(page_a.locator(f".chat-window[data-chat-uid='{uid_b}']")).to_have_count(1)
def test_dock_panel_and_window_close_controls(alice, bob):
page_a, _ = alice
_, user_b = bob
uid_b = _uid(user_b["username"])
page_a.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
toggle = page_a.locator("[data-chat-panel-toggle]").first
panel = page_a.locator(".chat-panel")
toggle.click()
expect(panel).to_be_visible()
page_a.keyboard.press("Escape")
expect(panel).to_be_hidden()
toggle.click()
expect(panel).to_be_visible()
page_a.locator("body").click(position={"x": 700, "y": 500})
expect(panel).to_be_hidden()
page_a.goto(f"{BASE_URL}/profile/{user_b['username']}", wait_until="domcontentloaded")
page_a.locator(f"[data-chat-open='{uid_b}']").click()
window = page_a.locator(f".chat-window[data-chat-uid='{uid_b}']")
window.locator(".chat-window-close").click()
expect(window).to_have_count(0)
page_a.locator(f"[data-chat-open='{uid_b}']").click()
window.locator(".chat-window-minimize").click()
head = page_a.locator(f".chat-head[data-chat-uid='{uid_b}']")
head.wait_for(state="visible")
head.locator(".chat-head-close").click()
expect(head).to_have_count(0)
def test_dock_caps_expanded_windows_at_three(alice, bob):
page_a, _ = alice
_, user_b = bob
from devplacepy.utils import generate_uid
partners = [_uid(user_b["username"])]
for name in ("dockcap1", "dockcap2", "dockcap3"):
row = get_table("users").find_one(username=name)
if not row:
get_table("users").insert(
{
"deleted_at": None,
"deleted_by": None,
"uid": generate_uid(),
"username": name,
"email": f"{name}@test.devplace",
"password_hash": "x",
"role": "Member",
"is_active": True,
"created_at": "2026-01-01T00:00:00+00:00",
}
)
row = get_table("users").find_one(username=name)
partners.append(row["uid"])
page_a.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
for uid in partners:
page_a.evaluate("(uid) => window.app.chatDock.open({ uid, username: 'x' }, { focus: false })", uid)
expect(page_a.locator(".chat-window:not(.chat-window-compose)")).to_have_count(3)
expect(page_a.locator(".chat-head")).to_have_count(1)
def test_dock_toast_click_opens_window(alice, bob):
page_a, user_a = alice
page_b, _ = bob
uid_a = _uid(user_a["username"])
uid_b = _uid("bob_test")
page_a.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
page_a.wait_for_function("() => !!window.app && !!window.app.chatDock")
msg = f"Toast hello {int(time.time() * 1000)}"
_send_as(page_b, uid_a, msg)
page_a.evaluate(
"(sender) => window.app.liveNotifications.onNotification("
" { uid: 'toast-test', type: 'message', message: 'bob_test sent you a message',"
" target_url: `/messages?with_uid=${sender}` })",
uid_b,
)
toast = page_a.locator(".dp-toast-link")
toast.first.wait_for(state="visible", timeout=10000)
toast.first.click()
window = page_a.locator(f".chat-window[data-chat-uid='{uid_b}']")
window.locator(f".message-bubble:has-text('{msg}')").wait_for(state="visible", timeout=10000)
assert page_a.url.endswith("/feed")
def test_dock_window_live_message_shows_report_button(alice, bob):
page_a, user_a = alice
page_b, user_b = bob
uid_a = _uid(user_a["username"])
uid_b = _uid(user_b["username"])
page_a.goto(f"{BASE_URL}/profile/{user_b['username']}", wait_until="domcontentloaded")
page_a.locator(f"[data-chat-open='{uid_b}']").click()
window = page_a.locator(f".chat-window[data-chat-uid='{uid_b}']")
window.locator("textarea[name='content']").wait_for(state="visible")
msg = f"Flag in window {int(time.time() * 1000)}"
_send_as(page_b, uid_a, msg)
bubble = window.locator(f".message-bubble.theirs:has-text('{msg}')")
bubble.wait_for(state="visible", timeout=10000)
expect(bubble.locator(".message-report-btn")).to_be_visible()
def test_dock_reading_on_messages_page_clears_head_badge(alice, bob):
page_a, user_a = alice
page_b, user_b = bob
uid_a = _uid(user_a["username"])
uid_b = _uid(user_b["username"])
page_a.goto(f"{BASE_URL}/profile/{user_b['username']}", wait_until="domcontentloaded")
page_a.locator(f"[data-chat-open='{uid_b}']").click()
window = page_a.locator(f".chat-window[data-chat-uid='{uid_b}']")
window.locator(".chat-window-minimize").click()
head = page_a.locator(f".chat-head[data-chat-uid='{uid_b}']")
head.wait_for(state="visible")
_send_as(page_b, uid_a, f"Badge check {int(time.time() * 1000)}")
expect(head.locator(".chat-head-badge")).to_have_text("1", timeout=10000)
page_a.goto(f"{BASE_URL}/messages?with_uid={uid_b}", wait_until="domcontentloaded")
page_a.locator(".messages-thread .message-bubble").first.wait_for(state="visible")
page_a.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
head = page_a.locator(f".chat-head[data-chat-uid='{uid_b}']")
head.wait_for(state="visible")
expect(head.locator(".chat-head-badge")).to_be_hidden(timeout=10000)
def test_dock_hidden_tab_does_not_mark_read_until_visible(alice, bob):
page_a, user_a = alice
page_b, user_b = bob
uid_a = _uid(user_a["username"])
uid_b = _uid(user_b["username"])
page_a.goto(f"{BASE_URL}/profile/{user_b['username']}", wait_until="domcontentloaded")
page_a.locator(f"[data-chat-open='{uid_b}']").click()
window = page_a.locator(f".chat-window[data-chat-uid='{uid_b}']")
window.locator("textarea[name='content']").wait_for(state="visible")
page_a.wait_for_function("() => document.querySelector('dp-chat-dock').hub.isOpen()")
page_a.evaluate(
"() => { Object.defineProperty(document, 'visibilityState', { value: 'hidden', configurable: true });"
" document.dispatchEvent(new Event('visibilitychange')); }"
)
msg = f"Hidden tab {int(time.time() * 1000)}"
_send_as(page_b, uid_a, msg)
window.locator(f".message-bubble:has-text('{msg}')").wait_for(state="visible", timeout=10000)
page_a.wait_for_timeout(500)
unread = page_a.evaluate(
"async (uid) => { const r = await fetch('/messages/conversations', {headers: {Accept: 'application/json'}});"
" const d = await r.json(); const c = (d.conversations || []).find((x) => x.other_user.uid === uid);"
" return c ? c.unread : null; }",
uid_b,
)
assert unread is True, "a message to a window in a hidden tab must stay unread"
page_a.evaluate(
"() => { Object.defineProperty(document, 'visibilityState', { value: 'visible', configurable: true });"
" document.dispatchEvent(new Event('visibilitychange')); }"
)
page_a.wait_for_function(
"async (uid) => { const r = await fetch('/messages/conversations', {headers: {Accept: 'application/json'}});"
" const d = await r.json(); const c = (d.conversations || []).find((x) => x.other_user.uid === uid);"
" return !!c && c.unread === false; }",
arg=uid_b,
timeout=10000,
)
def test_dock_socket_does_not_resurrect_after_last_window_closes(alice, bob):
page_a, _ = alice
_, user_b = bob
uid_b = _uid(user_b["username"])
page_a.goto(f"{BASE_URL}/profile/{user_b['username']}", wait_until="domcontentloaded")
page_a.locator(f"[data-chat-open='{uid_b}']").click()
page_a.locator(f".chat-window[data-chat-uid='{uid_b}'] textarea[name='content']").wait_for(state="visible")
page_a.wait_for_function("() => document.querySelector('dp-chat-dock').hub.isOpen()")
result = page_a.evaluate(
"async (uid) => {"
" const dock = document.querySelector('dp-chat-dock');"
" const cs = dock.hub.socket;"
" let opens = 0; const orig = cs._open.bind(cs);"
" cs._open = () => { opens += 1; return orig(); };"
" cs.socket.close();"
" await new Promise((r) => setTimeout(r, 100));"
" dock.close(uid);"
" await new Promise((r) => setTimeout(r, 900));"
" return { opens, hubSocket: dock.hub.socket === null, state: cs.socket ? cs.socket.readyState : null };"
"}",
uid_b,
)
assert result["hubSocket"], "the hub must not hold a socket after the last window closes"
assert result["opens"] == 0, f"a closed socket must not reconnect with zero subscribers: {result}"