Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(mobile): 保留安卓语音 E2E 测试入口

DavidShen31a0ebff5699
diff --git a/apps/mobile/src/__tests__/mobileRealtimeAudio.test.ts b/apps/mobile/src/__tests__/mobileRealtimeAudio.test.ts
index aa9e571d72..c901b895e7 100644
--- a/apps/mobile/src/__tests__/mobileRealtimeAudio.test.ts
+++ b/apps/mobile/src/__tests__/mobileRealtimeAudio.test.ts
@@ -1,6 +1,6 @@
import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';
-import { describe, expect, it, vi } from 'vitest';
+import { afterEach, describe, expect, it, vi } from 'vitest';
vi.mock('expo-modules-core', () => ({
EventEmitter: class {
@@ -19,6 +19,10 @@ vi.mock('expo-modules-core', () => ({
}),
}));
+afterEach(() => {
+ vi.unstubAllEnvs();
+});
+
describe('mobileRealtimeAudio', () => {
it('decodes native PCM base64 payloads into ArrayBuffer chunks', async () => {
const { __testing } = await import('@/session/mobileRealtimeAudio');
@@ -42,11 +46,19 @@ describe('mobileRealtimeAudio', () => {
.rejects.toThrow('realtime microphone PCM capture');
});
- it('hides voice UI on Android without changing the supported iOS surface', async () => {
+ it('hides voice UI on Android without changing existing non-Android surfaces', async () => {
const { shouldShowMobileVoiceUi } = await import('@/session/mobileRealtimeAudio');
expect(shouldShowMobileVoiceUi('android')).toBe(false);
expect(shouldShowMobileVoiceUi('ios')).toBe(true);
+ expect(shouldShowMobileVoiceUi('web')).toBe(true);
+ });
+
+ it('keeps the Android voice entry available to explicit E2E mock runs', async () => {
+ vi.stubEnv('EXPO_PUBLIC_XDT_MOBILE_E2E_MOCK_AUDIO', '1');
+ const { shouldShowMobileVoiceUi } = await import('@/session/mobileRealtimeAudio');
+
+ expect(shouldShowMobileVoiceUi('android')).toBe(true);
});
it('keeps the iOS native realtime recorder wired for interruption cleanup', () => {
diff --git a/apps/mobile/src/session/mobileRealtimeAudio.ts b/apps/mobile/src/session/mobileRealtimeAudio.ts
index a6f001b36d..7886894f66 100644
--- a/apps/mobile/src/session/mobileRealtimeAudio.ts
+++ b/apps/mobile/src/session/mobileRealtimeAudio.ts
@@ -66,6 +66,7 @@ export function isMobileRealtimeAudioAvailable(): boolean {
export function shouldShowMobileVoiceUi(
platform: string,
): boolean {
+ if (isE2eMockRealtimeAudioEnabled()) return true;
return platform !== 'android';
}