mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-07 10:52:56 +00:00
58 lines
2.0 KiB
TypeScript
58 lines
2.0 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import type { OpenClawConfig } from "../../config/config.js";
|
|
import { parseInlineDirectives } from "./directive-handling.parse.js";
|
|
import { maybeHandleQueueDirective } from "./directive-handling.queue-validation.js";
|
|
|
|
describe("maybeHandleQueueDirective", () => {
|
|
it("reports invalid queue options and current queue settings", () => {
|
|
const invalid = maybeHandleQueueDirective({
|
|
directives: parseInlineDirectives("/queue collect debounce:bogus cap:zero drop:maybe"),
|
|
cfg: {} as OpenClawConfig,
|
|
channel: "quietchat",
|
|
});
|
|
expect(invalid?.text).toContain("Invalid debounce");
|
|
expect(invalid?.text).toContain("Invalid cap");
|
|
expect(invalid?.text).toContain("Invalid drop policy");
|
|
|
|
const invalidMode = maybeHandleQueueDirective({
|
|
directives: parseInlineDirectives("/queue backlog"),
|
|
cfg: {} as OpenClawConfig,
|
|
channel: "quietchat",
|
|
});
|
|
expect(invalidMode?.text).toContain(
|
|
'Unrecognized queue mode "backlog". Valid modes: steer, followup, collect, interrupt.',
|
|
);
|
|
|
|
const current = maybeHandleQueueDirective({
|
|
directives: parseInlineDirectives("/queue"),
|
|
cfg: {
|
|
messages: {
|
|
queue: {
|
|
mode: "collect",
|
|
debounceMs: 1500,
|
|
cap: 9,
|
|
drop: "summarize",
|
|
},
|
|
},
|
|
} as OpenClawConfig,
|
|
channel: "quietchat",
|
|
});
|
|
expect(current?.text).toContain(
|
|
"Current queue settings: mode=collect, debounce=1500ms, cap=9, drop=summarize.",
|
|
);
|
|
expect(current?.text).toContain(
|
|
"Options: modes steer, followup, collect, interrupt; debounce:<ms|s|m>, cap:<n>, drop:old|new|summarize.",
|
|
);
|
|
});
|
|
|
|
it.each(["cap:1e3", "cap:0x10", "cap:4.9"])("rejects non-decimal-integer caps: %s", (cap) => {
|
|
const invalid = maybeHandleQueueDirective({
|
|
directives: parseInlineDirectives(`/queue collect ${cap}`),
|
|
cfg: {} as OpenClawConfig,
|
|
channel: "quietchat",
|
|
});
|
|
|
|
expect(invalid?.text).toContain("Invalid cap");
|
|
});
|
|
});
|