mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 05:31:38 +00:00
test (memory/compaction): cover resolved memory flush prompt semantics
This commit is contained in:
36
src/auto-reply/reply/memory-flush.test.ts
Normal file
36
src/auto-reply/reply/memory-flush.test.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { resolveMemoryFlushPromptForRun } from "./memory-flush.js";
|
||||
|
||||
describe("resolveMemoryFlushPromptForRun", () => {
|
||||
const cfg = {
|
||||
agents: {
|
||||
defaults: {
|
||||
userTimezone: "America/New_York",
|
||||
timeFormat: "12",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
it("replaces YYYY-MM-DD using user timezone and appends current time", () => {
|
||||
const prompt = resolveMemoryFlushPromptForRun({
|
||||
prompt: "Store durable notes in memory/YYYY-MM-DD.md",
|
||||
cfg,
|
||||
nowMs: Date.UTC(2026, 1, 16, 15, 0, 0),
|
||||
});
|
||||
|
||||
expect(prompt).toContain("memory/2026-02-16.md");
|
||||
expect(prompt).toContain("Current time:");
|
||||
expect(prompt).toContain("(America/New_York)");
|
||||
});
|
||||
|
||||
it("does not append a duplicate current time line", () => {
|
||||
const prompt = resolveMemoryFlushPromptForRun({
|
||||
prompt: "Store notes.\nCurrent time: already present",
|
||||
cfg,
|
||||
nowMs: Date.UTC(2026, 1, 16, 15, 0, 0),
|
||||
});
|
||||
|
||||
expect(prompt).toContain("Current time: already present");
|
||||
expect((prompt.match(/Current time:/g) ?? []).length).toBe(1);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user