mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-30 04:16:25 +00:00
Media: add attachment root regression tests
This commit is contained in:
44
src/media/local-roots.test.ts
Normal file
44
src/media/local-roots.test.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { resolveStateDir } from "../config/paths.js";
|
||||
import { resolveUserPath } from "../utils.js";
|
||||
import { getAgentScopedMediaLocalRoots } from "./local-roots.js";
|
||||
|
||||
describe("getAgentScopedMediaLocalRoots", () => {
|
||||
it("merges iMessage attachment roots into the agent-scoped allowlist", () => {
|
||||
const cfg: OpenClawConfig = {
|
||||
channels: {
|
||||
imessage: {
|
||||
attachmentRoots: ["/Users/*/Library/Messages/Attachments"],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
expect(getAgentScopedMediaLocalRoots(cfg)).toContain("/Users/*/Library/Messages/Attachments");
|
||||
});
|
||||
|
||||
it("adds the resolved agent workspace without dropping attachment roots", () => {
|
||||
const cfg: OpenClawConfig = {
|
||||
channels: {
|
||||
imessage: {
|
||||
attachmentRoots: ["/tmp/imessage-attachments"],
|
||||
},
|
||||
},
|
||||
agents: {
|
||||
list: [
|
||||
{
|
||||
id: "clawdy",
|
||||
workspace: "~/agent-workspace",
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
const roots = getAgentScopedMediaLocalRoots(cfg, "clawdy");
|
||||
|
||||
expect(roots).toContain("/tmp/imessage-attachments");
|
||||
expect(roots).toContain(path.resolve(resolveStateDir(), "workspace"));
|
||||
expect(roots).toContain(path.resolve(resolveUserPath("~/agent-workspace")));
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user