mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 11:10:45 +00:00
test(commands): share qmd orphan transcript setup
This commit is contained in:
@@ -94,6 +94,23 @@ async function runStateIntegrityText(cfg: OpenClawConfig): Promise<string> {
|
||||
return stateIntegrityText();
|
||||
}
|
||||
|
||||
async function runOrphanTranscriptCheckWithQmdSessions(enabled: boolean, homeDir: string) {
|
||||
const cfg: OpenClawConfig = {
|
||||
memory: {
|
||||
backend: "qmd",
|
||||
qmd: {
|
||||
sessions: { enabled },
|
||||
},
|
||||
},
|
||||
};
|
||||
setupSessionState(cfg, process.env, homeDir);
|
||||
const sessionsDir = resolveSessionTranscriptsDirForAgent("main", process.env, () => homeDir);
|
||||
fs.writeFileSync(path.join(sessionsDir, "orphan-session.jsonl"), '{"type":"session"}\n');
|
||||
const confirmRuntimeRepair = vi.fn(async () => false);
|
||||
await noteStateIntegrity(cfg, { confirmRuntimeRepair, note: noteMock });
|
||||
return confirmRuntimeRepair;
|
||||
}
|
||||
|
||||
describe("doctor state integrity oauth dir checks", () => {
|
||||
let envSnapshot: EnvSnapshot;
|
||||
let tempHome = "";
|
||||
@@ -282,20 +299,7 @@ describe("doctor state integrity oauth dir checks", () => {
|
||||
});
|
||||
|
||||
it("suppresses orphan transcript warnings when QMD sessions are enabled", async () => {
|
||||
const cfg: OpenClawConfig = {
|
||||
memory: {
|
||||
backend: "qmd",
|
||||
qmd: {
|
||||
sessions: { enabled: true },
|
||||
},
|
||||
},
|
||||
};
|
||||
setupSessionState(cfg, process.env, process.env.HOME ?? "");
|
||||
const sessionsDir = resolveSessionTranscriptsDirForAgent("main", process.env, () => tempHome);
|
||||
fs.writeFileSync(path.join(sessionsDir, "orphan-session.jsonl"), '{"type":"session"}\n');
|
||||
|
||||
const confirmRuntimeRepair = vi.fn(async () => false);
|
||||
await noteStateIntegrity(cfg, { confirmRuntimeRepair, note: noteMock });
|
||||
const confirmRuntimeRepair = await runOrphanTranscriptCheckWithQmdSessions(true, tempHome);
|
||||
|
||||
expect(stateIntegrityText()).not.toContain(
|
||||
"These .jsonl files are no longer referenced by sessions.json",
|
||||
@@ -304,20 +308,7 @@ describe("doctor state integrity oauth dir checks", () => {
|
||||
});
|
||||
|
||||
it("still detects orphan transcripts when QMD sessions are disabled", async () => {
|
||||
const cfg: OpenClawConfig = {
|
||||
memory: {
|
||||
backend: "qmd",
|
||||
qmd: {
|
||||
sessions: { enabled: false },
|
||||
},
|
||||
},
|
||||
};
|
||||
setupSessionState(cfg, process.env, process.env.HOME ?? "");
|
||||
const sessionsDir = resolveSessionTranscriptsDirForAgent("main", process.env, () => tempHome);
|
||||
fs.writeFileSync(path.join(sessionsDir, "orphan-session.jsonl"), '{"type":"session"}\n');
|
||||
|
||||
const confirmRuntimeRepair = vi.fn(async () => false);
|
||||
await noteStateIntegrity(cfg, { confirmRuntimeRepair, note: noteMock });
|
||||
const confirmRuntimeRepair = await runOrphanTranscriptCheckWithQmdSessions(false, tempHome);
|
||||
|
||||
expect(stateIntegrityText()).toContain(
|
||||
"These .jsonl files are no longer referenced by sessions.json",
|
||||
|
||||
Reference in New Issue
Block a user