test(telegram): fold draft preview surrogate clamp coverage · openclaw/openclaw@a3b4e81
obviyus
·
2026-06-26
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -807,29 +807,15 @@ describe("createTelegramDraftStream", () => {
|
807 | 807 | expectNthPreviewSend(api, 2, "foo bar baz qux"); |
808 | 808 | }); |
809 | 809 | |
810 | | -it("clamps a first oversized non-final preview", async () => { |
811 | | -const api = createMockDraftApi(); |
812 | | -const stream = createDraftStream(api, { maxChars: 10 }); |
813 | | - |
814 | | -stream.update("1234567890ABCDEFGHIJ"); |
815 | | -await stream.flush(); |
816 | | - |
817 | | -expect(api.sendMessage).toHaveBeenCalledTimes(1); |
818 | | -expectNthPreviewSend(api, 1, "1234567890"); |
819 | | -expect(stream.lastDeliveredText?.()).toBe("1234567890"); |
820 | | -}); |
821 | | - |
822 | | -it("does not split surrogate pairs when clamping a first oversized non-final preview", async () => { |
| 810 | +it("clamps a first oversized non-final preview on a UTF-16 boundary", async () => { |
823 | 811 | const api = createMockDraftApi(); |
824 | 812 | const stream = createDraftStream(api, { maxChars: 10 }); |
825 | 813 | |
826 | 814 | stream.update("123456789😀tail"); |
827 | 815 | await stream.flush(); |
828 | 816 | |
829 | 817 | expect(api.sendMessage).toHaveBeenCalledTimes(1); |
830 | | -const sentText = requireSendMessageCallText(api, 0); |
831 | | -expect(sentText).toBe("123456789"); |
832 | | -expect(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(sentText)).toBe(false); |
| 818 | +expectNthPreviewSend(api, 1, "123456789"); |
833 | 819 | expect(stream.lastDeliveredText?.()).toBe("123456789"); |
834 | 820 | }); |
835 | 821 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。