fix: harden queue retry debounce and add regression tests

This commit is contained in:
Peter Steinberger
2026-02-24 03:52:31 +00:00
parent a216f2dabe
commit 6c1ed9493c
9 changed files with 257 additions and 6 deletions

View File

@@ -39,6 +39,7 @@ vi.mock("zod", () => ({
}));
const { createSynologyChatPlugin } = await import("./channel.js");
const { registerPluginHttpRoute } = await import("openclaw/plugin-sdk");
describe("createSynologyChatPlugin", () => {
it("returns a plugin object with all required sections", () => {
@@ -336,5 +337,39 @@ describe("createSynologyChatPlugin", () => {
const result = await plugin.gateway.startAccount(ctx);
expect(typeof result.stop).toBe("function");
});
it("deregisters stale route before re-registering same account/path", async () => {
const unregisterFirst = vi.fn();
const unregisterSecond = vi.fn();
const registerMock = vi.mocked(registerPluginHttpRoute);
registerMock.mockReturnValueOnce(unregisterFirst).mockReturnValueOnce(unregisterSecond);
const plugin = createSynologyChatPlugin();
const ctx = {
cfg: {
channels: {
"synology-chat": {
enabled: true,
token: "t",
incomingUrl: "https://nas/incoming",
webhookPath: "/webhook/synology",
},
},
},
accountId: "default",
log: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },
};
const first = await plugin.gateway.startAccount(ctx);
const second = await plugin.gateway.startAccount(ctx);
expect(registerMock).toHaveBeenCalledTimes(2);
expect(unregisterFirst).toHaveBeenCalledTimes(1);
expect(unregisterSecond).not.toHaveBeenCalled();
// Clean up active route map so this module-level state doesn't leak across tests.
first.stop();
second.stop();
});
});
});