From 4de268587cb649ecd7c9e82f46351d3c20b3fb59 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 13 Mar 2026 21:52:01 +0000 Subject: [PATCH] test: tighten shared tailscale fallback coverage --- src/shared/tailscale-status.test.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/shared/tailscale-status.test.ts b/src/shared/tailscale-status.test.ts index 94128e700..ebd89629a 100644 --- a/src/shared/tailscale-status.test.ts +++ b/src/shared/tailscale-status.test.ts @@ -54,9 +54,23 @@ describe("shared/tailscale-status", () => { expect(run).toHaveBeenCalledTimes(2); }); + it("continues when the first candidate returns success but malformed Self data", async () => { + const run = vi + .fn() + .mockResolvedValueOnce({ code: 0, stdout: '{"Self":"bad"}' }) + .mockResolvedValueOnce({ + code: 0, + stdout: 'prefix {"Self":{"TailscaleIPs":["100.64.0.11"]}} suffix', + }); + + await expect(resolveTailnetHostWithRunner(run)).resolves.toBe("100.64.0.11"); + expect(run).toHaveBeenCalledTimes(2); + }); + it("returns null for non-zero exits, blank output, or invalid json", async () => { const run = vi .fn() + .mockResolvedValueOnce({ code: null, stdout: "boom" }) .mockResolvedValueOnce({ code: 1, stdout: "boom" }) .mockResolvedValueOnce({ code: 0, stdout: " " });