"""Router tests - SharePlay endpoints.""" class TestCreateRoom: def test_create(self, client): r = client.post("/api/shareplay/create") assert r.status_code == 200 data = r.json() assert "id" in data assert data["creator_user"] == "user" assert data["active_connections"] == 1 class TestJoinRoom: def test_join(self, client): create = client.post("/api/shareplay/create") room_id = create.json()["id"] r = client.post("/api/shareplay/join", json={"room_id": room_id}) assert r.status_code == 200 assert r.json()["active_connections"] == 2 def test_join_not_found(self, client): r = client.post("/api/shareplay/join", json={"room_id": "nonexistent"}) assert r.status_code == 404 class TestLeaveRoom: def test_leave(self, client): create = client.post("/api/shareplay/create") room_id = create.json()["id"] r = client.post("/api/shareplay/leave", json={"room_id": room_id}) assert r.status_code == 200 def test_leave_not_found(self, client): r = client.post("/api/shareplay/leave", json={"room_id": "nonexistent"}) assert r.status_code == 404 class TestCue: def test_get_cue(self, client): r = client.get("/api/shareplay/cue?room_id=test") assert r.status_code == 200 data = r.json() assert "items" in data assert "next_song" in data class TestControl: def test_play(self, client): create = client.post("/api/shareplay/create") room_id = create.json()["id"] r = client.post("/api/shareplay/control", json={"room_id": room_id, "type": "play"}) assert r.status_code == 200 def test_pause(self, client): create = client.post("/api/shareplay/create") room_id = create.json()["id"] r = client.post("/api/shareplay/control", json={"room_id": room_id, "type": "pause"}) assert r.status_code == 200 def test_seek(self, client): create = client.post("/api/shareplay/create") room_id = create.json()["id"] r = client.post("/api/shareplay/control", json={ "room_id": room_id, "type": "seek", "payload": {"position": 42} }) assert r.status_code == 200 def test_shuffle(self, client): create = client.post("/api/shareplay/create") room_id = create.json()["id"] r = client.post("/api/shareplay/control", json={"room_id": room_id, "type": "shuffle"}) assert r.status_code == 200 def test_control_not_found(self, client): r = client.post("/api/shareplay/control", json={"room_id": "x", "type": "play"}) assert r.status_code == 404