Add required test suite and websocket fixes

This commit is contained in:
ameer
2026-05-02 03:08:48 +08:00
parent dfebfe2ee8
commit 63a03c0367
14 changed files with 516 additions and 29 deletions

View File

@@ -1,2 +1,22 @@
def test_placeholder_reconnect():
assert True
from conftest import create_session, join_student
def test_reconnect_replays_existing_submit_ack(client, sample_pool):
sid = create_session(client, sample_pool)
join_student(client, sid, "s1", "Student One")
rooms = client.app.state.rooms
client.portal.call(rooms.open_question, sid, 0, 2)
with client.websocket_connect(f"/ws/student/{sid}") as ws:
assert ws.receive_json()["type"] == "state"
assert ws.receive_json()["type"] == "question_open"
ws.send_json({"type": "submit", "question_idx": 0, "answer": "B"})
ack = ws.receive_json()
assert ack["type"] == "submit_ack"
with client.websocket_connect(f"/ws/student/{sid}") as ws:
assert ws.receive_json()["type"] == "state"
assert ws.receive_json()["type"] == "question_open"
replay = ws.receive_json()
assert replay["type"] == "submit_ack"
assert replay["score"] == ack["score"]