Files
movim-rs/tests/e2e/e2e_reconnect.py
2026-10-24 14:03:52 +07:00

21 lines
1.1 KiB
Python

import os
import uuid
import asyncio, json, subprocess, time
from e2e import Client
S = os.path.dirname(os.path.abspath(__file__))
async def main():
alice = Client("alice@localhost", "alicepass"); bob = Client("bob@localhost", "bobpass")
await alice.login(); await bob.login()
print("logged in, restarting prosody")
subprocess.run([f"{S}/prosody.sh", "restart"], capture_output=True)
t = time.time()
await alice.recv_until(lambda m: m.get("func") == "MovimUtils.addClass" and m["p"][0] == "#status_websocket" and m["p"][1] == "hide", timeout=90)
await bob.recv_until(lambda m: m.get("func") == "MovimUtils.addClass" and m["p"][0] == "#status_websocket" and m["p"][1] == "hide", timeout=90)
print(f"both reconnected after {time.time()-t:.1f}s")
bob.ajax("Chat", "ajaxHttpDaemonSendMessage", [str(uuid.uuid4()), "alice@localhost", "after the restart", False], daemon=True)
await alice.recv_until(lambda m: m.get("func") == "Chat.appendMessagesWrapper" and "after the restart" in json.dumps(m), timeout=15)
print("alice receives messages after reconnection: OK")
asyncio.run(main())