forked from retoor/devplacepy
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:
+62
-20
@@ -191,7 +191,7 @@ def app_server(test_db_path):
|
||||
except OSError:
|
||||
return ""
|
||||
|
||||
deadline = time.time() + 30
|
||||
deadline = time.time() + 120
|
||||
while time.time() < deadline:
|
||||
try:
|
||||
import urllib.request
|
||||
@@ -208,8 +208,12 @@ def app_server(test_db_path):
|
||||
time.sleep(0.5)
|
||||
else:
|
||||
proc.terminate()
|
||||
proc.wait(timeout=5)
|
||||
raise RuntimeError(f"Server did not start after 30s. Log:\n{server_log()}")
|
||||
try:
|
||||
proc.wait(timeout=15)
|
||||
except subprocess.TimeoutExpired:
|
||||
proc.kill()
|
||||
proc.wait(timeout=5)
|
||||
raise RuntimeError(f"Server did not start after 120s. Log:\n{server_log()}")
|
||||
|
||||
from devplacepy.database import set_setting as _set_setting
|
||||
|
||||
@@ -301,26 +305,39 @@ def page(browser_context):
|
||||
p.close()
|
||||
|
||||
|
||||
def signup_user(page, user):
|
||||
def _reach_feed(page, url, fill, submit_text):
|
||||
page.bring_to_front()
|
||||
page.goto(f"{BASE_URL}/auth/signup", wait_until="domcontentloaded")
|
||||
page.fill("#username", user["username"])
|
||||
page.fill("#email", user["email"])
|
||||
page.fill("#password", user["password"])
|
||||
page.fill("#confirm_password", user["password"])
|
||||
page.fill("#birth_date", "1990-01-01")
|
||||
page.check("#accept_terms")
|
||||
page.click("button:has-text('Create account')")
|
||||
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
|
||||
for attempt in (1, 2):
|
||||
page.goto(url, wait_until="domcontentloaded")
|
||||
fill()
|
||||
try:
|
||||
page.click(f"button:has-text('{submit_text}')")
|
||||
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
|
||||
return
|
||||
except Exception as error:
|
||||
dropped = "chrome-error://chromewebdata/" in str(error) or page.url.startswith("chrome-error:")
|
||||
if attempt == 2 or not dropped:
|
||||
raise
|
||||
|
||||
|
||||
def signup_user(page, user):
|
||||
def fill():
|
||||
page.fill("#username", user["username"])
|
||||
page.fill("#email", user["email"])
|
||||
page.fill("#password", user["password"])
|
||||
page.fill("#confirm_password", user["password"])
|
||||
page.fill("#birth_date", "1990-01-01")
|
||||
page.check("#accept_terms")
|
||||
|
||||
_reach_feed(page, f"{BASE_URL}/auth/signup", fill, "Create account")
|
||||
|
||||
|
||||
def login_user(page, user):
|
||||
page.bring_to_front()
|
||||
page.goto(f"{BASE_URL}/auth/login", wait_until="domcontentloaded")
|
||||
page.fill("#email", user["email"])
|
||||
page.fill("#password", user["password"])
|
||||
page.click("button:has-text('Sign in')")
|
||||
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
|
||||
def fill():
|
||||
page.fill("#email", user["email"])
|
||||
page.fill("#password", user["password"])
|
||||
|
||||
_reach_feed(page, f"{BASE_URL}/auth/login", fill, "Sign in")
|
||||
|
||||
|
||||
def paste_image(page, selector, name="pasted.png"):
|
||||
@@ -365,10 +382,35 @@ def create_post_with_files(page, content, files, expected_count=1):
|
||||
page.wait_for_url(f"{BASE_URL}/posts/*", wait_until="domcontentloaded")
|
||||
|
||||
|
||||
def open_action_menu(locator):
|
||||
target = locator.first
|
||||
target.evaluate(
|
||||
"""el => {
|
||||
const menu = el.closest("dp-action-menu");
|
||||
if (!menu) return;
|
||||
const panel = menu.querySelector("[data-action-menu-panel]");
|
||||
if (panel && panel.matches(":popover-open")) return;
|
||||
if (typeof menu.open === "function") {
|
||||
menu.open();
|
||||
return;
|
||||
}
|
||||
const trigger = menu.querySelector("[data-action-menu-trigger]");
|
||||
if (trigger) trigger.click();
|
||||
}"""
|
||||
)
|
||||
return target
|
||||
|
||||
|
||||
def click_menu_action(locator):
|
||||
target = open_action_menu(locator)
|
||||
target.click()
|
||||
return target
|
||||
|
||||
|
||||
def assert_share_copies(page, expected_fragment):
|
||||
from playwright.sync_api import expect
|
||||
|
||||
share = page.locator("button[data-share]").first
|
||||
share = open_action_menu(page.locator("button[data-share]"))
|
||||
share.scroll_into_view_if_needed()
|
||||
assert expected_fragment in (share.get_attribute("data-share") or ""), (
|
||||
f"data-share={share.get_attribute('data-share')!r}"
|
||||
|
||||
Reference in New Issue
Block a user