fix: validate whatsapp login timeout · openclaw/openclaw@c0d525c
steipete
·
2026-05-29
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -26,7 +26,7 @@ describe("createWhatsAppLoginTool", () => {
|
26 | 26 | const tool = createWhatsAppLoginTool(); |
27 | 27 | const result = await tool.execute("tool-call-1", { |
28 | 28 | action: "wait", |
29 | | -timeoutMs: 5000, |
| 29 | +timeoutMs: "5000", |
30 | 30 | accountId, |
31 | 31 | currentQrDataUrl: "data:image/png;base64,current-qr", |
32 | 32 | }); |
@@ -56,6 +56,39 @@ describe("createWhatsAppLoginTool", () => {
|
56 | 56 | }); |
57 | 57 | }); |
58 | 58 | |
| 59 | +it("passes string timeoutMs through to start actions", async () => { |
| 60 | +startWebLoginWithQrMock.mockResolvedValueOnce({ |
| 61 | +connected: false, |
| 62 | +message: "Scan this QR in WhatsApp → Linked Devices.", |
| 63 | +qrDataUrl: "data:image/png;base64,current-qr", |
| 64 | +}); |
| 65 | + |
| 66 | +const tool = createWhatsAppLoginTool(); |
| 67 | +await tool.execute("tool-call-start", { |
| 68 | +action: "start", |
| 69 | +timeoutMs: "6000", |
| 70 | +accountId: "account-3", |
| 71 | +}); |
| 72 | + |
| 73 | +expect(startWebLoginWithQrMock).toHaveBeenCalledWith({ |
| 74 | +accountId: "account-3", |
| 75 | +timeoutMs: 6000, |
| 76 | +force: false, |
| 77 | +}); |
| 78 | +}); |
| 79 | + |
| 80 | +it("rejects fractional timeoutMs before login actions", async () => { |
| 81 | +const tool = createWhatsAppLoginTool(); |
| 82 | + |
| 83 | +await expect( |
| 84 | +tool.execute("tool-call-start", { |
| 85 | +action: "start", |
| 86 | +timeoutMs: "6000.5", |
| 87 | +}), |
| 88 | +).rejects.toThrow("timeoutMs must be a positive integer"); |
| 89 | +expect(startWebLoginWithQrMock).not.toHaveBeenCalled(); |
| 90 | +}); |
| 91 | + |
59 | 92 | it("does not retain QR state across tool actions", async () => { |
60 | 93 | const accountId = "account-2"; |
61 | 94 | startWebLoginWithQrMock.mockResolvedValueOnce({ |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。