mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 15:03:32 +00:00
fix: add reset transcript archive integration tests (openclaw#14949) thanks @mcaxtr
This commit is contained in:
@@ -583,6 +583,49 @@ describe("initSessionState preserves behavior overrides across /new and /reset",
|
||||
expect(result.sessionEntry.ttsAuto).toBe("on");
|
||||
});
|
||||
|
||||
it("archives previous transcript file on /new reset", async () => {
|
||||
const storePath = await createStorePath("openclaw-reset-archive-");
|
||||
const sessionKey = "agent:main:telegram:dm:user-archive";
|
||||
const existingSessionId = "existing-session-archive";
|
||||
await seedSessionStoreWithOverrides({
|
||||
storePath,
|
||||
sessionKey,
|
||||
sessionId: existingSessionId,
|
||||
overrides: {},
|
||||
});
|
||||
const transcriptPath = path.join(path.dirname(storePath), `${existingSessionId}.jsonl`);
|
||||
await fs.writeFile(
|
||||
transcriptPath,
|
||||
`${JSON.stringify({ message: { role: "user", content: "hello" } })}\n`,
|
||||
"utf-8",
|
||||
);
|
||||
|
||||
const cfg = {
|
||||
session: { store: storePath, idleMinutes: 999 },
|
||||
} as OpenClawConfig;
|
||||
|
||||
const result = await initSessionState({
|
||||
ctx: {
|
||||
Body: "/new",
|
||||
RawBody: "/new",
|
||||
CommandBody: "/new",
|
||||
From: "user-archive",
|
||||
To: "bot",
|
||||
ChatType: "direct",
|
||||
SessionKey: sessionKey,
|
||||
Provider: "telegram",
|
||||
Surface: "telegram",
|
||||
},
|
||||
cfg,
|
||||
commandAuthorized: true,
|
||||
});
|
||||
|
||||
expect(result.isNewSession).toBe(true);
|
||||
expect(result.resetTriggered).toBe(true);
|
||||
const files = await fs.readdir(path.dirname(storePath));
|
||||
expect(files.some((f) => f.startsWith(`${existingSessionId}.jsonl.reset.`))).toBe(true);
|
||||
});
|
||||
|
||||
it("idle-based new session does NOT preserve overrides (no entry to read)", async () => {
|
||||
const storePath = await createStorePath("openclaw-idle-no-preserve-");
|
||||
const sessionKey = "agent:main:telegram:dm:new-user";
|
||||
|
||||
@@ -361,6 +361,8 @@ describe("gateway server sessions", () => {
|
||||
expect(reset.ok).toBe(true);
|
||||
expect(reset.payload?.key).toBe("agent:main:main");
|
||||
expect(reset.payload?.entry.sessionId).not.toBe("sess-main");
|
||||
const filesAfterReset = await fs.readdir(dir);
|
||||
expect(filesAfterReset.some((f) => f.startsWith("sess-main.jsonl.reset."))).toBe(true);
|
||||
|
||||
const badThinking = await rpcReq(ws, "sessions.patch", {
|
||||
key: "agent:main:main",
|
||||
|
||||
Reference in New Issue
Block a user