LiveState loads extension states and registered devices from Asterisk on every AMI connect and follows ExtensionStatus/ContactStatus; the hub sends a snapshot then deltas batched every 250 ms (devices for admins only), pings every 30 s and closes unauthenticated sockets with 4401. The web UI keeps one reconnecting socket in a zustand store, shows a Reconnecting banner, a Dashboard (online, on a call, telephony engine) and status dots. Fix: Asterisk 24 has no 'pjsip reload'; reload with 'module reload res_pjsip.so'. AMI errors now carry the CLI output. Milestone check, automated: call-test.ts registers two baresip phones and holds a 30 s call with RTP both ways (pnpm test:asterisk); the recorded session drives the live-state tests. scripts/e2e/m2-live.mjs runs api + Asterisk + phones + browser on a private Docker network: a new extension is live in Asterisk in ~1.3 s, the dashboard shows 2/2 online and red dots during the call. Task: M2-T6
34 lines
1.7 KiB
Markdown
34 lines
1.7 KiB
Markdown
# Browser checks
|
|
|
|
Dependency-free scripts that drive a headless Chromium (Edge/Chrome) over the DevTools
|
|
protocol. They need an api serving the built web UI and a fresh database.
|
|
|
|
```sh
|
|
pnpm --filter @selfphoneng/web build && mkdir -p /tmp/sp && cp -r apps/web/dist /tmp/sp/public
|
|
# fresh DB, then from /tmp/sp:
|
|
DATABASE_URL=postgres://… INITIAL_ADMIN_EMAIL=admin@example.com INITIAL_ADMIN_PASSWORD=initial-admin-pw \
|
|
node --env-file=<repo>/.env --conditions=source <repo>/apps/api/src/index.ts
|
|
BROWSER=/usr/bin/chromium node scripts/e2e/m1-t4.mjs http://127.0.0.1:8080 admin@example.com initial-admin-pw /tmp/shots
|
|
node scripts/e2e/mobile.mjs http://127.0.0.1:8080 admin@example.com correct-horse-battery-staple /tmp/shots
|
|
```
|
|
|
|
`m1-t4.mjs` is the M1-T4 acceptance flow: forced password change, then create/edit/delete a user.
|
|
|
|
## M2 live loop (any Docker host, no host networking)
|
|
|
|
`m2-live.mjs` runs the whole chain on a private Docker network: a test Asterisk with AMI published
|
|
on `127.0.0.1:15038`, the api writing config into it, two baresip phones, and the dashboard in a
|
|
browser. It checks that a new extension is live in Asterisk within 2 s, both phones show online,
|
|
and the dots turn red during a call.
|
|
|
|
```sh
|
|
node scripts/e2e/m2-live.mjs up /tmp/sp-live-conf
|
|
# start the api with AMI_PORT=15038 AMI_SECRET=m2-live-secret ASTERISK_CONFIG_DIR=/tmp/sp-live-conf
|
|
node scripts/e2e/m1-t4.mjs http://127.0.0.1:8080 admin@example.com initial-admin-pw /tmp/shots
|
|
node scripts/e2e/m2-live.mjs check http://127.0.0.1:8080 admin@example.com correct-horse-battery-staple /tmp/shots
|
|
node scripts/e2e/m2-live.mjs down
|
|
```
|
|
|
|
`pnpm test:asterisk` (golden-file load test plus `call-test.ts`, 30 s two-way audio between two
|
|
baresip phones) needs no api at all.
|