mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-05 03:21:35 +00:00
* refactor(state): move workspace setup state to SQLite * test(state): track workspace cleanup temp dirs * fix(state): satisfy workspace migration gates * docs(state): fix migration list indentation * fix(state): verify sibling migration claims * fix(state): remove obsolete claim probe
84 lines
2.2 KiB
TypeScript
84 lines
2.2 KiB
TypeScript
// Reset command tests cover cleanup runtime behavior, workspace state, and reset prompts.
|
|
import { beforeAll, beforeEach, describe, expect, it } from "vitest";
|
|
import {
|
|
cleanupCommandLogMessages,
|
|
createCleanupCommandRuntime,
|
|
removeStateAndLinkedPaths,
|
|
removeWorkspaceDirs,
|
|
resetCleanupCommandMocks,
|
|
silenceCleanupCommandRuntime,
|
|
} from "./cleanup-command.test-support.js";
|
|
|
|
describe("resetCommand", () => {
|
|
const runtime = createCleanupCommandRuntime();
|
|
let resetCommand: typeof import("./reset.js").resetCommand;
|
|
|
|
beforeAll(async () => {
|
|
({ resetCommand } = await import("./reset.js"));
|
|
});
|
|
|
|
beforeEach(() => {
|
|
resetCleanupCommandMocks();
|
|
silenceCleanupCommandRuntime(runtime);
|
|
});
|
|
|
|
it("recommends creating a backup before state-destructive reset scopes", async () => {
|
|
await resetCommand(runtime, {
|
|
scope: "config+creds+sessions",
|
|
yes: true,
|
|
nonInteractive: true,
|
|
dryRun: true,
|
|
});
|
|
|
|
expect(
|
|
cleanupCommandLogMessages(runtime).some((message) =>
|
|
message.includes("openclaw backup create"),
|
|
),
|
|
).toBe(true);
|
|
});
|
|
|
|
it("does not recommend backup for config-only reset", async () => {
|
|
await resetCommand(runtime, {
|
|
scope: "config",
|
|
yes: true,
|
|
nonInteractive: true,
|
|
dryRun: true,
|
|
});
|
|
|
|
expect(
|
|
cleanupCommandLogMessages(runtime).some((message) =>
|
|
message.includes("openclaw backup create"),
|
|
),
|
|
).toBe(false);
|
|
});
|
|
|
|
it("does not reopen workspace state after full state removal", async () => {
|
|
await resetCommand(runtime, {
|
|
scope: "full",
|
|
yes: true,
|
|
nonInteractive: true,
|
|
dryRun: true,
|
|
});
|
|
|
|
expect(removeWorkspaceDirs).toHaveBeenCalledWith(["/tmp/.openclaw/workspace"], runtime, {
|
|
dryRun: true,
|
|
removeStateRows: false,
|
|
});
|
|
});
|
|
|
|
it("removes workspace rows when full state removal fails", async () => {
|
|
removeStateAndLinkedPaths.mockResolvedValueOnce(false);
|
|
|
|
await resetCommand(runtime, {
|
|
scope: "full",
|
|
yes: true,
|
|
nonInteractive: true,
|
|
});
|
|
|
|
expect(removeWorkspaceDirs).toHaveBeenCalledWith(["/tmp/.openclaw/workspace"], runtime, {
|
|
dryRun: false,
|
|
removeStateRows: true,
|
|
});
|
|
});
|
|
});
|