mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 06:12:45 +00:00
test(discord): share thread binding sweep fixtures
This commit is contained in:
@@ -66,6 +66,28 @@ describe("thread binding ttl", () => {
|
|||||||
vi.useRealTimers();
|
vi.useRealTimers();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const createDefaultSweeperManager = () =>
|
||||||
|
createThreadBindingManager({
|
||||||
|
accountId: "default",
|
||||||
|
persist: false,
|
||||||
|
enableSweeper: true,
|
||||||
|
sessionTtlMs: 24 * 60 * 60 * 1000,
|
||||||
|
});
|
||||||
|
|
||||||
|
const bindDefaultThreadTarget = async (
|
||||||
|
manager: ReturnType<typeof createThreadBindingManager>,
|
||||||
|
) => {
|
||||||
|
await manager.bindTarget({
|
||||||
|
threadId: "thread-1",
|
||||||
|
channelId: "parent-1",
|
||||||
|
targetKind: "subagent",
|
||||||
|
targetSessionKey: "agent:main:subagent:child",
|
||||||
|
agentId: "main",
|
||||||
|
webhookId: "wh-1",
|
||||||
|
webhookToken: "tok-1",
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
it("includes ttl in intro text", () => {
|
it("includes ttl in intro text", () => {
|
||||||
const intro = resolveThreadBindingIntroText({
|
const intro = resolveThreadBindingIntroText({
|
||||||
agentId: "main",
|
agentId: "main",
|
||||||
@@ -115,22 +137,8 @@ describe("thread binding ttl", () => {
|
|||||||
it("keeps binding when thread sweep probe fails transiently", async () => {
|
it("keeps binding when thread sweep probe fails transiently", async () => {
|
||||||
vi.useFakeTimers();
|
vi.useFakeTimers();
|
||||||
try {
|
try {
|
||||||
const manager = createThreadBindingManager({
|
const manager = createDefaultSweeperManager();
|
||||||
accountId: "default",
|
await bindDefaultThreadTarget(manager);
|
||||||
persist: false,
|
|
||||||
enableSweeper: true,
|
|
||||||
sessionTtlMs: 24 * 60 * 60 * 1000,
|
|
||||||
});
|
|
||||||
|
|
||||||
await manager.bindTarget({
|
|
||||||
threadId: "thread-1",
|
|
||||||
channelId: "parent-1",
|
|
||||||
targetKind: "subagent",
|
|
||||||
targetSessionKey: "agent:main:subagent:child",
|
|
||||||
agentId: "main",
|
|
||||||
webhookId: "wh-1",
|
|
||||||
webhookToken: "tok-1",
|
|
||||||
});
|
|
||||||
|
|
||||||
hoisted.restGet.mockRejectedValueOnce(new Error("ECONNRESET"));
|
hoisted.restGet.mockRejectedValueOnce(new Error("ECONNRESET"));
|
||||||
|
|
||||||
@@ -146,22 +154,8 @@ describe("thread binding ttl", () => {
|
|||||||
it("unbinds when thread sweep probe reports unknown channel", async () => {
|
it("unbinds when thread sweep probe reports unknown channel", async () => {
|
||||||
vi.useFakeTimers();
|
vi.useFakeTimers();
|
||||||
try {
|
try {
|
||||||
const manager = createThreadBindingManager({
|
const manager = createDefaultSweeperManager();
|
||||||
accountId: "default",
|
await bindDefaultThreadTarget(manager);
|
||||||
persist: false,
|
|
||||||
enableSweeper: true,
|
|
||||||
sessionTtlMs: 24 * 60 * 60 * 1000,
|
|
||||||
});
|
|
||||||
|
|
||||||
await manager.bindTarget({
|
|
||||||
threadId: "thread-1",
|
|
||||||
channelId: "parent-1",
|
|
||||||
targetKind: "subagent",
|
|
||||||
targetSessionKey: "agent:main:subagent:child",
|
|
||||||
agentId: "main",
|
|
||||||
webhookId: "wh-1",
|
|
||||||
webhookToken: "tok-1",
|
|
||||||
});
|
|
||||||
|
|
||||||
hoisted.restGet.mockRejectedValueOnce({
|
hoisted.restGet.mockRejectedValueOnce({
|
||||||
status: 404,
|
status: 404,
|
||||||
|
|||||||
Reference in New Issue
Block a user