Spaces:
Sleeping
Sleeping
Update tests/test_e2e.py
Browse files- tests/test_e2e.py +22 -0
tests/test_e2e.py
CHANGED
|
@@ -113,6 +113,28 @@ async def main():
|
|
| 113 |
"alice got global conversation in payload")
|
| 114 |
check(any(u["id"] == alice.user["id"] for u in ev_b["online_users"]), "bob sees alice online")
|
| 115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
# ---- global message + receipt round trip ----
|
| 117 |
await alice.send({"type": "send_message", "content": "hello everyone", "conversation_id": 1, "client_id": "c1"})
|
| 118 |
echo = await alice.expect("new_message")
|
|
|
|
| 113 |
"alice got global conversation in payload")
|
| 114 |
check(any(u["id"] == alice.user["id"] for u in ev_b["online_users"]), "bob sees alice online")
|
| 115 |
|
| 116 |
+
# ---- live presence stays in sync after profile changes ----
|
| 117 |
+
r = await http.patch(f"{BASE}/api/profile?display_name=AliceX",
|
| 118 |
+
headers={"X-Auth-Token": alice.token})
|
| 119 |
+
check(r.status_code == 200, "alice profile update ok")
|
| 120 |
+
pv = await bob.expect("profile_updated", 6)
|
| 121 |
+
check(pv["user_id"] == alice.user["id"] and pv["display_name"] == "AliceX",
|
| 122 |
+
"bob receives live profile update")
|
| 123 |
+
await bob.send({"type": "get_online_users"})
|
| 124 |
+
online = await bob.expect("online_users", 6)
|
| 125 |
+
alice_online = next((u for u in online["users"] if u["id"] == alice.user["id"]), None)
|
| 126 |
+
check(alice_online is not None and alice_online["display_name"] == "AliceX",
|
| 127 |
+
"online users list reflects updated profile")
|
| 128 |
+
|
| 129 |
+
# ---- disconnect must clear presence on other clients ----
|
| 130 |
+
await alice.drain(0.4) # clear the earlier "bob online" event
|
| 131 |
+
await bob.ws.close()
|
| 132 |
+
off = await alice.expect("user_status", 6)
|
| 133 |
+
check(off["user_id"] == bob.user["id"] and off["status"] == "offline",
|
| 134 |
+
"alice is notified when bob disconnects")
|
| 135 |
+
# reconnect bob so the rest of the suite can keep using him
|
| 136 |
+
await bob.connect()
|
| 137 |
+
|
| 138 |
# ---- global message + receipt round trip ----
|
| 139 |
await alice.send({"type": "send_message", "content": "hello everyone", "conversation_id": 1, "client_id": "c1"})
|
| 140 |
echo = await alice.expect("new_message")
|