openclaw/src/auto-reply/reply/session-reset-prompt.test.ts
Jacob Riff aad372e15f
feat: append UTC time alongside local time in shared Current time lines (#32423)
Merged via squash.

Prepared head SHA: 9e8ec13933b5317e7cff3f0bc048de515826c31a
Co-authored-by: jriff <50276+jriff@users.noreply.github.com>
Co-authored-by: altaywtf <9790196+altaywtf@users.noreply.github.com>
Reviewed-by: @altaywtf
2026-03-06 01:26:34 +03:00

36 lines
1.5 KiB
TypeScript

import { describe, it, expect } from "vitest";
import type { OpenClawConfig } from "../../config/config.js";
import { buildBareSessionResetPrompt } from "./session-reset-prompt.js";
describe("buildBareSessionResetPrompt", () => {
it("includes the core session startup instruction", () => {
const prompt = buildBareSessionResetPrompt();
expect(prompt).toContain("Execute your Session Startup sequence now");
expect(prompt).toContain("read the required files before responding to the user");
});
it("appends current time line so agents know the date", () => {
const cfg = {
agents: { defaults: { userTimezone: "America/New_York", timeFormat: "12" } },
} as OpenClawConfig;
// 2026-03-03 14:00 UTC = 2026-03-03 09:00 EST
const nowMs = Date.UTC(2026, 2, 3, 14, 0, 0);
const prompt = buildBareSessionResetPrompt(cfg, nowMs);
expect(prompt).toContain(
"Current time: Tuesday, March 3rd, 2026 — 9:00 AM (America/New_York) / 2026-03-03 14:00 UTC",
);
});
it("does not append a duplicate current time line", () => {
const nowMs = Date.UTC(2026, 2, 3, 14, 0, 0);
const prompt = buildBareSessionResetPrompt(undefined, nowMs);
expect((prompt.match(/Current time:/g) ?? []).length).toBe(1);
});
it("falls back to UTC when no timezone configured", () => {
const nowMs = Date.UTC(2026, 2, 3, 14, 0, 0);
const prompt = buildBareSessionResetPrompt(undefined, nowMs);
expect(prompt).toContain("Current time:");
});
});