mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 23:56:07 +00:00
test(context): cover context map media (#79867)
This commit is contained in:
@@ -6,6 +6,7 @@ Docs: https://docs.openclaw.ai
|
||||
|
||||
### Changes
|
||||
|
||||
- Context: add `/context map` to send a treemap image of the current session context contributors. (#79867)
|
||||
- Plugin SDK: deprecate public subpaths that existed for at least one month and have no bundled extension production imports, keep legacy barrel/test/zod subpath package exports for backwards compatibility, and track both sets in the SDK surface report.
|
||||
- Plugin SDK: deprecate public subpaths currently used by only one or two bundled plugin owners, keeping them importable while steering new plugin code to focused shared SDK seams or plugin-owned APIs.
|
||||
- Plugin SDK: remove the owner-specific `provider-auth-login` public subpath after moving Chutes, GitHub Copilot, and OpenAI Codex auth flows back to provider-owned modules.
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { readFile, unlink } from "node:fs/promises";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { SessionEntry } from "../../config/sessions.js";
|
||||
import { buildContextReply } from "./commands-context-report.js";
|
||||
@@ -155,4 +156,30 @@ describe("buildContextReply", () => {
|
||||
expect(result.text).toContain("Session tokens (cached): 900 total / ctx=8,192");
|
||||
expect(result.text).not.toContain("Actual context usage (cached): 111 tok");
|
||||
});
|
||||
|
||||
it("renders context map as sensitive local PNG media", async () => {
|
||||
const result = await buildContextReply(
|
||||
makeParams("/context map", false, {
|
||||
contextTokens: 8_192,
|
||||
totalTokens: 900,
|
||||
}),
|
||||
);
|
||||
if (!result.mediaUrl) {
|
||||
throw new Error("missing context map media path");
|
||||
}
|
||||
try {
|
||||
const png = await readFile(result.mediaUrl);
|
||||
expect(result.text).toContain("Context treemap");
|
||||
expect(result.text).toContain("Source: run");
|
||||
expect(result.text).toContain("Actual cached context: 900 tok");
|
||||
expect(result.trustedLocalMedia).toBe(true);
|
||||
expect(result.sensitiveMedia).toBe(true);
|
||||
expect(png.subarray(0, 8)).toEqual(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]));
|
||||
expect(png.subarray(12, 16).toString("ascii")).toBe("IHDR");
|
||||
expect(png.readUInt32BE(16)).toBe(1280);
|
||||
expect(png.readUInt32BE(20)).toBe(860);
|
||||
} finally {
|
||||
await unlink(result.mediaUrl);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user