Import apps/android/tests/connection.test.ts

This commit is contained in:
QQ 2026-11-17 08:35:18 +08:00
parent 5eb3c91c45
commit 990f84e0d0
1 changed files with 12 additions and 0 deletions

View File

@ -1,3 +1,4 @@
vi.mock('expo', () => ({ requireOptionalNativeModule: () => undefined }))
import { runScenarios, scenarioName } from '../../../scripts/test-scenarios.mjs'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import type { AdaptiveTransportOptions } from '@dsh-remote/webrtc'
@ -108,6 +109,17 @@ afterEach(async () => {
vi.useRealTimers()
})
it('scopes binary upload support to the current Host and clears it on close', async () => {
const connection = new AndroidRemoteConnection()
for (const binary of [false, true, false]) {
testState.capabilities = ['harness.remote.v1', 'workspace.upload.v1', ...(binary ? ['workspace.upload.binary.v1'] : [])]
await connection.connect('https://server.example.com', identity, host, 'synthetic', () => undefined)
expect(connection.supportsBinaryUpload()).toBe(binary)
}
await connection.close()
expect(connection.supportsBinaryUpload()).toBe(false)
})
it('gives TURN-only attempts an allocation budget without slowing automatic routing', async () => {
await runScenarios([
{ name: 'automatic', preferred: ['lan', 'p2p', 'turn', 'relay'] as const, timeout: 6000 },