fix(doctor): canonicalize gateway service entrypoint paths (#43882)

Merged via squash.

Prepared head SHA: 9f530d2a86b5d30822d4419db7cffae6a560ddca
Co-authored-by: ngutman <1540134+ngutman@users.noreply.github.com>
Co-authored-by: ngutman <1540134+ngutman@users.noreply.github.com>
Reviewed-by: @ngutman
This commit is contained in:
Nimrod Gutman
2026-03-12 12:39:22 +02:00
committed by GitHub
parent 783a0d540f
commit 4f620bebe5
4 changed files with 186 additions and 18 deletions

View File

@@ -1,42 +1,65 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { chunkMarkdownText } from "../../../src/auto-reply/chunk.js";
import { zalouserPlugin } from "./channel.js";
import { setZalouserRuntime } from "./runtime.js";
import { sendReactionZalouser } from "./send.js";
import { sendMessageZalouser, sendReactionZalouser } from "./send.js";
vi.mock("./send.js", async (importOriginal) => {
const actual = (await importOriginal()) as Record<string, unknown>;
return {
...actual,
sendMessageZalouser: vi.fn(async () => ({ ok: true, messageId: "mid-1" })),
sendReactionZalouser: vi.fn(async () => ({ ok: true })),
};
});
const mockSendMessage = vi.mocked(sendMessageZalouser);
const mockSendReaction = vi.mocked(sendReactionZalouser);
describe("zalouser outbound chunker", () => {
describe("zalouser outbound", () => {
beforeEach(() => {
mockSendMessage.mockClear();
setZalouserRuntime({
channel: {
text: {
chunkMarkdownText,
resolveChunkMode: vi.fn(() => "newline"),
resolveTextChunkLimit: vi.fn(() => 10),
},
},
} as never);
});
it("chunks without empty strings and respects limit", () => {
const chunker = zalouserPlugin.outbound?.chunker;
expect(chunker).toBeTypeOf("function");
if (!chunker) {
it("passes markdown chunk settings through sendText", async () => {
const sendText = zalouserPlugin.outbound?.sendText;
expect(sendText).toBeTypeOf("function");
if (!sendText) {
return;
}
const limit = 10;
const chunks = chunker("hello world\nthis is a test", limit);
expect(chunks.length).toBeGreaterThan(1);
expect(chunks.every((c) => c.length > 0)).toBe(true);
expect(chunks.every((c) => c.length <= limit)).toBe(true);
const result = await sendText({
cfg: { channels: { zalouser: { enabled: true } } } as never,
to: "group:123456",
text: "hello world\nthis is a test",
accountId: "default",
} as never);
expect(mockSendMessage).toHaveBeenCalledWith(
"123456",
"hello world\nthis is a test",
expect.objectContaining({
profile: "default",
isGroup: true,
textMode: "markdown",
textChunkMode: "newline",
textChunkLimit: 10,
}),
);
expect(result).toEqual(
expect.objectContaining({
channel: "zalouser",
messageId: "mid-1",
ok: true,
}),
);
});
});