chore: 保存工作副本——客户端授权新契约(双端点/验签/令牌/周检)与桌面会话可靠性改进
This commit is contained in:
1 parent
f71eef0eba
commit
ae6093c9b3
163 files changed
+4911
-2494
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
classifyDisconnectReason,
|
||||
reconnectDelayMs,
|
||||
shouldAutoReconnect,
|
||||
shouldForgetNativeConnection,
|
||||
} from '../../src/utils/disconnectReason'
|
||||
|
||||
describe('classifyDisconnectReason', () => {
|
||||
it('treats keepalive failure as a link drop that should reconnect', () => {
|
||||
expect(classifyDisconnectReason('keepalive failed')).toBe('keepalive')
|
||||
expect(shouldAutoReconnect('keepalive')).toBe(true)
|
||||
})
|
||||
|
||||
it('does not treat the legacy native default as a user click', () => {
|
||||
expect(classifyDisconnectReason('closed by user')).toBe('unexpected')
|
||||
expect(classifyDisconnectReason('connection closed')).toBe('unexpected')
|
||||
expect(shouldAutoReconnect('unexpected')).toBe(true)
|
||||
})
|
||||
|
||||
it('skips auto-reconnect for local policy and teardown', () => {
|
||||
expect(classifyDisconnectReason('idle suspend')).toBe('idle-suspend')
|
||||
expect(shouldAutoReconnect('idle-suspend')).toBe(false)
|
||||
expect(shouldForgetNativeConnection('idle-suspend')).toBe(false)
|
||||
|
||||
expect(classifyDisconnectReason('manual')).toBe('user')
|
||||
expect(classifyDisconnectReason('no refs')).toBe('user')
|
||||
expect(classifyDisconnectReason('auto reconnect cleanup')).toBe('cleanup')
|
||||
expect(shouldAutoReconnect('user')).toBe(false)
|
||||
expect(shouldAutoReconnect('cleanup')).toBe(false)
|
||||
})
|
||||
|
||||
it('backs off reconnect delay', () => {
|
||||
expect(reconnectDelayMs(1, 1000)).toBe(1000)
|
||||
expect(reconnectDelayMs(2, 1000)).toBe(1600)
|
||||
expect(reconnectDelayMs(20, 1000, 5000)).toBe(5000)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user