From b55979844b097b5c40c71d324f971e122ebd1a41 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 22 Feb 2026 00:26:28 +0000 Subject: [PATCH] test(tui): dedupe local bind loopback assertions --- src/tui/gateway-chat.test.ts | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/tui/gateway-chat.test.ts b/src/tui/gateway-chat.test.ts index 60e6b2cbead..f349f07b71f 100644 --- a/src/tui/gateway-chat.test.ts +++ b/src/tui/gateway-chat.test.ts @@ -84,20 +84,21 @@ describe("resolveGatewayConnection", () => { }); }); - it("uses loopback host when local bind is tailnet", () => { - loadConfig.mockReturnValue({ gateway: { mode: "local", bind: "tailnet" } }); + it.each([ + { + label: "tailnet", + bind: "tailnet", + setup: () => pickPrimaryTailnetIPv4.mockReturnValue("100.64.0.1"), + }, + { + label: "lan", + bind: "lan", + setup: () => pickPrimaryLanIPv4.mockReturnValue("192.168.1.42"), + }, + ])("uses loopback host when local bind is $label", ({ bind, setup }) => { + loadConfig.mockReturnValue({ gateway: { mode: "local", bind } }); resolveGatewayPort.mockReturnValue(18800); - pickPrimaryTailnetIPv4.mockReturnValue("100.64.0.1"); - - const result = resolveGatewayConnection({}); - - expect(result.url).toBe("ws://127.0.0.1:18800"); - }); - - it("uses loopback host when local bind is lan", () => { - loadConfig.mockReturnValue({ gateway: { mode: "local", bind: "lan" } }); - resolveGatewayPort.mockReturnValue(18800); - pickPrimaryLanIPv4.mockReturnValue("192.168.1.42"); + setup(); const result = resolveGatewayConnection({});