Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(frontend): show profile popover avatar image (#13155)

Abhimanyu Yadav39fcbebe7402
diff --git a/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx
index 5fe629ee88..dce530d382 100644
--- a/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx
+++ b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx
@@ -12,10 +12,15 @@ export function InitialAvatar({ src, name, className }: Props) {
return (
<Avatar className={cn("h-10 w-10", className)}>
- <div className="absolute inset-0 flex items-center justify-center bg-violet-500 text-sm font-semibold text-white">
+ <div className="absolute inset-0 z-0 flex items-center justify-center bg-violet-500 text-sm font-semibold text-white">
{initial}
</div>
- <AvatarImage src={src} alt="" aria-hidden="true" />
+ <AvatarImage
+ src={src}
+ alt=""
+ aria-hidden="true"
+ className="relative z-10"
+ />
</Avatar>
);
}
diff --git a/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
index 3891f72074..f8ecaf54e2 100644
--- a/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
+++ b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
@@ -1,4 +1,4 @@
-import { render, screen } from "@/tests/integrations/test-utils";
+import { render, screen, waitFor } from "@/tests/integrations/test-utils";
import { describe, expect, test } from "vitest";
import { InitialAvatar } from "../InitialAvatar";
@@ -25,10 +25,23 @@ describe("InitialAvatar", () => {
test("merges className prop into the avatar root", () => {
const { container } = render(
- <InitialAvatar name="ada" className="h-12 w-12" />,
+ <InitialAvatar name="ada" className="size-12" />,
);
const root = container.firstChild as HTMLElement;
- expect(root.className).toContain("h-12");
- expect(root.className).toContain("w-12");
+ expect(root.className).toContain("size-12");
+ });
+
+ test("places image above the initial fallback when src is provided", async () => {
+ const { container } = render(
+ <InitialAvatar name="ada" src="https://example.com/avatar.png" />,
+ );
+
+ await waitFor(() => {
+ expect(container.querySelector("img")).not.toBeNull();
+ });
+
+ const image = container.querySelector("img");
+ expect(image?.className).toContain("z-10");
+ expect(screen.getByText("A").className).toContain("z-0");
});
});