diff --git a/apps/mobile-shell/scripts/check-config.mjs b/apps/mobile-shell/scripts/check-config.mjs index 77ee460cd..56faf7445 100644 --- a/apps/mobile-shell/scripts/check-config.mjs +++ b/apps/mobile-shell/scripts/check-config.mjs @@ -1797,6 +1797,9 @@ for (const snippet of [ throw new Error(`mobile shell clipboard module is missing ${snippet}`); } } +if (!bridgeTestSource.includes("'猫'.repeat(100000)")) { + throw new Error('mobile shell clipboard tests must cover Unicode truncation'); +} if ( !hapticsSource.includes('normalizeHostBridgeHapticsImpactStyle(rawStyle)') || diff --git a/apps/mobile-shell/src/host-bridge/bridge.test.ts b/apps/mobile-shell/src/host-bridge/bridge.test.ts index 7b64f608b..e16da2256 100644 --- a/apps/mobile-shell/src/host-bridge/bridge.test.ts +++ b/apps/mobile-shell/src/host-bridge/bridge.test.ts @@ -709,6 +709,17 @@ describe('handleMobileHostBridgeMessage', () => { expect(expectOk(response).result).toBe(true); expect(Clipboard.setStringAsync).toHaveBeenCalledWith('a'.repeat(100000)); + + vi.mocked(Clipboard.setStringAsync).mockClear(); + + const unicodeResponse = await send( + request('clipboard.writeText', { + text: '猫'.repeat(100010), + }), + ); + + expect(expectOk(unicodeResponse).result).toBe(true); + expect(Clipboard.setStringAsync).toHaveBeenCalledWith('猫'.repeat(100000)); }); test('clipboard.readText 读取失败时返回 host_error', async () => {