mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 22:24:32 +00:00
refactor(core): dedupe command, hook, and cron fixtures
This commit is contained in:
@@ -65,6 +65,20 @@ async function runStateIntegrity(cfg: OpenClawConfig) {
|
||||
return confirmSkipInNonInteractive;
|
||||
}
|
||||
|
||||
function writeSessionStore(
|
||||
cfg: OpenClawConfig,
|
||||
sessions: Record<string, { sessionId: string; updatedAt: number }>,
|
||||
) {
|
||||
setupSessionState(cfg, process.env, process.env.HOME ?? "");
|
||||
const storePath = resolveStorePath(cfg.session?.store, { agentId: "main" });
|
||||
fs.writeFileSync(storePath, JSON.stringify(sessions, null, 2));
|
||||
}
|
||||
|
||||
async function runStateIntegrityText(cfg: OpenClawConfig): Promise<string> {
|
||||
await noteStateIntegrity(cfg, { confirmSkipInNonInteractive: vi.fn(async () => false) });
|
||||
return stateIntegrityText();
|
||||
}
|
||||
|
||||
describe("doctor state integrity oauth dir checks", () => {
|
||||
let envSnapshot: EnvSnapshot;
|
||||
let tempHome = "";
|
||||
@@ -146,25 +160,13 @@ describe("doctor state integrity oauth dir checks", () => {
|
||||
|
||||
it("prints openclaw-only verification hints when recent sessions are missing transcripts", async () => {
|
||||
const cfg: OpenClawConfig = {};
|
||||
setupSessionState(cfg, process.env, process.env.HOME ?? "");
|
||||
const storePath = resolveStorePath(cfg.session?.store, { agentId: "main" });
|
||||
fs.writeFileSync(
|
||||
storePath,
|
||||
JSON.stringify(
|
||||
{
|
||||
"agent:main:main": {
|
||||
sessionId: "missing-transcript",
|
||||
updatedAt: Date.now(),
|
||||
},
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
);
|
||||
|
||||
await noteStateIntegrity(cfg, { confirmSkipInNonInteractive: vi.fn(async () => false) });
|
||||
|
||||
const text = stateIntegrityText();
|
||||
writeSessionStore(cfg, {
|
||||
"agent:main:main": {
|
||||
sessionId: "missing-transcript",
|
||||
updatedAt: Date.now(),
|
||||
},
|
||||
});
|
||||
const text = await runStateIntegrityText(cfg);
|
||||
expect(text).toContain("recent sessions are missing transcripts");
|
||||
expect(text).toMatch(/openclaw sessions --store ".*sessions\.json"/);
|
||||
expect(text).toMatch(/openclaw sessions cleanup --store ".*sessions\.json" --dry-run/);
|
||||
@@ -177,25 +179,13 @@ describe("doctor state integrity oauth dir checks", () => {
|
||||
|
||||
it("ignores slash-routing sessions for recent missing transcript warnings", async () => {
|
||||
const cfg: OpenClawConfig = {};
|
||||
setupSessionState(cfg, process.env, process.env.HOME ?? "");
|
||||
const storePath = resolveStorePath(cfg.session?.store, { agentId: "main" });
|
||||
fs.writeFileSync(
|
||||
storePath,
|
||||
JSON.stringify(
|
||||
{
|
||||
"agent:main:telegram:slash:6790081233": {
|
||||
sessionId: "missing-slash-transcript",
|
||||
updatedAt: Date.now(),
|
||||
},
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
);
|
||||
|
||||
await noteStateIntegrity(cfg, { confirmSkipInNonInteractive: vi.fn(async () => false) });
|
||||
|
||||
const text = stateIntegrityText();
|
||||
writeSessionStore(cfg, {
|
||||
"agent:main:telegram:slash:6790081233": {
|
||||
sessionId: "missing-slash-transcript",
|
||||
updatedAt: Date.now(),
|
||||
},
|
||||
});
|
||||
const text = await runStateIntegrityText(cfg);
|
||||
expect(text).not.toContain("recent sessions are missing transcripts");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user