forked from retoor/devplacepy
feat: add structured data schemas, og tags, share button, and configurable site url
This commit is contained in:
+19
-3
@@ -25,6 +25,7 @@ _TEST_DB.close()
|
||||
os.environ["DEVPLACE_DATABASE_URL"] = f"sqlite:///{_TEST_DB.name}"
|
||||
os.environ["SECRET_KEY"] = "test-secret-key"
|
||||
os.environ["DEVPLACE_DISABLE_SERVICES"] = "1"
|
||||
os.environ["DEVPLACE_RATE_LIMIT"] = "1000000"
|
||||
|
||||
|
||||
def save_failure_screenshot(page, test_name):
|
||||
@@ -117,14 +118,14 @@ def playwright_instance():
|
||||
def browser(playwright_instance):
|
||||
headless = os.environ.get("PLAYWRIGHT_HEADLESS", "1") == "1"
|
||||
b = playwright_instance.chromium.launch(
|
||||
headless=headless, slow_mo=300, args=["--window-size=1400,900"],
|
||||
headless=headless, slow_mo=int(os.environ.get("PLAYWRIGHT_SLOW_MO", "0")), args=["--window-size=1400,900"],
|
||||
)
|
||||
yield b
|
||||
b.close()
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def browser_context(browser):
|
||||
ctx = browser.new_context(viewport={"width": 1400, "height": 900})
|
||||
ctx = browser.new_context(viewport={"width": 1400, "height": 900}, permissions=["clipboard-read", "clipboard-write"])
|
||||
yield ctx
|
||||
ctx.close()
|
||||
|
||||
@@ -158,6 +159,21 @@ def login_user(page, user):
|
||||
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
|
||||
|
||||
|
||||
def assert_share_copies(page, expected_fragment):
|
||||
from playwright.sync_api import expect
|
||||
share = page.locator("button[data-share]").first
|
||||
share.scroll_into_view_if_needed()
|
||||
share.click()
|
||||
expect(share).to_have_text("Copied!", timeout=3000)
|
||||
expect(share).not_to_have_text("Copied!", timeout=3000)
|
||||
try:
|
||||
clip = page.evaluate("navigator.clipboard.readText()")
|
||||
except Exception:
|
||||
clip = None
|
||||
if clip:
|
||||
assert clip.startswith("http") and expected_fragment in clip, f"clipboard={clip!r}"
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def seeded_db(app_server):
|
||||
"""Create test users once at session level using requests directly."""
|
||||
@@ -192,7 +208,7 @@ def alice(page, seeded_db):
|
||||
|
||||
@pytest.fixture
|
||||
def bob(browser, seeded_db):
|
||||
ctx = browser.new_context(viewport={"width": 1400, "height": 900})
|
||||
ctx = browser.new_context(viewport={"width": 1400, "height": 900}, permissions=["clipboard-read", "clipboard-write"])
|
||||
p = ctx.new_page()
|
||||
p.set_default_timeout(15000)
|
||||
p.bring_to_front()
|
||||
|
||||
Reference in New Issue
Block a user