Files
devplacepy/tests/e2e/posts/visibility.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

106 lines
3.9 KiB
Python

# retoor <retoor@molodetz.nl>
import time
from playwright.sync_api import expect
from tests.conftest import BASE_URL, assert_no_horizontal_overflow, click_menu_action
def _unique():
return f"vispost{int(time.time() * 1000)}"
def _compose(page, token, visibility=None):
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-content", f"visibility e2e body {token}")
if visibility:
page.select_option("#composer-visibility", visibility)
page.locator("#create-post-modal button.btn-primary:has-text('Post')").click()
page.wait_for_url(f"{BASE_URL}/posts/*", wait_until="domcontentloaded")
return page.url
def _edit_visibility(page, url, value):
page.goto(url, wait_until="domcontentloaded")
click_menu_action(page.locator("#post-actions-panel [data-modal='edit-post-modal']"))
page.select_option("#edit-post-visibility", value)
page.locator("#edit-post-form button.btn-primary").click()
page.wait_for_url(url, wait_until="domcontentloaded")
def _feed_has(page, token):
page.goto(f"{BASE_URL}/feed?search={token}", wait_until="domcontentloaded")
return page.locator(f"text={token}").count() > 0
def test_new_post_defaults_to_published(alice):
page, _ = alice
token = _unique()
url = _compose(page, token)
click_menu_action(page.locator("#post-actions-panel [data-modal='edit-post-modal']"))
expect(page.locator("#edit-post-visibility")).to_have_value("published")
assert _feed_has(page, token)
page.goto(url, wait_until="domcontentloaded")
def test_composer_offers_the_three_user_choices(alice):
page, _ = alice
page.goto(f"{BASE_URL}/feed", wait_until="domcontentloaded")
page.locator(".feed-fab").first.click()
options = page.locator("#composer-visibility option")
assert options.all_text_contents() == ["Published", "Hidden", "Offline"]
expect(page.locator("#composer-visibility")).to_have_value("published")
def test_create_hidden_post_leaves_the_feed(alice):
page, _ = alice
token = _unique()
url = _compose(page, token, "hidden")
click_menu_action(page.locator("#post-actions-panel [data-modal='edit-post-modal']"))
expect(page.locator("#edit-post-visibility")).to_have_value("hidden")
assert not _feed_has(page, token)
page.goto(url, wait_until="domcontentloaded")
expect(page.locator(f"text={token}").first).to_be_visible()
def test_edit_form_toggles_visibility_and_the_feed_follows(alice):
page, _ = alice
token = _unique()
url = _compose(page, token)
assert _feed_has(page, token)
_edit_visibility(page, url, "offline")
assert not _feed_has(page, token)
_edit_visibility(page, url, "published")
assert _feed_has(page, token)
def test_offline_post_is_not_shown_to_other_members(alice, bob):
page, _ = alice
other, _ = bob
token = _unique()
url = _compose(page, token)
_edit_visibility(page, url, "offline")
other.goto(url, wait_until="domcontentloaded")
assert other.locator(f"text={token}").count() == 0
_edit_visibility(page, url, "hidden")
other.goto(url, wait_until="domcontentloaded")
expect(other.locator(f"text={token}").first).to_be_visible()
assert not _feed_has(other, token)
def test_edit_form_lists_the_three_choices(alice):
page, _ = alice
_compose(page, _unique())
click_menu_action(page.locator("#post-actions-panel [data-modal='edit-post-modal']"))
options = page.locator("#edit-post-visibility option")
assert options.all_text_contents() == ["Published", "Hidden", "Offline"]
def test_visibility_field_fits_a_phone(mobile_page):
page, _ = mobile_page
_compose(page, _unique(), "hidden")
click_menu_action(page.locator("#post-actions-panel [data-modal='edit-post-modal']"))
expect(page.locator("#edit-post-visibility")).to_be_visible()
assert_no_horizontal_overflow(page, ".post-page")