mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:40:44 +00:00
test: dedupe avatar fixture setup
This commit is contained in:
@@ -34,6 +34,20 @@ async function createTempAvatarRoot() {
|
||||
return root;
|
||||
}
|
||||
|
||||
async function setupUiAndConfigAvatarWorkspace() {
|
||||
const root = await createTempAvatarRoot();
|
||||
const workspace = path.join(root, "work");
|
||||
const uiAvatarPath = path.join(workspace, "ui-avatar.png");
|
||||
const cfgAvatarPath = path.join(workspace, "cfg-avatar.png");
|
||||
await writeFile(uiAvatarPath);
|
||||
await writeFile(cfgAvatarPath);
|
||||
const cfg: OpenClawConfig = {
|
||||
ui: { assistant: { avatar: "ui-avatar.png" } },
|
||||
agents: { list: [{ id: "main", workspace, identity: { avatar: "cfg-avatar.png" } }] },
|
||||
};
|
||||
return { cfg, workspace };
|
||||
}
|
||||
|
||||
afterEach(async () => {
|
||||
await Promise.all(
|
||||
tempRoots.splice(0).map((root) => fs.rm(root, { recursive: true, force: true })),
|
||||
@@ -179,34 +193,14 @@ describe("resolveAgentAvatar", () => {
|
||||
});
|
||||
|
||||
it("ui.assistant.avatar ignored without includeUiOverride (outbound callers)", async () => {
|
||||
const root = await createTempAvatarRoot();
|
||||
const workspace = path.join(root, "work");
|
||||
const uiAvatarPath = path.join(workspace, "ui-avatar.png");
|
||||
const cfgAvatarPath = path.join(workspace, "cfg-avatar.png");
|
||||
await writeFile(uiAvatarPath);
|
||||
await writeFile(cfgAvatarPath);
|
||||
|
||||
const cfg: OpenClawConfig = {
|
||||
ui: { assistant: { avatar: "ui-avatar.png" } },
|
||||
agents: { list: [{ id: "main", workspace, identity: { avatar: "cfg-avatar.png" } }] },
|
||||
};
|
||||
const { cfg, workspace } = await setupUiAndConfigAvatarWorkspace();
|
||||
|
||||
// Without the opt-in, outbound callers get the per-agent identity avatar, not the UI override.
|
||||
await expectLocalAvatarPath(cfg, workspace, "cfg-avatar.png");
|
||||
});
|
||||
|
||||
it("ui.assistant.avatar takes priority over agents.list identity.avatar with includeUiOverride", async () => {
|
||||
const root = await createTempAvatarRoot();
|
||||
const workspace = path.join(root, "work");
|
||||
const uiAvatarPath = path.join(workspace, "ui-avatar.png");
|
||||
const cfgAvatarPath = path.join(workspace, "cfg-avatar.png");
|
||||
await writeFile(uiAvatarPath);
|
||||
await writeFile(cfgAvatarPath);
|
||||
|
||||
const cfg: OpenClawConfig = {
|
||||
ui: { assistant: { avatar: "ui-avatar.png" } },
|
||||
agents: { list: [{ id: "main", workspace, identity: { avatar: "cfg-avatar.png" } }] },
|
||||
};
|
||||
const { cfg, workspace } = await setupUiAndConfigAvatarWorkspace();
|
||||
|
||||
await expectLocalAvatarPath(cfg, workspace, "ui-avatar.png", { includeUiOverride: true });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user