mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 20:04:32 +00:00
test: expand prompt and update hint coverage
This commit is contained in:
@@ -48,6 +48,9 @@ describe("buildAgentSystemPrompt", () => {
|
|||||||
expect(prompt).not.toContain("## Silent Replies");
|
expect(prompt).not.toContain("## Silent Replies");
|
||||||
expect(prompt).not.toContain("## Heartbeats");
|
expect(prompt).not.toContain("## Heartbeats");
|
||||||
expect(prompt).toContain("## Safety");
|
expect(prompt).toContain("## Safety");
|
||||||
|
expect(prompt).toContain(
|
||||||
|
"For long waits, avoid rapid poll loops: use exec with enough yieldMs or process(action=poll, timeout=<ms>).",
|
||||||
|
);
|
||||||
expect(prompt).toContain("You have no independent goals");
|
expect(prompt).toContain("You have no independent goals");
|
||||||
expect(prompt).toContain("Prioritize safety and human oversight");
|
expect(prompt).toContain("Prioritize safety and human oversight");
|
||||||
expect(prompt).toContain("if instructions conflict");
|
expect(prompt).toContain("if instructions conflict");
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
import type { UpdateCheckResult } from "../infra/update-check.js";
|
import type { UpdateCheckResult } from "../infra/update-check.js";
|
||||||
import { VERSION } from "../version.js";
|
import { VERSION } from "../version.js";
|
||||||
import { formatUpdateOneLiner, resolveUpdateAvailability } from "./status.update.js";
|
import {
|
||||||
|
formatUpdateAvailableHint,
|
||||||
|
formatUpdateOneLiner,
|
||||||
|
resolveUpdateAvailability,
|
||||||
|
} from "./status.update.js";
|
||||||
|
|
||||||
function buildUpdate(partial: Partial<UpdateCheckResult>): UpdateCheckResult {
|
function buildUpdate(partial: Partial<UpdateCheckResult>): UpdateCheckResult {
|
||||||
return {
|
return {
|
||||||
@@ -106,3 +110,38 @@ describe("formatUpdateOneLiner", () => {
|
|||||||
expect(formatUpdateOneLiner(update)).toBe("Update: npm · npm latest unknown · deps missing");
|
expect(formatUpdateOneLiner(update)).toBe("Update: npm · npm latest unknown · deps missing");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("formatUpdateAvailableHint", () => {
|
||||||
|
it("returns null when no update is available", () => {
|
||||||
|
const update = buildUpdate({
|
||||||
|
installKind: "package",
|
||||||
|
packageManager: "pnpm",
|
||||||
|
registry: { latestVersion: VERSION },
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(formatUpdateAvailableHint(update)).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("renders git and registry update details", () => {
|
||||||
|
const latestVersion = nextMajorVersion(VERSION);
|
||||||
|
const update = buildUpdate({
|
||||||
|
installKind: "git",
|
||||||
|
git: {
|
||||||
|
root: "/tmp/repo",
|
||||||
|
sha: null,
|
||||||
|
tag: null,
|
||||||
|
branch: "main",
|
||||||
|
upstream: "origin/main",
|
||||||
|
dirty: false,
|
||||||
|
ahead: 0,
|
||||||
|
behind: 2,
|
||||||
|
fetchOk: true,
|
||||||
|
},
|
||||||
|
registry: { latestVersion },
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(formatUpdateAvailableHint(update)).toBe(
|
||||||
|
`Update available (git behind 2 · npm ${latestVersion}). Run: openclaw update`,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user