forked from retoor/devplacepy
Updpdate
This commit is contained in:
+54
-1
@@ -176,7 +176,7 @@ def test_send_message_appears_in_thread(alice):
|
||||
f"{BASE_URL}/messages?with_uid={bob['uid']}", wait_until="domcontentloaded"
|
||||
)
|
||||
msg = f"Hello bob {int(time.time() * 1000)}"
|
||||
page.fill("input[name='content']", msg)
|
||||
page.fill("textarea[name='content']", msg)
|
||||
page.locator(".messages-send-btn").click()
|
||||
page.wait_for_url("**/messages**", wait_until="domcontentloaded")
|
||||
page.locator(f".message-bubble:has-text('{msg}')").first.wait_for(state="visible")
|
||||
@@ -290,3 +290,56 @@ def test_messages_page_is_noindex(alice):
|
||||
meta = page.locator('meta[name="robots"]')
|
||||
content = meta.get_attribute("content")
|
||||
assert content and "noindex" in content
|
||||
|
||||
|
||||
def test_optimistic_send_pending_then_reconciles_no_double_render(alice, bob):
|
||||
page_a, user_a = alice
|
||||
page_b, user_b = bob
|
||||
uid_a = get_table("users").find_one(username=user_a["username"])["uid"]
|
||||
uid_b = get_table("users").find_one(username=user_b["username"])["uid"]
|
||||
|
||||
page_a.goto(
|
||||
f"{BASE_URL}/messages?with_uid={uid_b}", wait_until="domcontentloaded"
|
||||
)
|
||||
page_b.goto(
|
||||
f"{BASE_URL}/messages?with_uid={uid_a}", wait_until="domcontentloaded"
|
||||
)
|
||||
|
||||
msg = f"Optimistic hello {int(time.time() * 1000)}"
|
||||
textarea = page_a.locator(".messages-input-area textarea[name='content']")
|
||||
textarea.wait_for(state="visible")
|
||||
textarea.fill(msg)
|
||||
page_a.locator(".messages-send-btn").click()
|
||||
|
||||
pending = page_a.locator(f".message-bubble.mine.pending:has-text('{msg}')")
|
||||
pending.wait_for(state="visible", timeout=5000)
|
||||
client_id = pending.get_attribute("data-client-id")
|
||||
assert client_id
|
||||
|
||||
reconciled = page_a.locator(
|
||||
f".message-bubble.mine[data-client-id='{client_id}'][data-msg-uid]:not(.pending)"
|
||||
)
|
||||
reconciled.wait_for(state="visible", timeout=6000)
|
||||
|
||||
received = page_b.locator(f".message-bubble.theirs:has-text('{msg}')")
|
||||
received.wait_for(state="visible", timeout=6000)
|
||||
assert received.count() == 1
|
||||
|
||||
|
||||
def test_mobile_single_pane_back_button(mobile_page):
|
||||
page, user = mobile_page
|
||||
bob = get_table("users").find_one(username="bob_test")
|
||||
page.goto(
|
||||
f"{BASE_URL}/messages?with_uid={bob['uid']}", wait_until="domcontentloaded"
|
||||
)
|
||||
|
||||
thread = page.locator(".messages-main")
|
||||
conv_list = page.locator(".messages-list")
|
||||
thread.wait_for(state="visible")
|
||||
expect(conv_list).to_be_hidden()
|
||||
|
||||
page.locator("#messages-back-btn").click()
|
||||
|
||||
expect(conv_list).to_be_visible()
|
||||
expect(thread).to_be_hidden()
|
||||
assert page.url == f"{BASE_URL}/messages"
|
||||
|
||||
@@ -440,7 +440,7 @@ def test_message_notification(app_server, browser, seeded_db):
|
||||
pb.goto(f"{BASE_URL}/messages?search=alice_test", wait_until="domcontentloaded")
|
||||
pb.wait_for_timeout(2000)
|
||||
|
||||
msg_input = pb.locator("input[name='content']").first
|
||||
msg_input = pb.locator("textarea[name='content']").first
|
||||
msg_input.wait_for(state="visible", timeout=10000)
|
||||
msg_input.fill("Hello from bob_test!")
|
||||
pb.locator("button[type='submit']").last.click()
|
||||
@@ -753,7 +753,7 @@ def test_message_notification_click_opens_conversation(app_server, browser, seed
|
||||
|
||||
pb.goto(f"{BASE_URL}/messages?search=alice_test", wait_until="domcontentloaded")
|
||||
pb.wait_for_timeout(2000)
|
||||
msg_input = pb.locator("input[name='content']").first
|
||||
msg_input = pb.locator("textarea[name='content']").first
|
||||
msg_input.wait_for(state="visible", timeout=10000)
|
||||
msg_input.fill("Click-through message from bob")
|
||||
pb.locator("button[type='submit']").last.click()
|
||||
|
||||
Reference in New Issue
Block a user