Update PresenceDO tests to match the view-only guest model

Aperta
#1,126 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python

Direzione di ricerca

Start by running the suite with cd learn && python -m pytest -q to see the 20 failures in learn/tests/test_presence_do.py. Read PresenceDO in learn/src/worker.py (around line 7775) to confirm that ?user_id= sockets are spectators and never enter self.presence, and reuse create_token and the jwt_secret in _make_presence_env for interactive joins. Done means all tests pass, new tests cover spectator acceptance without presence membership and ignored messages plus a 401 for an invalid token, and no ALLOW_ANON_PRESENCE references remain.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

2026-11 good first issue gsoc-2027 project: learn tests
Context

20 tests in learn/tests/test_presence_do.py fail. They were written for an older PresenceDO (learn/src/worker.py ~line 7775) that read an ALLOW_ANON_PRESENCE env flag and added anonymous ?user_id= joiners to presence.

The current code no longer reads ALLOW_ANON_PRESENCE. A socket with a valid ?token= is an interactive participant; a socket with only ?user_id= is accepted as a view-only spectator (can_interact = False) and is never added to self.presence. So tests such as test_accepts_anon_join (expects "bob" in do.presence) and test_rejects_when_anon_disabled_even_with_user_id (expects 401) now fail, and the message/disconnect tests fail because their helpers join as anonymous users.

Run the suite with cd learn && pip install pytest pytest-asyncio && python -m pytest -q (no Cloudflare account needed; tests/conftest.py stubs the Workers runtime).

What to do
  • Change the test helpers so interactive users join with a signed token (see create_token in worker.py and the existing jwt_secret in _make_presence_env).
  • Rewrite the anonymous-join tests to assert spectator behaviour: socket accepted (101), receives the welcome state, is not in presence, and its position/emoji/hand-raise messages are ignored.
  • Remove ALLOW_ANON_PRESENCE from the test env helpers, and delete or rewrite tests that only exercised that flag.
  • If you believe spectators should be rejected instead, say so in the issue before writing code; don't change PresenceDO behaviour in this PR.
Acceptance criteria
  • All tests in test_presence_do.py pass.
  • New tests cover: spectator accepted but not in presence, spectator messages ignored, and an invalid token rejected with 401.
  • No ALLOW_ANON_PRESENCE references remain in tests.
Files
  • learn/tests/test_presence_do.py
  • learn/src/worker.py (class PresenceDO, ~lines 7775-7990)
Helpful links

Part of GSoC 2027 onboarding — see https://gsoc.alphaonelabs.com

Lingua principale
HTML
Stelle
66
Fork
181
Merge medio
2m
PR unite (30g)
9

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di alphaonelabs/website

Tutte le issue di alphaonelabs/website

Issue simili

Altre issue su Backend & API Design

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.