Media: add attachment root regression tests

This commit is contained in:
Vincent Koc
2026-03-07 09:19:24 -08:00
parent df2db2175e
commit 078e622161

View 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")));
});
});