forked from retoor/devplacepy
Attach images pasted into the composer, comments and chat
Pressing Ctrl+V with a screenshot on the clipboard now attaches it immediately instead of requiring a trip through the file picker. The clipboard reader lives in dp-upload behind a new opt-in `paste` boolean attribute: with it set, the component binds one paste listener on its closest form and routes the clipboard image files through the same handleFiles path as the picker and the drop target, so validation, limits, the terms gate and the hidden attachment_uids field are shared. A paste carrying plain text is never swallowed. It is opt-in rather than a form-wide default because a form may hold several upload buttons - projects.html has cover and logo beside the attachment one - and a default would attach one pasted screenshot to all of them. Set on _attachment_form.html, so every form including it inherits the behaviour (post composer, post edit, gists, projects, issues, screenshots), plus _comment_form.html, messages.html and the embed-mode skeleton AppChat builds. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+19
-1
@@ -3,7 +3,7 @@
|
||||
import re
|
||||
import time
|
||||
from playwright.sync_api import expect
|
||||
from tests.conftest import BASE_URL
|
||||
from tests.conftest import BASE_URL, paste_image
|
||||
from devplacepy.database import get_table
|
||||
import requests
|
||||
def _seed_news_seo():
|
||||
@@ -183,6 +183,24 @@ def test_send_message_appears_in_thread(alice):
|
||||
page.locator(f".message-bubble:has-text('{msg}')").first.wait_for(state="visible")
|
||||
|
||||
|
||||
def test_paste_image_attaches_in_chat(alice):
|
||||
page, _ = alice
|
||||
bob = get_table("users").find_one(username="bob_test")
|
||||
page.goto(
|
||||
f"{BASE_URL}/messages?with_uid={bob['uid']}", wait_until="domcontentloaded"
|
||||
)
|
||||
page.locator(".messages-input-area dp-upload .dp-upload-btn").first.wait_for(
|
||||
state="visible", timeout=10000
|
||||
)
|
||||
paste_image(page, ".messages-input-area textarea[name='content']")
|
||||
page.locator(".messages-input-area dp-upload .dp-upload-count").first.wait_for(
|
||||
state="visible", timeout=15000
|
||||
)
|
||||
expect(
|
||||
page.locator(".messages-input-area dp-upload input[name='attachment_uids']")
|
||||
).to_have_value(re.compile(r".+"))
|
||||
|
||||
|
||||
def test_messages_page_loads(alice):
|
||||
page, _ = alice
|
||||
page.goto(f"{BASE_URL}/messages", wait_until="domcontentloaded")
|
||||
|
||||
Reference in New Issue
Block a user