Files
PaperClipAI/ui/src/components/AgentAvatar.test.tsx
T
TonioandPaperclip 9dfdeaad86 Refine agent workspaces and organization charts (#20973)
Refine agent details, identity editing, responsive controls, and organization charts with three card tiers, clearer save feedback, and stable filtering.

Guard instruction-file renames and root configuration updates in one transaction through the agent lifecycle integration, preserving conflict checks, rollback, and configuration history.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-11-12 01:23:59 +00:00

28 lines
1.5 KiB
TypeScript

// @vitest-environment jsdom
import { act } from "react";
import { createRoot } from "react-dom/client";
import { expect, it } from "vitest";
import { appearanceForPalette } from "@paperclipai/shared";
import { AgentAvatar } from "./AgentAvatar";
import { AgentCharacter } from "./AgentCharacter";
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
it("shows the uploaded image in small and animated-character surfaces, then returns to the palette on reset", async () => {
const base = appearanceForPalette("deep-tide");
const appearance = { ...base, customAvatarAssetId: "22222222-2222-4222-8222-222222222222" };
const container = document.createElement("div");
const root = createRoot(container);
try {
await act(async () => root.render(<><AgentAvatar appearance={appearance} view="portrait" /><AgentCharacter appearance={appearance} /></>));
for (const image of container.querySelectorAll("img")) {
expect(image.getAttribute("src")).toBe("/api/assets/22222222-2222-4222-8222-222222222222/content");
expect(image.hasAttribute("srcset")).toBe(false);
expect(image.parentElement?.classList.contains("invisible")).toBe(false);
}
expect(container.querySelectorAll("img")).toHaveLength(2);
expect(container.querySelector("canvas")).toBeNull();
await act(async () => root.render(<AgentAvatar appearance={base} />));
expect(container.querySelector("img")?.getAttribute("src")).toContain("/api/agent-avatars/cap-v1/deep-tide/");
} finally { await act(async () => root.unmount()); }
});