Files
devplacepy/tests/e2e/comments/copylink.py
T

29 lines
1.1 KiB
Python
Raw Normal View History

# retoor <retoor@molodetz.nl>
from playwright.sync_api import expect
from tests.e2e.post import create_post
def test_comment_copy_link_button(alice):
page, _ = alice
create_post(page, "devlog", "Post for comment permalink test")
textarea = page.locator(".comment-form textarea[name='content']")
textarea.fill("Comment for permalink test")
page.locator(".comment-form button:has-text('Post')").click()
comment_text = page.locator(".comment-text:has-text('Comment for permalink test')")
expect(comment_text).to_be_visible()
wrapper = page.locator(".comment-body", has=comment_text)
comment_uid = wrapper.get_attribute("data-comment-uid")
assert comment_uid
copy_btn = page.locator(f".comment-action-btn[data-share='#comment-{comment_uid}']")
expect(copy_btn).to_be_visible()
copy_btn.click()
expect(copy_btn).to_have_text("Copied!", timeout=3000)
expect(copy_btn).not_to_have_text("Copied!", timeout=3000)
try:
clip = page.evaluate("navigator.clipboard.readText()")
except Exception:
clip = None
if clip:
assert clip.endswith(f"#comment-{comment_uid}"), f"clipboard={clip!r}"