fix: add reset transcript archive integration tests (openclaw#14949) thanks @mcaxtr

This commit is contained in:
Gustavo Madeira Santana
2026-02-13 14:39:44 -05:00
parent 95c96c7b68
commit b79cff1c36
2 changed files with 45 additions and 0 deletions

View File

@@ -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";

View File

@@ -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",