mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 15:31:23 +00:00
test(agents): add missing announce delivery regressions
This commit is contained in:
@@ -47,10 +47,15 @@ function maybeBootstrapChannelPlugin(params: {
|
||||
const autoEnabled = applyPluginAutoEnable({ config: cfg }).config;
|
||||
const defaultAgentId = resolveDefaultAgentId(autoEnabled);
|
||||
const workspaceDir = resolveAgentWorkspaceDir(autoEnabled, defaultAgentId);
|
||||
loadOpenClawPlugins({
|
||||
config: autoEnabled,
|
||||
workspaceDir,
|
||||
});
|
||||
try {
|
||||
loadOpenClawPlugins({
|
||||
config: autoEnabled,
|
||||
workspaceDir,
|
||||
});
|
||||
} catch {
|
||||
// Allow a follow-up resolution attempt if bootstrap failed transiently.
|
||||
bootstrapAttempts.delete(attemptKey);
|
||||
}
|
||||
}
|
||||
|
||||
export function resolveOutboundChannelPlugin(params: {
|
||||
|
||||
@@ -28,8 +28,11 @@ import { createTestRegistry } from "../../test-utils/channel-plugins.js";
|
||||
import { resolveOutboundTarget } from "./targets.js";
|
||||
|
||||
describe("resolveOutboundTarget channel resolution", () => {
|
||||
let registrySeq = 0;
|
||||
|
||||
beforeEach(() => {
|
||||
setActivePluginRegistry(createTestRegistry([]));
|
||||
registrySeq += 1;
|
||||
setActivePluginRegistry(createTestRegistry([]), `targets-test-${registrySeq}`);
|
||||
mocks.getChannelPlugin.mockReset();
|
||||
mocks.loadOpenClawPlugins.mockReset();
|
||||
});
|
||||
@@ -58,4 +61,43 @@ describe("resolveOutboundTarget channel resolution", () => {
|
||||
expect(result).toEqual({ ok: true, to: "123456" });
|
||||
expect(mocks.loadOpenClawPlugins).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("retries bootstrap on subsequent resolve when the first bootstrap attempt fails", () => {
|
||||
const telegramPlugin = {
|
||||
id: "telegram",
|
||||
meta: { label: "Telegram" },
|
||||
config: {
|
||||
listAccountIds: () => [],
|
||||
resolveAccount: () => ({}),
|
||||
},
|
||||
};
|
||||
mocks.getChannelPlugin
|
||||
.mockReturnValueOnce(undefined)
|
||||
.mockReturnValueOnce(undefined)
|
||||
.mockReturnValueOnce(undefined)
|
||||
.mockReturnValueOnce(telegramPlugin)
|
||||
.mockReturnValue(telegramPlugin);
|
||||
mocks.loadOpenClawPlugins
|
||||
.mockImplementationOnce(() => {
|
||||
throw new Error("bootstrap failed");
|
||||
})
|
||||
.mockImplementation(() => undefined);
|
||||
|
||||
const first = resolveOutboundTarget({
|
||||
channel: "telegram",
|
||||
to: "123456",
|
||||
cfg: { channels: { telegram: { botToken: "test-token" } } },
|
||||
mode: "explicit",
|
||||
});
|
||||
const second = resolveOutboundTarget({
|
||||
channel: "telegram",
|
||||
to: "123456",
|
||||
cfg: { channels: { telegram: { botToken: "test-token" } } },
|
||||
mode: "explicit",
|
||||
});
|
||||
|
||||
expect(first.ok).toBe(false);
|
||||
expect(second).toEqual({ ok: true, to: "123456" });
|
||||
expect(mocks.loadOpenClawPlugins).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user