Files
devplacepy/tests/e2e/posts/requested.py
T
retoor 8a48e3ef85 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.
2026-11-12 15:29:27 +01:00

100 lines
3.5 KiB
Python

# retoor <retoor@molodetz.nl>
import time
from playwright.sync_api import expect
from tests.conftest import BASE_URL
JSON = {"Accept": "application/json"}
def _create_post(page, content):
page.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
page.locator(".feed-fab").first.wait_for(state="visible", timeout=10000)
page.locator(".feed-fab").first.click()
page.fill("#post-title", f"Requested {int(time.time() * 1000)}")
page.fill("#post-content", content)
page.locator("#create-post-modal button.btn-primary:has-text('Post')").click()
page.wait_for_url(f"{BASE_URL}/posts/*", wait_until="domcontentloaded")
def test_title_is_first_and_focused(alice):
page, _user = alice
page.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
page.locator(".feed-fab").first.wait_for(state="visible", timeout=10000)
page.locator(".feed-fab").first.click()
title = page.locator("#post-title")
expect(title).to_be_focused()
order = page.evaluate(
"""() => {
const title = document.querySelector('#post-title');
const content = document.querySelector('#post-content');
return (title.compareDocumentPosition(content) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0;
}"""
)
assert order is True
def test_post_detail_groups_secondary_actions_in_more_menu(alice):
page, _user = alice
_create_post(page, "Menu grouping post content.")
expect(page.locator(".post-votes")).to_be_visible()
expect(page.locator("[data-action-menu-trigger]")).to_be_visible()
panel = page.locator("#post-actions-panel")
expect(panel).to_be_hidden()
page.locator("[data-action-menu-trigger]").click()
expect(panel).to_be_visible()
expect(panel.locator("[data-share]")).to_be_visible()
expect(panel.locator(".bookmark-btn")).to_be_visible()
page.keyboard.press("Escape")
expect(panel).to_be_hidden()
def test_comment_enter_posts_and_shift_enter_newlines(alice):
page, user = alice
username = user["username"]
try:
_create_post(page, "Enter key comment post content.")
box = page.locator(".comment-form textarea[name='content']").first
box.click()
box.fill("First line")
box.press("Shift+Enter")
box.type("second line")
assert "\n" in box.input_value()
box.fill("Posted by Enter key")
box.press("Enter")
expect(page.locator(".comment-text", has_text="Posted by Enter key").first).to_be_visible(timeout=10000)
finally:
page.request.post(
f"{BASE_URL}/profile/{username}/enter-to-submit",
form={"value": "true"},
headers=JSON,
)
def test_comment_enter_newlines_when_setting_off(alice):
page, user = alice
username = user["username"]
resp = page.request.post(
f"{BASE_URL}/profile/{username}/enter-to-submit",
form={"value": "false"},
headers=JSON,
)
assert resp.status == 200
try:
_create_post(page, "Enter off comment post content.")
box = page.locator(".comment-form textarea[name='content']").first
box.click()
box.fill("Not posted yet")
box.press("Enter")
box.type("still editing")
assert "still editing" in box.input_value()
expect(page.locator(".comment-text", has_text="Not posted yet")).to_have_count(0)
finally:
page.request.post(
f"{BASE_URL}/profile/{username}/enter-to-submit",
form={"value": "true"},
headers=JSON,
)