Heartbeat: add relay helper and fix CLI tests

This commit is contained in:
Peter Steinberger
2025-11-26 17:49:34 +01:00
parent 117161e6ff
commit deded848ee
6 changed files with 113 additions and 10 deletions

View File

@@ -80,6 +80,10 @@ describe("cli program", () => {
});
it("runs relay tmux attach command", async () => {
const originalIsTTY = process.stdout.isTTY;
(process.stdout as typeof process.stdout & { isTTY?: boolean }).isTTY =
true;
const program = buildProgram();
await program.parseAsync(["relay:tmux:attach"], { from: "user" });
expect(spawnRelayTmux).toHaveBeenCalledWith(
@@ -87,5 +91,29 @@ describe("cli program", () => {
true,
false,
);
(process.stdout as typeof process.stdout & { isTTY?: boolean }).isTTY =
originalIsTTY;
});
it("runs relay heartbeat command", async () => {
pickProvider.mockResolvedValue("web");
monitorWebProvider.mockResolvedValue(undefined);
const originalExit = runtime.exit;
runtime.exit = vi.fn();
const program = buildProgram();
await program.parseAsync(["relay:heartbeat"], { from: "user" });
expect(logWebSelfId).toHaveBeenCalled();
expect(monitorWebProvider).toHaveBeenCalledWith(
false,
undefined,
true,
undefined,
runtime,
undefined,
{ replyHeartbeatNow: true },
);
expect(runtime.exit).not.toHaveBeenCalled();
runtime.exit = originalExit;
});
});