mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 12:30:22 +00:00
test(agents): add compaction and workspace reset regressions
This commit is contained in:
@@ -121,6 +121,21 @@ describe("ensureAgentWorkspace", () => {
|
||||
const memoryContent = await fs.readFile(path.join(tempDir, "MEMORY.md"), "utf-8");
|
||||
expect(memoryContent).toBe("# Long-term memory\nImportant stuff");
|
||||
});
|
||||
|
||||
it("treats git-backed workspaces as existing even when template files are missing", async () => {
|
||||
const tempDir = await makeTempWorkspace("openclaw-workspace-");
|
||||
await fs.mkdir(path.join(tempDir, ".git"), { recursive: true });
|
||||
await fs.writeFile(path.join(tempDir, ".git", "HEAD"), "ref: refs/heads/main\n");
|
||||
|
||||
await ensureAgentWorkspace({ dir: tempDir, ensureBootstrapFiles: true });
|
||||
|
||||
await expect(fs.access(path.join(tempDir, DEFAULT_IDENTITY_FILENAME))).resolves.toBeUndefined();
|
||||
await expect(fs.access(path.join(tempDir, DEFAULT_BOOTSTRAP_FILENAME))).rejects.toMatchObject({
|
||||
code: "ENOENT",
|
||||
});
|
||||
const state = await readOnboardingState(tempDir);
|
||||
expect(state.onboardingCompletedAt).toMatch(/\d{4}-\d{2}-\d{2}T/);
|
||||
});
|
||||
});
|
||||
|
||||
describe("loadWorkspaceBootstrapFiles", () => {
|
||||
|
||||
@@ -408,7 +408,11 @@ export async function ensureAgentWorkspace(params?: {
|
||||
fs.readFile(userPath, "utf-8"),
|
||||
]);
|
||||
const hasUserContent = await (async () => {
|
||||
const indicators = [path.join(dir, "memory"), path.join(dir, DEFAULT_MEMORY_FILENAME)];
|
||||
const indicators = [
|
||||
path.join(dir, "memory"),
|
||||
path.join(dir, DEFAULT_MEMORY_FILENAME),
|
||||
path.join(dir, ".git"),
|
||||
];
|
||||
for (const indicator of indicators) {
|
||||
try {
|
||||
await fs.access(indicator);
|
||||
|
||||
Reference in New Issue
Block a user