etherpad-lite/src/tests
John McLear 70415714e6
fix(socketio): don't kick authenticated duplicate-author sessions (#7656) (#7678)
* fix(socketio): don't kick authenticated duplicate-author sessions (#7656)

The CLIENT_READY handler kicks any prior socket whose authorID matches the
joining socket's, originally as a workaround for stale tabs in the same
browser (cookie-derived authorIDs were per-browser, so "same authorID, same
pad" reliably meant "page refresh / second tab in this browser").

With stable identities (basic auth, SSO, apikey, getAuthorId hook) the same
authorID can legitimately appear across windows or devices, so the kick
disconnects real concurrent sessions. Skip the kick when the joining socket
has req.session.user set; cookie-only sessions keep the existing behavior so
the userdup modal and the xxauto_reconnect path still work.

* fix(socketio): suppress USER_LEAVE when other same-author sockets remain

With the duplicate-author kick disabled for authenticated sessions, a single
authorID can legitimately span multiple sockets in one pad. handleDisconnect
was emitting USER_LEAVE on every socket close, which made clients (whose
presence is keyed by authorID) drop the author entirely even when another
socket of theirs was still online.

Only broadcast USER_LEAVE — and only run the userLeave hook — when the
disconnecting socket is the last one in the pad for that author.

Adds two backend tests:
- authenticated identity: closing one of two same-author sockets does NOT
  emit USER_LEAVE on the other.
- different authors (regression): closing socket A still emits USER_LEAVE
  for socket B.

Action of Qodo review feedback on PR #7678.
2026-05-06 20:08:36 +02:00
..
backend fix(socketio): don't kick authenticated duplicate-author sessions (#7656) (#7678) 2026-05-06 20:08:36 +02:00
backend-new feat(updater): tier 1 — notify admin and pad users of available updates (#7601) 2026-05-01 20:02:12 +08:00
container Feat/oauth2 (#6281): Added oauth to API paths 2024-03-26 17:11:24 +01:00
frontend fix: delay anchor line scrolling until layout settles (#7544) 2026-04-30 14:56:02 +08:00
frontend-new test: also tag userlist_click_to_chat describe with @feature:username (#7664) 2026-05-03 20:52:15 +08:00
ratelimit chore: updated clients to esm (#7627) 2026-04-28 21:46:49 +02:00
README.md restructure: move bin/ and tests/ to src/ 2021-02-04 17:15:08 -05:00
settings.json Add creator-owned pad settings defaults (#7545) 2026-04-19 11:13:44 +01:00

About this folder: Tests

Before running the tests, start an Etherpad instance on your machine.

Frontend

To run the frontend tests, point your browser to <yourdomainhere>/tests/frontend

Backend

To run the backend tests, run cd src and then npm test