Add short game join codes

This commit is contained in:
2026-07-10 12:30:43 -07:00
parent 8470da4aa9
commit b253a06b45
11 changed files with 189 additions and 3 deletions

View File

@@ -443,6 +443,11 @@ def test_game_creation_with_crew_name(session):
assert game.id is not None
assert game.crew_name == "The Black Gats"
assert game.phase == "lobby"
assert len(game.join_code) == 5
assert set(game.join_code) <= set("ABCDEFGHJKLMNPQRSTUVWXYZ23456789")
another = crud.create_game(session, crew_name="The Other Gats")
assert another.join_code != game.join_code
def test_create_game_endpoint():
from fastapi.testclient import TestClient
@@ -475,6 +480,17 @@ def test_create_game_endpoint():
games = session.exec(select(Game)).all()
assert len(games) == 1
assert games[0].crew_name == "The Math Mutineers"
# Codes are case-insensitive at the API boundary and resolve only
# active games without exposing the UUID in the code itself.
lookup = client.get(f"/api/game/code/{games[0].join_code.lower()}")
assert lookup.status_code == 200
assert lookup.json() == {"id": games[0].id}
games[0].phase = "ended"
session.add(games[0])
session.commit()
assert client.get(f"/api/game/code/{games[0].join_code}").status_code == 404
finally:
app.dependency_overrides.clear()