mirror of https://github.com/openclaw/openclaw.git
fix: stabilize stale buffer sweep landing (#52428) (thanks @karanuppal)
This commit is contained in:
parent
841add8414
commit
797f3cc377
|
|
@ -2,6 +2,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
|
|||
import { buildDiscordInboundAccessContext } from "../../../../extensions/discord/src/monitor/inbound-context.js";
|
||||
import type { ResolvedSlackAccount } from "../../../../extensions/slack/src/accounts.js";
|
||||
import type { SlackMessageEvent } from "../../../../extensions/slack/src/types.js";
|
||||
import { withTempHome } from "../../../../test/helpers/temp-home.js";
|
||||
import type { MsgContext } from "../../../auto-reply/templating.js";
|
||||
import type { OpenClawConfig } from "../../../config/config.js";
|
||||
import { inboundCtxCapture } from "./inbound-testkit.js";
|
||||
|
|
@ -178,23 +179,25 @@ describe("channel inbound contract", () => {
|
|||
});
|
||||
|
||||
it("keeps Slack inbound context finalized", async () => {
|
||||
const ctx = createInboundSlackTestContext({
|
||||
cfg: {
|
||||
channels: { slack: { enabled: true } },
|
||||
} as OpenClawConfig,
|
||||
});
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
ctx.resolveUserName = async () => ({ name: "Alice" }) as any;
|
||||
await withTempHome(async () => {
|
||||
const ctx = createInboundSlackTestContext({
|
||||
cfg: {
|
||||
channels: { slack: { enabled: true } },
|
||||
} as OpenClawConfig,
|
||||
});
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
ctx.resolveUserName = async () => ({ name: "Alice" }) as any;
|
||||
|
||||
const prepared = await prepareSlackMessage({
|
||||
ctx,
|
||||
account: createSlackAccount(),
|
||||
message: createSlackMessage({}),
|
||||
opts: { source: "message" },
|
||||
});
|
||||
const prepared = await prepareSlackMessage({
|
||||
ctx,
|
||||
account: createSlackAccount(),
|
||||
message: createSlackMessage({}),
|
||||
opts: { source: "message" },
|
||||
});
|
||||
|
||||
expect(prepared).toBeTruthy();
|
||||
expectChannelInboundContextContract(prepared!.ctxPayload);
|
||||
expect(prepared).toBeTruthy();
|
||||
expectChannelInboundContextContract(prepared!.ctxPayload);
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps Telegram inbound context finalized", async () => {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
|
|||
import { readCommandSource } from "./command-source.test-helpers.js";
|
||||
|
||||
const SECRET_TARGET_CALLSITES = [
|
||||
"src/cli/memory-cli.ts",
|
||||
"src/cli/memory-cli.runtime.ts",
|
||||
"src/cli/qr-cli.ts",
|
||||
"src/commands/agent.ts",
|
||||
"src/commands/channels/resolve.ts",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import fs from "node:fs/promises";
|
|||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { withTempHome } from "../../../test/helpers/temp-home.js";
|
||||
import { withPathResolutionEnv } from "../../test-utils/env.js";
|
||||
import type { OpenClawConfig } from "../config.js";
|
||||
import { resolveStorePath } from "./paths.js";
|
||||
import {
|
||||
|
|
@ -78,37 +77,30 @@ const discoveryResolvers = [
|
|||
] as const;
|
||||
|
||||
describe("resolveSessionStoreTargets", () => {
|
||||
it("resolves all configured agent stores", () => {
|
||||
const cfg: OpenClawConfig = {
|
||||
session: {
|
||||
store: "~/.openclaw/agents/{agentId}/sessions/sessions.json",
|
||||
},
|
||||
agents: {
|
||||
list: [{ id: "main", default: true }, { id: "work" }],
|
||||
},
|
||||
};
|
||||
it("resolves all configured agent stores", async () => {
|
||||
await withTempHome(async (home) => {
|
||||
const cfg: OpenClawConfig = {
|
||||
session: {
|
||||
store: "~/.openclaw/agents/{agentId}/sessions/sessions.json",
|
||||
},
|
||||
agents: {
|
||||
list: [{ id: "main", default: true }, { id: "work" }],
|
||||
},
|
||||
};
|
||||
|
||||
const homeDir = path.resolve(path.sep, "tmp", "openclaw-home");
|
||||
const targets = withPathResolutionEnv(homeDir, {}, (env) =>
|
||||
resolveSessionStoreTargets(cfg, { allAgents: true }, { env }),
|
||||
);
|
||||
|
||||
expect(targets).toEqual([
|
||||
{
|
||||
agentId: "main",
|
||||
storePath: resolveStorePath(cfg.session?.store, {
|
||||
const env = { ...process.env };
|
||||
const targets = resolveSessionStoreTargets(cfg, { allAgents: true }, { env });
|
||||
expect(targets).toEqual([
|
||||
{
|
||||
agentId: "main",
|
||||
env: { HOME: homeDir },
|
||||
}),
|
||||
},
|
||||
{
|
||||
agentId: "work",
|
||||
storePath: resolveStorePath(cfg.session?.store, {
|
||||
storePath: resolveStorePath(cfg.session?.store, { agentId: "main", env }),
|
||||
},
|
||||
{
|
||||
agentId: "work",
|
||||
env: { HOME: homeDir },
|
||||
}),
|
||||
},
|
||||
]);
|
||||
storePath: resolveStorePath(cfg.session?.store, { agentId: "work", env }),
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
it("dedupes shared store paths for --all-agents", () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue