Files
hideck/web/tests/smsReceptionPresentation.test.ts
BFNOC c91ff20532 fix(imscore): await the Lebara UK P-CSCF after a port-s timeout
- Probe with a REGISTER after a Lebara UK port-s timeout and wait for the P-CSCF to reopen port-s once it succeeds
- Keep SMS readiness true with its own reasons while probing and waiting
- Bind the wait and the probe grace to the timed-out port-s generation and P-CSCF, and drop them on a new registration
- Send another probe REGISTER when port-s timed out while an earlier REGISTER was in flight
- End the wait when a REGISTER fails or a refresh negotiates an outbound flow, and the probe grace when recovery backs off
- Count a peer reopen during the wait as on-demand evidence only when no REGISTER is in flight
- Mirror sipOutbound into an atomic and clear the post-REGISTER wait flag on every port-s close
- Log entering, declining and ending the wait, each REGISTER during it and probe retries with the carrier preset and peer reconnect history
- Show in the web UI that SMS reception waits for the carrier to reopen port-s
- Add tests for the Lebara UK wait, probes, failures, stale states, outbound and carriers outside the list
2026-10-29 00:47:52 +08:00

46 lines
2.7 KiB
TypeScript

import assert from 'node:assert/strict'
import test from 'node:test'
import { createDashboardStages } from '../src/utils/dashboardPresentation.ts'
import { smsReceptionDetail, smsReceptionPending } from '../src/utils/smsReceptionPresentation.ts'
test('unverified SMS RX is neutral, while SMS TX remains usable', () => {
const runtime = { ims_ready: true, sms_ready: false, sms_mo_ready: true, sms_rx_pending: true }
const stages = createDashboardStages(runtime)
assert.deepEqual(stages[4], { key: 'SMS TX', ready: true })
assert.deepEqual(stages[5], { key: 'SMS RX', ready: undefined, pending: true })
assert.equal(smsReceptionDetail(runtime), 'IMS 已注册,短信接收待验证')
assert.equal(smsReceptionPending({ ...runtime, ims_ready: false }), false)
})
test('an explicit reception failure stays failed', () => {
const runtime = { ims_ready: true, sms_ready: false, sms_rx_pending: false }
assert.equal(createDashboardStages(runtime)[5]?.ready, false)
assert.equal(smsReceptionDetail(runtime), '')
})
test('a closed or timed-out port-s is neutral until the P-CSCF reconnects', () => {
const runtime = { ims_ready: true, sms_ready: false, sms_mo_ready: true, sms_rx_pending: false,
sms_ready_reason: 'IMS registered; port-s closed or timed out, awaiting the P-CSCF reconnect' }
assert.deepEqual(createDashboardStages(runtime)[5], { key: 'SMS RX', ready: undefined, pending: true })
assert.equal(smsReceptionDetail(runtime), '端口已断,等运营商连入')
assert.equal(smsReceptionPending({ ...runtime, ims_ready: false }), false)
assert.equal(createDashboardStages({ ...runtime, sms_ready_reason: 'IMS SMS receiver is not ready' })[5]?.ready, false)
})
test('verified registered-flow reception describes its actual route', () => {
const runtime = { ims_ready: true, sms_ready: true, sms_rx_pending: false,
sms_ready_reason: 'IMS SMS receiver verified on registered TCP flow' }
assert.equal(createDashboardStages(runtime)[5]?.ready, true)
assert.equal(smsReceptionDetail(runtime), '短信接收已验证,复用注册连接')
})
test('reception awaiting an on-demand port-s says so', () => {
const runtime = { ims_ready: true, sms_ready: true, sms_rx_pending: false,
sms_ready_reason: 'IMS SMS receiver ready; port-s timed out, P-CSCF reconnects on demand' }
assert.equal(createDashboardStages(runtime)[5]?.ready, true)
assert.equal(smsReceptionDetail(runtime), '端口已断,等运营商按需连入')
const probing = { ...runtime, sms_ready_reason: 'IMS SMS receiver ready; port-s timed out, REGISTER probing the P-CSCF' }
assert.equal(createDashboardStages(probing)[5]?.ready, true)
assert.equal(smsReceptionDetail(probing), '端口已断,等运营商按需连入')
})