Skip to content

A platform for community discussion. Free, open, simple.

2.8 KB
Raw Blame

Local fake participants for Live

This developer-only harness opens several Playwright browser contexts, logs each one in as a bot user, injects fake camera/audio/screen-share media, and joins a Live room. It is meant for local interactive WebRTC testing, not CI.

Quick start

From the plugin checkout:

pnpm install
DISCOURSE_URL=http://localhost:4200 ROOM=watercooler BOT_COUNT=3 \
  pnpm live:bots -- --headed --screenshots

By default the harness uses Discourse's development/test-only /session/:username/become.json login route. That means the named users must already exist and the target site must allow that route.

Bot config

If .local/live-bots.json exists, it is used instead of generated live_bot_N usernames.

Create it from the example:

mkdir -p .local
cp docs/examples/live-bots.example.json .local/live-bots.json

Example:

[
  {
    "username": "live_bot_1",
    "label": "Alice fake camera",
    "color": "#2563eb",
    "accent": "#f97316"
  },
  {
    "username": "live_bot_2",
    "label": "Bob fake camera",
    "color": "#16a34a",
    "accent": "#7c3aed"
  }
]

You can also pass JSON directly:

LIVE_BOTS_JSON='[{"username":"alice"},{"username":"bob"}]' \
  DISCOURSE_URL=http://localhost:4200 ROOM=watercooler pnpm live:bots -- --headed

Useful options

pnpm live:bots -- --help

Common flags:

  • --headed: show browser windows.
  • --screenshots: write screenshots to tmp/live-bots/.
  • --trace: write Playwright trace zips to tmp/live-bots/.
  • --record-video: write Playwright videos to tmp/live-bots/.
  • --screen-share-bot 1: make the first bot start fake screen share.
  • --hold-ms 30000: auto-close after 30 seconds; otherwise runs until Ctrl-C.
  • --no-camera: join without immediately starting camera.

Password login mode

For non-development sites, use password login with credentials in the ignored local file:

[
  { "username": "live_bot_1", "password": "local-only-password" },
  { "username": "live_bot_2", "password": "local-only-password" }
]

Then run:

LOGIN_MODE=password DISCOURSE_URL=https://example.test ROOM=watercooler \
  pnpm live:bots -- --headed

Do not commit real credentials.

Notes

  • The harness works unchanged against rooms routed through a LiveKit server: the plugin acquires media itself (through these same fakes) and hands the SDK finished tracks, so livekit-client never calls getUserMedia.
  • Each bot uses a distinct canvas-backed camera stream with a visible label and animated frame marker.
  • Audio is a very-low-gain oscillator so the browser sees a real audio track without audible noise.
  • getDisplayMedia returns a separate fake screen-share canvas derived from the bot feed.
  • Browser logs are echoed with the bot username prefix.