build: add local node bin to restart script PATH

This commit is contained in:
Peter Steinberger
2025-12-07 18:49:55 +01:00
parent 558af7a454
commit d463c82c95
31 changed files with 2089 additions and 1851 deletions

View File

@@ -18,7 +18,8 @@ const runtime: RuntimeEnv = {
};
const makeDeps = (overrides: Partial<CliDeps> = {}): CliDeps => ({
sendMessageWeb: vi.fn(),
sendMessageWhatsApp: vi.fn(),
sendMessageTelegram: vi.fn(),
...overrides,
});
@@ -34,7 +35,7 @@ describe("sendCommand", () => {
deps,
runtime,
);
expect(deps.sendMessageWeb).not.toHaveBeenCalled();
expect(deps.sendMessageWhatsApp).not.toHaveBeenCalled();
});
it("uses IPC when available", async () => {
@@ -48,14 +49,16 @@ describe("sendCommand", () => {
deps,
runtime,
);
expect(deps.sendMessageWeb).not.toHaveBeenCalled();
expect(deps.sendMessageWhatsApp).not.toHaveBeenCalled();
expect(runtime.log).toHaveBeenCalledWith(expect.stringContaining("ipc1"));
});
it("falls back to direct send when IPC fails", async () => {
sendViaIpcMock.mockResolvedValueOnce({ success: false, error: "nope" });
const deps = makeDeps({
sendMessageWeb: vi.fn().mockResolvedValue({ messageId: "direct1" }),
sendMessageWhatsApp: vi
.fn()
.mockResolvedValue({ messageId: "direct1" }),
});
await sendCommand(
{
@@ -66,13 +69,34 @@ describe("sendCommand", () => {
deps,
runtime,
);
expect(deps.sendMessageWeb).toHaveBeenCalled();
expect(deps.sendMessageWhatsApp).toHaveBeenCalled();
});
it("routes to telegram provider", async () => {
const deps = makeDeps({
sendMessageTelegram: vi
.fn()
.mockResolvedValue({ messageId: "t1", chatId: "123" }),
});
await sendCommand(
{ to: "123", message: "hi", provider: "telegram" },
deps,
runtime,
);
expect(deps.sendMessageTelegram).toHaveBeenCalledWith(
"123",
"hi",
expect.objectContaining({ token: expect.any(String) }),
);
expect(deps.sendMessageWhatsApp).not.toHaveBeenCalled();
});
it("emits json output", async () => {
sendViaIpcMock.mockResolvedValueOnce(null);
const deps = makeDeps({
sendMessageWeb: vi.fn().mockResolvedValue({ messageId: "direct2" }),
sendMessageWhatsApp: vi
.fn()
.mockResolvedValue({ messageId: "direct2" }),
});
await sendCommand(
{