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.

feat(frontend): redesign profile popover (SECRT-2360) (#13138)

Abhimanyu Yadav61d4f2b68f46
diff --git a/autogpt_platform/frontend/src/components/__legacy__/ui/icons.tsx b/autogpt_platform/frontend/src/components/__legacy__/ui/icons.tsx
index d62f369e6f..cdc3abac7d 100644
--- a/autogpt_platform/frontend/src/components/__legacy__/ui/icons.tsx
+++ b/autogpt_platform/frontend/src/components/__legacy__/ui/icons.tsx
@@ -1838,6 +1838,8 @@ export enum IconType {
AutoGPTLogo,
Sliders,
Chat,
+ Billing,
+ Help,
}
export function getIconForSocial(
diff --git a/autogpt_platform/frontend/src/components/layout/Navbar/Navbar.tsx b/autogpt_platform/frontend/src/components/layout/Navbar/Navbar.tsx
index 149cf12507..8272af5bc8 100644
--- a/autogpt_platform/frontend/src/components/layout/Navbar/Navbar.tsx
+++ b/autogpt_platform/frontend/src/components/layout/Navbar/Navbar.tsx
@@ -97,8 +97,8 @@ export function Navbar() {
<AgentActivityDropdown />
{profile && <Wallet key={profile.username} />}
<AccountMenu
- userName={profile?.username}
- userEmail={profile?.name}
+ userName={profile?.name || profile?.username}
+ userEmail={user?.email}
avatarSrc={profile?.avatar_url ?? ""}
menuItemGroups={dynamicMenuItems}
isLoading={isLoadingProfile}
diff --git a/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/AccountMenu.stories.tsx b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/AccountMenu.stories.tsx
new file mode 100644
index 0000000000..29c1a2eec1
--- /dev/null
+++ b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/AccountMenu.stories.tsx
@@ -0,0 +1,100 @@
+import { IconType } from "@/components/__legacy__/ui/icons";
+import type { Meta, StoryObj } from "@storybook/nextjs";
+import { AccountMenu } from "./AccountMenu";
+
+const meta: Meta<typeof AccountMenu> = {
+ title: "Layout/Navbar/AccountMenu",
+ component: AccountMenu,
+ parameters: {
+ layout: "centered",
+ },
+};
+
+export default meta;
+type Story = StoryObj<typeof AccountMenu>;
+
+const userGroups = [
+ {
+ items: [
+ {
+ icon: IconType.Edit,
+ text: "Profile",
+ href: "/settings/profile",
+ },
+ {
+ icon: IconType.Settings,
+ text: "Settings",
+ href: "/settings/account",
+ },
+ {
+ icon: IconType.Billing,
+ text: "Billing",
+ href: "/settings/billing",
+ },
+ {
+ icon: IconType.LayoutDashboard,
+ text: "Creator Dashboard",
+ href: "/settings/creator-dashboard",
+ },
+ {
+ icon: IconType.Help,
+ text: "Help & Docs",
+ href: "https://agpt.co/docs",
+ external: true,
+ },
+ ],
+ },
+ {
+ items: [
+ {
+ icon: IconType.LogOut,
+ text: "Log out",
+ },
+ ],
+ },
+];
+
+const adminGroups = [
+ userGroups[0],
+ {
+ items: [
+ {
+ icon: IconType.Sliders,
+ text: "Admin",
+ href: "/admin/marketplace",
+ },
+ ],
+ },
+ userGroups[1],
+];
+
+export const Default: Story = {
+ args: {
+ userName: "abhimanyu",
+ userEmail: "[email protected]",
+ menuItemGroups: userGroups,
+ },
+};
+
+export const AdminUser: Story = {
+ args: {
+ userName: "abhimanyu",
+ userEmail: "[email protected]",
+ menuItemGroups: adminGroups,
+ },
+};
+
+export const Loading: Story = {
+ args: {
+ isLoading: true,
+ menuItemGroups: userGroups,
+ },
+};
+
+export const LongValues: Story = {
+ args: {
+ userName: "a-really-long-username-that-should-truncate",
+ userEmail: "[email protected]",
+ menuItemGroups: userGroups,
+ },
+};
diff --git a/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/AccountMenu.tsx b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/AccountMenu.tsx
index ec1aeacab5..a0c8f3cc6a 100644
--- a/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/AccountMenu.tsx
+++ b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/AccountMenu.tsx
@@ -1,18 +1,15 @@
+import { Skeleton } from "@/components/atoms/Skeleton/Skeleton";
import {
Popover,
PopoverContent,
PopoverTrigger,
-} from "@/components/__legacy__/ui/popover";
-import { Skeleton } from "@/components/__legacy__/ui/skeleton";
-import Avatar, {
- AvatarFallback,
- AvatarImage,
-} from "@/components/atoms/Avatar/Avatar";
-import { PublishAgentModal } from "@/components/contextual/PublishAgentModal/PublishAgentModal";
-import Link from "next/link";
+} from "@/components/molecules/Popover/Popover";
import * as React from "react";
-import { getAccountMenuOptionIcon, MenuItemGroup } from "../../helpers";
+import { MenuItemGroup } from "../../helpers";
import { AccountLogoutOption } from "./components/AccountLogoutOption";
+import { AccountMenuRow } from "./components/AccountMenuRow";
+import { InitialAvatar } from "./components/InitialAvatar";
+import { getAccountMenuPhosphorIcon } from "./helpers";
interface Props {
userName?: string;
@@ -37,118 +34,89 @@ export function AccountMenu({
<PopoverTrigger asChild>
<button
type="button"
- className="flex cursor-pointer items-center space-x-3"
+ className="flex cursor-pointer items-center space-x-3 rounded-full outline-none focus-visible:ring-2 focus-visible:ring-neutral-300"
aria-label="Open profile menu"
aria-controls={popupId}
aria-haspopup="true"
data-testid="profile-popout-menu-trigger"
>
- <Avatar>
- <AvatarImage src={avatarSrc} alt="" aria-hidden="true" />
- <AvatarFallback aria-hidden="true">
- {userName?.charAt(0) || "U"}
- </AvatarFallback>
- </Avatar>
+ <InitialAvatar src={avatarSrc} name={userName} className="h-8 w-8" />
</button>
</PopoverTrigger>
<PopoverContent
id={popupId}
- className="flex flex-col items-start justify-start gap-4 rounded-[26px] bg-zinc-400/65 p-4 shadow backdrop-blur-[10px] dark:bg-zinc-800/70"
+ align="end"
+ sideOffset={8}
+ className="w-64 overflow-hidden rounded-2xl border border-neutral-200 bg-white p-0 shadow-lg"
data-testid="account-menu-popover"
>
- {/* Header with avatar and user info */}
- <div className="inline-flex items-center justify-start gap-1 self-stretch">
- <Avatar className="h-[60px] w-[60px]">
- <AvatarImage src={avatarSrc} alt="" aria-hidden="true" />
- <AvatarFallback aria-hidden="true">
- {userName?.charAt(0) || "U"}
- </AvatarFallback>
- </Avatar>
- <div className="relative flex h-[47px] w-[173px] flex-col items-start justify-center gap-1">
+ <div className="flex items-center gap-3 px-4 py-3">
+ <InitialAvatar src={avatarSrc} name={userName} />
+ <div className="flex min-w-0 flex-1 flex-col gap-1">
{isLoading || !userName || !userEmail ? (
<>
- <Skeleton className="h-4 w-24 bg-white/40" />
- <Skeleton className="h-4 w-32 bg-white/40" />
+ <Skeleton className="h-3.5 w-24" />
+ <Skeleton className="h-3 w-32" />
</>
) : (
<>
- <div className="max-w-[10.5rem] truncate font-sans text-base font-semibold leading-none text-white dark:text-neutral-200">
+ <span className="truncate text-sm font-semibold leading-tight text-neutral-900">
{userName}
- </div>
- <div
+ </span>
+ <span
data-testid="account-menu-user-email"
- className="max-w-[10.5rem] truncate font-sans text-base font-normal leading-none text-white dark:text-neutral-400"
+ className="truncate text-sm leading-tight text-neutral-700"
>
{userEmail}
- </div>
+ </span>
</>
)}
</div>
</div>
- {/* Menu items */}
- <div className="flex w-full flex-col items-start justify-start gap-2 rounded-[23px]">
- {menuItemGroups.map((group, groupIndex) => (
- <div
- key={groupIndex}
- className="flex w-full flex-col items-start justify-start gap-5 rounded-[18px] bg-white p-3.5 dark:bg-neutral-900"
- >
- {group.items.map((item, itemIndex) => {
- if (item.href) {
+ <div className="border-t border-neutral-100 p-2">
+ <ul className="flex flex-col gap-0.5">
+ {menuItemGroups.map((group, groupIndex) =>
+ group.items.map((item, itemIndex) => {
+ const key = `${groupIndex}-${itemIndex}-${item.text}`;
+ const icon = getAccountMenuPhosphorIcon(item.icon);
+
+ if (item.text === "Log out") {
return (
- <Link
- key={itemIndex}
- href={item.href}
- className="inline-flex w-full items-center justify-start gap-2.5"
- >
- <div className="relative">
- {getAccountMenuOptionIcon(item.icon)}
- </div>
- <div className="font-sans text-base font-medium leading-normal text-neutral-800 dark:text-neutral-200">
- {item.text}
- </div>
- </Link>
+ <li key={key}>
+ <AccountLogoutOption />
+ </li>
);
- } else if (item.text === "Log out") {
- return <AccountLogoutOption key={itemIndex} />;
- } else if (item.text === "Publish an agent") {
- return (
- <PublishAgentModal
- key={itemIndex}
- trigger={
- <div className="inline-flex w-full flex-row flex-nowrap items-center justify-start gap-2.5">
- <div className="relative">
- {getAccountMenuOptionIcon(item.icon)}
- </div>
- <div className="font-sans text-base font-medium leading-normal text-neutral-800">
- {item.text}
- </div>
- </div>
- }
- />
- );
- } else {
+ }
+
+ if (item.href) {
return (
- <div
- key={itemIndex}
- className="inline-flex w-full items-center justify-start gap-2.5"
- onClick={item.onClick}
- role="button"
- tabIndex={0}
- >
- <div className="relative">
- {getAccountMenuOptionIcon(item.icon)}
- </div>
- <div className="font-sans text-base font-medium leading-normal text-neutral-800 dark:text-neutral-200">
- {item.text}
- </div>
- </div>
+ <li key={key}>
+ <AccountMenuRow
+ as="link"
+ href={item.href}
+ external={item.external}
+ icon={icon}
+ label={item.text}
+ />
+ </li>
);
}
- })}
- </div>
- ))}
+
+ return (
+ <li key={key}>
+ <AccountMenuRow
+ as="button"
+ onClick={item.onClick}
+ icon={icon}
+ label={item.text}
+ />
+ </li>
+ );
+ }),
+ )}
+ </ul>
</div>
</PopoverContent>
</Popover>
diff --git a/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/__tests__/AccountMenu.test.tsx b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/__tests__/AccountMenu.test.tsx
new file mode 100644
index 0000000000..0653387d24
--- /dev/null
+++ b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/__tests__/AccountMenu.test.tsx
@@ -0,0 +1,149 @@
+import { IconType } from "@/components/__legacy__/ui/icons";
+import { render, screen } from "@/tests/integrations/test-utils";
+import { describe, expect, test, vi } from "vitest";
+import { AccountMenu } from "../AccountMenu";
+import { MenuItemGroup } from "../../../helpers";
+
+vi.mock("next/link", () => ({
+ __esModule: true,
+ default: ({ children, href, ...props }: any) => (
+ <a href={href} {...props}>
+ {children}
+ </a>
+ ),
+ useLinkStatus: () => ({ pending: false }),
+}));
+
+vi.mock("@/components/molecules/Popover/Popover", () => {
+ function Popover({ children }: { children: React.ReactNode }) {
+ return <div>{children}</div>;
+ }
+ function PopoverTrigger({ children }: { children: React.ReactNode }) {
+ return <div>{children}</div>;
+ }
+ function PopoverContent({ children }: { children: React.ReactNode }) {
+ return <div>{children}</div>;
+ }
+ return { Popover, PopoverTrigger, PopoverContent };
+});
+
+const baseGroups: MenuItemGroup[] = [
+ {
+ items: [
+ {
+ icon: IconType.Edit,
+ text: "Profile",
+ href: "/settings/profile",
+ },
+ {
+ icon: IconType.Settings,
+ text: "Settings",
+ href: "/settings/account",
+ },
+ {
+ icon: IconType.Help,
+ text: "Help & Docs",
+ href: "https://agpt.co/docs",
+ external: true,
+ },
+ ],
+ },
+ {
+ items: [
+ {
+ icon: IconType.UploadCloud,
+ text: "Publish an agent",
+ onClick: vi.fn(),
+ },
+ ],
+ },
+ {
+ items: [
+ {
+ icon: IconType.LogOut,
+ text: "Log out",
+ },
+ ],
+ },
+];
+
+describe("AccountMenu", () => {
+ test("renders user name and email when loaded", () => {
+ render(
+ <AccountMenu
+ userName="Ada Lovelace"
+ userEmail="[email protected]"
+ menuItemGroups={baseGroups}
+ />,
+ );
+
+ expect(screen.getByText("Ada Lovelace")).toBeDefined();
+ expect(screen.getByTestId("account-menu-user-email").textContent).toBe(
+ );
+ });
+
+ test("renders skeleton loaders when loading", () => {
+ const { container } = render(
+ <AccountMenu
+ userName="Ada"
+ userEmail="[email protected]"
+ menuItemGroups={baseGroups}
+ isLoading
+ />,
+ );
+
+ expect(screen.queryByText("Ada")).toBeNull();
+ expect(container.querySelectorAll(".animate-pulse").length).toBeGreaterThan(
+ 0,
+ );
+ });
+
+ test("renders skeleton when userName/email are missing", () => {
+ render(<AccountMenu menuItemGroups={baseGroups} />);
+ expect(screen.queryByTestId("account-menu-user-email")).toBeNull();
+ });
+
+ test("renders all menu items including links, buttons and logout", () => {
+ render(
+ <AccountMenu
+ userName="Ada"
+ userEmail="[email protected]"
+ menuItemGroups={baseGroups}
+ />,
+ );
+
+ expect(screen.getByText("Profile")).toBeDefined();
+ expect(screen.getByText("Settings")).toBeDefined();
+ expect(screen.getByText("Help & Docs")).toBeDefined();
+ expect(screen.getByText("Publish an agent")).toBeDefined();
+ expect(screen.getByText("Log out")).toBeDefined();
+ });
+
+ test("renders external link with target=_blank", () => {
+ render(
+ <AccountMenu
+ userName="Ada"
+ userEmail="[email protected]"
+ menuItemGroups={baseGroups}
+ />,
+ );
+
+ const helpLink = screen.getByText("Help & Docs").closest("a");
+ expect(helpLink?.getAttribute("target")).toBe("_blank");
+ expect(helpLink?.getAttribute("rel")).toBe("noopener noreferrer");
+ });
+
+ test("renders profile trigger with avatar fallback", () => {
+ render(
+ <AccountMenu
+ userName="Ada"
+ userEmail="[email protected]"
+ menuItemGroups={baseGroups}
+ />,
+ );
+
+ expect(screen.getByTestId("profile-popout-menu-trigger")).toBeDefined();
+ expect(screen.getAllByText("A").length).toBeGreaterThan(0);
+ });
+});
diff --git a/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/__tests__/helpers.test.tsx b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/__tests__/helpers.test.tsx
new file mode 100644
index 0000000000..8285da48c2
--- /dev/null
+++ b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/__tests__/helpers.test.tsx
@@ -0,0 +1,24 @@
+import { IconType } from "@/components/__legacy__/ui/icons";
+import { describe, expect, test } from "vitest";
+import { getAccountMenuPhosphorIcon } from "../helpers";
+
+describe("getAccountMenuPhosphorIcon", () => {
+ test.each([
+ IconType.Edit,
+ IconType.LayoutDashboard,
+ IconType.UploadCloud,
+ IconType.Sliders,
+ IconType.Settings,
+ IconType.Billing,
+ IconType.Help,
+ IconType.LogOut,
+ ])("returns a Phosphor icon element for %s", (icon) => {
+ const result = getAccountMenuPhosphorIcon(icon);
+ expect(result).not.toBeNull();
+ });
+
+ test("returns null for unmapped icon types", () => {
+ const result = getAccountMenuPhosphorIcon(IconType.Chat);
+ expect(result).toBeNull();
+ });
+});
diff --git a/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/AccountLogoutOption.tsx b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/AccountLogoutOption.tsx
index d65b07bd48..9e2afac94d 100644
--- a/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/AccountLogoutOption.tsx
+++ b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/AccountLogoutOption.tsx
@@ -1,26 +1,24 @@
"use client";
-import { IconLogOut } from "@/components/__legacy__/ui/icons";
+import { SignOutIcon } from "@phosphor-icons/react";
import { useRouter } from "next/navigation";
+import { AccountMenuRow } from "./AccountMenuRow";
export function AccountLogoutOption() {
const router = useRouter();
- async function handleLogout() {
+ function handleLogout() {
router.replace("/logout");
}
return (
- <button
- className="inline-flex w-full items-center justify-start gap-2.5"
+ <AccountMenuRow
+ as="button"
+ destructive
+ label="Log out"
+ icon={
+ <SignOutIcon className="h-[18px] w-[18px] shrink-0" weight="bold" />
+ }
onClick={handleLogout}
- type="button"
- >
- <div className="relative h-4 w-4">
- <IconLogOut />
- </div>
- <div className="font-sans text-base font-medium leading-normal text-neutral-800 dark:text-neutral-200">
- Log out
- </div>
- </button>
+ />
);
}
diff --git a/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/AccountMenuRow.tsx b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/AccountMenuRow.tsx
new file mode 100644
index 0000000000..a9de0f0d5d
--- /dev/null
+++ b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/AccountMenuRow.tsx
@@ -0,0 +1,112 @@
+import { LoadingSpinner } from "@/components/atoms/LoadingSpinner/LoadingSpinner";
+import { cn } from "@/lib/utils";
+import Link, { useLinkStatus } from "next/link";
+import * as React from "react";
+
+interface Props {
+ icon: React.ReactNode;
+ label: string;
+ href?: string;
+ onClick?: () => void;
+ destructive?: boolean;
+ as?: "link" | "button";
+ external?: boolean;
+}
+
+const baseRowClasses =
+ "group relative flex w-full items-center gap-3 rounded-lg pl-3 pr-2 py-2 text-left text-sm font-medium outline-none transition-colors duration-200 ease-out focus-visible:outline-none";
+
+function RowBody({
+ icon,
+ label,
+ destructive,
+ pending = false,
+}: {
+ icon: React.ReactNode;
+ label: string;
+ destructive: boolean;
+ pending?: boolean;
+}) {
+ const barClasses = destructive
+ ? "absolute left-0 top-1/2 -translate-y-1/2 w-[3px] h-5 rounded-full bg-red-500 opacity-0 transition-opacity duration-200 group-hover:opacity-100 group-focus-visible:opacity-100"
+ : "absolute left-0 top-1/2 -translate-y-1/2 w-[3px] h-5 rounded-full bg-neutral-900 opacity-0 transition-opacity duration-200 group-hover:opacity-100 group-focus-visible:opacity-100";
+
+ return (
+ <>
+ <span className={barClasses} aria-hidden="true" />
+ <span className="relative z-10 flex shrink-0 items-center">{icon}</span>
+ <span className="relative z-10 flex-1 truncate">{label}</span>
+ {pending ? (
+ <LoadingSpinner
+ size="small"
+ className="relative z-10 text-current"
+ aria-hidden="true"
+ />
+ ) : null}
+ </>
+ );
+}
+
+function LinkRowBody({
+ icon,
+ label,
+ destructive,
+}: {
+ icon: React.ReactNode;
+ label: string;
+ destructive: boolean;
+}) {
+ const { pending } = useLinkStatus();
+ return (
+ <RowBody
+ icon={icon}
+ label={label}
+ destructive={destructive}
+ pending={pending}
+ />
+ );
+}
+
+export function AccountMenuRow({
+ icon,
+ label,
+ href,
+ onClick,
+ destructive = false,
+ as = "link",
+ external = false,
+}: Props) {
+ const colorClasses = destructive
+ ? "text-neutral-700 hover:bg-red-50 hover:text-red-600 focus-visible:bg-red-50 focus-visible:text-red-600"
+ : "text-neutral-700 hover:bg-neutral-100 focus-visible:bg-neutral-100";
+
+ if (as === "link" && href) {
+ if (external) {
+ return (
+ <a
+ href={href}
+ target="_blank"
+ rel="noopener noreferrer"
+ className={cn(baseRowClasses, colorClasses)}
+ >
+ <RowBody icon={icon} label={label} destructive={destructive} />
+ </a>
+ );
+ }
+ return (
+ <Link href={href} className={cn(baseRowClasses, colorClasses)}>
+ <LinkRowBody icon={icon} label={label} destructive={destructive} />
+ </Link>
+ );
+ }
+
+ return (
+ <button
+ type="button"
+ onClick={onClick}
+ className={cn(baseRowClasses, colorClasses)}
+ >
+ <RowBody icon={icon} label={label} destructive={destructive} />
+ </button>
+ );
+}
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
new file mode 100644
index 0000000000..5fe629ee88
--- /dev/null
+++ b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx
@@ -0,0 +1,21 @@
+import Avatar, { AvatarImage } from "@/components/atoms/Avatar/Avatar";
+import { cn } from "@/lib/utils";
+
+interface Props {
+ src?: string;
+ name?: string;
+ className?: string;
+}
+
+export function InitialAvatar({ src, name, className }: Props) {
+ const initial = name?.trim().charAt(0).toUpperCase() || "U";
+
+ 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">
+ {initial}
+ </div>
+ <AvatarImage src={src} alt="" aria-hidden="true" />
+ </Avatar>
+ );
+}
diff --git a/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/AccountLogoutOption.test.tsx b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/AccountLogoutOption.test.tsx
new file mode 100644
index 0000000000..17489b7177
--- /dev/null
+++ b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/AccountLogoutOption.test.tsx
@@ -0,0 +1,43 @@
+import { fireEvent, render, screen } from "@/tests/integrations/test-utils";
+import { describe, expect, test, vi } from "vitest";
+import { AccountLogoutOption } from "../AccountLogoutOption";
+
+const replaceMock = vi.fn();
+
+vi.mock("next/navigation", () => ({
+ useRouter: () => ({
+ push: vi.fn(),
+ replace: replaceMock,
+ prefetch: vi.fn(),
+ back: vi.fn(),
+ forward: vi.fn(),
+ refresh: vi.fn(),
+ }),
+ usePathname: () => "/",
+ useSearchParams: () => new URLSearchParams(),
+}));
+
+vi.mock("next/link", () => ({
+ __esModule: true,
+ default: ({ children, href, ...props }: any) => (
+ <a href={href} {...props}>
+ {children}
+ </a>
+ ),
+ useLinkStatus: () => ({ pending: false }),
+}));
+
+describe("AccountLogoutOption", () => {
+ test("renders a destructive Log out button", () => {
+ render(<AccountLogoutOption />);
+ const button = screen.getByRole("button", { name: /log out/i });
+ expect(button.tagName).toBe("BUTTON");
+ expect(button.className).toContain("hover:bg-red-50");
+ });
+
+ test("calls router.replace('/logout') when clicked", () => {
+ render(<AccountLogoutOption />);
+ fireEvent.click(screen.getByRole("button", { name: /log out/i }));
+ expect(replaceMock).toHaveBeenCalledWith("/logout");
+ });
+});
diff --git a/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/AccountMenuRow.test.tsx b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/AccountMenuRow.test.tsx
new file mode 100644
index 0000000000..e479086253
--- /dev/null
+++ b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/AccountMenuRow.test.tsx
@@ -0,0 +1,119 @@
+import { fireEvent, render, screen } from "@/tests/integrations/test-utils";
+import { describe, expect, test, vi } from "vitest";
+import { AccountMenuRow } from "../AccountMenuRow";
+
+vi.mock("next/link", () => ({
+ __esModule: true,
+ default: ({ children, href, ...props }: any) => (
+ <a href={href} {...props}>
+ {children}
+ </a>
+ ),
+ useLinkStatus: () => ({ pending: false }),
+}));
+
+describe("AccountMenuRow", () => {
+ test("renders as internal link with href when as=link", () => {
+ render(
+ <AccountMenuRow
+ as="link"
+ href="/settings"
+ icon={<span data-testid="icon" />}
+ label="Settings"
+ />,
+ );
+
+ const link = screen.getByText("Settings").closest("a");
+ expect(link).not.toBeNull();
+ expect(link?.getAttribute("href")).toBe("/settings");
+ expect(link?.getAttribute("target")).toBeNull();
+ expect(screen.getByTestId("icon")).toBeDefined();
+ });
+
+ test("renders as external anchor with target=_blank when external=true", () => {
+ render(
+ <AccountMenuRow
+ as="link"
+ href="https://example.com"
+ external
+ icon={<span />}
+ label="Docs"
+ />,
+ );
+
+ const anchor = screen.getByText("Docs").closest("a");
+ expect(anchor?.getAttribute("target")).toBe("_blank");
+ expect(anchor?.getAttribute("rel")).toBe("noopener noreferrer");
+ });
+
+ test("renders as button when as=button and triggers onClick", () => {
+ const onClick = vi.fn();
+ render(
+ <AccountMenuRow
+ as="button"
+ onClick={onClick}
+ icon={<span />}
+ label="Publish"
+ />,
+ );
+
+ const button = screen.getByRole("button", { name: /publish/i });
+ expect(button.tagName).toBe("BUTTON");
+ fireEvent.click(button);
+ expect(onClick).toHaveBeenCalledTimes(1);
+ });
+
+ test("falls back to button when as=link but no href provided", () => {
+ const onClick = vi.fn();
+ render(
+ <AccountMenuRow
+ as="link"
+ onClick={onClick}
+ icon={<span />}
+ label="No href"
+ />,
+ );
+
+ const button = screen.getByRole("button", { name: /no href/i });
+ expect(button.tagName).toBe("BUTTON");
+ fireEvent.click(button);
+ expect(onClick).toHaveBeenCalled();
+ });
+
+ test("applies destructive classes when destructive=true", () => {
+ render(
+ <AccountMenuRow
+ as="button"
+ destructive
+ icon={<span />}
+ label="Log out"
+ />,
+ );
+
+ const button = screen.getByRole("button", { name: /log out/i });
+ expect(button.className).toContain("hover:bg-red-50");
+ });
+
+ test("shows pending spinner when useLinkStatus returns pending", async () => {
+ vi.resetModules();
+ vi.doMock("next/link", () => ({
+ __esModule: true,
+ default: ({ children, href, ...props }: any) => (
+ <a href={href} {...props}>
+ {children}
+ </a>
+ ),
+ useLinkStatus: () => ({ pending: true }),
+ }));
+
+ const { AccountMenuRow: PendingRow } = await import("../AccountMenuRow");
+
+ render(
+ <PendingRow as="link" href="/foo" icon={<span />} label="Loading link" />,
+ );
+
+ const link = screen.getByText("Loading link").closest("a");
+ expect(link?.querySelector("svg")).not.toBeNull();
+ vi.doUnmock("next/link");
+ });
+});
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
new file mode 100644
index 0000000000..3891f72074
--- /dev/null
+++ b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
@@ -0,0 +1,34 @@
+import { render, screen } from "@/tests/integrations/test-utils";
+import { describe, expect, test } from "vitest";
+import { InitialAvatar } from "../InitialAvatar";
+
+describe("InitialAvatar", () => {
+ test("renders uppercase first character of name", () => {
+ render(<InitialAvatar name="abhimanyu" />);
+ expect(screen.getByText("A")).toBeDefined();
+ });
+
+ test("trims whitespace before extracting initial", () => {
+ render(<InitialAvatar name=" beth" />);
+ expect(screen.getByText("B")).toBeDefined();
+ });
+
+ test("falls back to 'U' when name is missing", () => {
+ render(<InitialAvatar />);
+ expect(screen.getByText("U")).toBeDefined();
+ });
+
+ test("falls back to 'U' when name is an empty string", () => {
+ render(<InitialAvatar name="" />);
+ expect(screen.getByText("U")).toBeDefined();
+ });
+
+ test("merges className prop into the avatar root", () => {
+ const { container } = render(
+ <InitialAvatar name="ada" className="h-12 w-12" />,
+ );
+ const root = container.firstChild as HTMLElement;
+ expect(root.className).toContain("h-12");
+ expect(root.className).toContain("w-12");
+ });
+});
diff --git a/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/helpers.tsx b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/helpers.tsx
new file mode 100644
index 0000000000..e0fc0b3914
--- /dev/null
+++ b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/helpers.tsx
@@ -0,0 +1,36 @@
+import { IconType } from "@/components/__legacy__/ui/icons";
+import {
+ ChartLineUpIcon,
+ CreditCardIcon,
+ GearIcon,
+ QuestionIcon,
+ SignOutIcon,
+ SlidersHorizontalIcon,
+ UploadSimpleIcon,
+ UserIcon,
+} from "@phosphor-icons/react";
+
+export function getAccountMenuPhosphorIcon(icon: IconType) {
+ const className = "h-[18px] w-[18px] shrink-0";
+ const weight = "bold";
+ switch (icon) {
+ case IconType.Edit:
+ return <UserIcon className={className} weight={weight} />;
+ case IconType.LayoutDashboard:
+ return <ChartLineUpIcon className={className} weight={weight} />;
+ case IconType.UploadCloud:
+ return <UploadSimpleIcon className={className} weight={weight} />;
+ case IconType.Sliders:
+ return <SlidersHorizontalIcon className={className} weight={weight} />;
+ case IconType.Settings:
+ return <GearIcon className={className} weight={weight} />;
+ case IconType.Billing:
+ return <CreditCardIcon className={className} weight={weight} />;
+ case IconType.Help:
+ return <QuestionIcon className={className} weight={weight} />;
+ case IconType.LogOut:
+ return <SignOutIcon className={className} weight={weight} />;
+ default:
+ return null;
+ }
+}
diff --git a/autogpt_platform/frontend/src/components/layout/Navbar/helpers.tsx b/autogpt_platform/frontend/src/components/layout/Navbar/helpers.tsx
index 597afaeec7..97d7b55637 100644
--- a/autogpt_platform/frontend/src/components/layout/Navbar/helpers.tsx
+++ b/autogpt_platform/frontend/src/components/layout/Navbar/helpers.tsx
@@ -10,7 +10,12 @@ import {
IconType,
IconUploadCloud,
} from "@/components/__legacy__/ui/icons";
-import { ChatsIcon, StorefrontIcon } from "@phosphor-icons/react";
+import {
+ ChatsIcon,
+ CreditCardIcon,
+ QuestionIcon,
+ StorefrontIcon,
+} from "@phosphor-icons/react";
type Link = {
name: string;
@@ -41,6 +46,7 @@ export type MenuItemGroup = {
icon: IconType;
text: string;
href?: string;
+ external?: boolean;
onClick?: () => void;
}[];
};
@@ -50,8 +56,8 @@ export const accountMenuItems: MenuItemGroup[] = [
items: [
{
icon: IconType.Edit,
- text: "Edit profile",
- href: "/settings/profile",
+ text: "Account",
+ href: "/settings/account",
},
],
},
@@ -93,27 +99,34 @@ export function getAccountMenuItems(userRole?: string): MenuItemGroup[] {
items: [
{
icon: IconType.Edit,
- text: "Edit profile",
+ text: "Profile",
href: "/settings/profile",
},
- ],
- },
- {
- items: [
+ {
+ icon: IconType.Settings,
+ text: "Settings",
+ href: "/settings/account",
+ },
+ {
+ icon: IconType.Billing,
+ text: "Billing",
+ href: "/settings/billing",
+ },
{
icon: IconType.LayoutDashboard,
text: "Creator Dashboard",
href: "/settings/creator-dashboard",
},
{
- icon: IconType.UploadCloud,
- text: "Publish an agent",
+ icon: IconType.Help,
+ text: "Help & Docs",
+ href: "https://agpt.co/docs",
+ external: true,
},
],
},
];
- // Add admin menu item for admin users
if (userRole === "admin") {
baseMenuItems.push({
items: [
@@ -126,26 +139,14 @@ export function getAccountMenuItems(userRole?: string): MenuItemGroup[] {
});
}
- // Add settings and logout
- baseMenuItems.push(
- {
- items: [
- {
- icon: IconType.Settings,
- text: "Settings",
- href: "/settings",
- },
- ],
- },
- {
- items: [
- {
- icon: IconType.LogOut,
- text: "Log out",
- },
- ],
- },
- );
+ baseMenuItems.push({
+ items: [
+ {
+ icon: IconType.LogOut,
+ text: "Log out",
+ },
+ ],
+ });
return baseMenuItems;
}
@@ -173,6 +174,10 @@ export function getAccountMenuOptionIcon(icon: IconType) {
return <IconSliders className={iconClass} />;
case IconType.Chat:
return <ChatsIcon className={iconClass} />;
+ case IconType.Billing:
+ return <CreditCardIcon className={iconClass} />;
+ case IconType.Help:
+ return <QuestionIcon className={iconClass} />;
default:
return <IconRefresh className={iconClass} />;
}
diff --git a/autogpt_platform/frontend/src/playwright/pages/navbar.page.ts b/autogpt_platform/frontend/src/playwright/pages/navbar.page.ts
index 0f24f003f0..4da50427f8 100644
--- a/autogpt_platform/frontend/src/playwright/pages/navbar.page.ts
+++ b/autogpt_platform/frontend/src/playwright/pages/navbar.page.ts
@@ -5,7 +5,7 @@ export class NavBar {
async clickProfileLink() {
await this.page.getByTestId("profile-popout-menu-trigger").click();
- await this.page.getByRole("link", { name: "Edit profile" }).click();
+ await this.page.getByRole("link", { name: "Profile" }).click();
}
async clickBuildLink() {