Skip to content

Commit 50fb29c

Browse files
fix(gateway): surface unreachable status diagnostics
1 parent beb569a commit 50fb29c

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/commands/gateway-status/output.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import type { GatewayProbeResult } from "../../gateway/probe.js";
33
import type { RuntimeEnv } from "../../runtime.js";
44
import type { GatewayStatusProbedTarget } from "./probe-run.js";
55

6-
const writeRuntimeJson = vi.fn();
6+
const mocks = vi.hoisted(() => ({
7+
writeRuntimeJson: vi.fn(),
8+
}));
79

810
vi.mock("../../runtime.js", () => ({
9-
writeRuntimeJson: (...args: unknown[]) => writeRuntimeJson(...args),
11+
writeRuntimeJson: (...args: unknown[]) => mocks.writeRuntimeJson(...args),
1012
}));
1113

1214
vi.mock("../../terminal/theme.js", async () => {
@@ -78,7 +80,7 @@ function createTarget(id: string, probe: GatewayProbeResult): GatewayStatusProbe
7880

7981
describe("gateway status output", () => {
8082
beforeEach(() => {
81-
writeRuntimeJson.mockReset();
83+
mocks.writeRuntimeJson.mockReset();
8284
});
8385

8486
it("warns with diagnostic next steps when no probes or Bonjour discovery find a gateway", () => {
@@ -143,7 +145,7 @@ describe("gateway status output", () => {
143145
primaryTargetId: "reachable-read",
144146
});
145147

146-
expect(writeRuntimeJson).toHaveBeenCalledWith(
148+
expect(mocks.writeRuntimeJson).toHaveBeenCalledWith(
147149
runtime,
148150
expect.objectContaining({
149151
ok: true,
@@ -217,7 +219,7 @@ describe("gateway status output", () => {
217219
primaryTargetId: "detail-timeout",
218220
});
219221

220-
expect(writeRuntimeJson).toHaveBeenCalledWith(
222+
expect(mocks.writeRuntimeJson).toHaveBeenCalledWith(
221223
runtime,
222224
expect.objectContaining({
223225
ok: true,

0 commit comments

Comments
 (0)