From 6f80a109ef7b554b7ea59e6ee02f7e5d6e7214e1 Mon Sep 17 00:00:00 2001 From: Nicholas Tindle Date: Fri, 17 Apr 2026 14:49:59 -0500 Subject: [PATCH] fix(frontend): fix lint, add storage bar test coverage - Fix prettier formatting in SubscriptionTierSection - Add tests for WorkspaceStorageSection rendering (shown/hidden states) - Mock useWorkspaceStorage in UsagePanelContent test suite Co-Authored-By: Claude Opus 4.6 (1M context) --- .../UsagePanelContentRender.test.tsx | 37 ++++++++++++++++++- .../SubscriptionTierSection.tsx | 9 +++-- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/UsageLimits/__tests__/UsagePanelContentRender.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/UsageLimits/__tests__/UsagePanelContentRender.test.tsx index d81d481cd4..9f5b5cb3b7 100644 --- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/UsageLimits/__tests__/UsagePanelContentRender.test.tsx +++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/UsageLimits/__tests__/UsagePanelContentRender.test.tsx @@ -4,7 +4,7 @@ import { cleanup, fireEvent, } from "@/tests/integrations/test-utils"; -import { afterEach, describe, expect, it, vi } from "vitest"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { UsagePanelContent, formatBytes } from "../UsagePanelContent"; import type { CoPilotUsageStatus } from "@/app/api/__generated__/models/coPilotUsageStatus"; @@ -13,9 +13,20 @@ vi.mock("../../../hooks/useResetRateLimit", () => ({ useResetRateLimit: () => ({ resetUsage: mockResetUsage, isPending: false }), })); +const mockStorageData = vi.fn(); +vi.mock("../useWorkspaceStorage", () => ({ + useWorkspaceStorage: () => mockStorageData(), +})); + afterEach(() => { cleanup(); mockResetUsage.mockReset(); + mockStorageData.mockReset(); +}); + +// Default: no storage data (most existing tests don't need it) +beforeEach(() => { + mockStorageData.mockReturnValue({ data: undefined }); }); function makeUsage( @@ -130,4 +141,28 @@ describe("UsagePanelContent", () => { ); expect(screen.getByText("Add credits to reset")).toBeDefined(); }); + + it("renders file storage bar when workspace data is available", () => { + mockStorageData.mockReturnValue({ + data: { + used_bytes: 100 * 1024 * 1024, // 100 MB + limit_bytes: 250 * 1024 * 1024, // 250 MB + used_percent: 40, + file_count: 5, + }, + }); + + render(); + expect(screen.getByText("File storage")).toBeDefined(); + expect(screen.getByText(/100 MB of 250 MB/)).toBeDefined(); + expect(screen.getByText(/5 files/)).toBeDefined(); + expect(screen.getByText("40% used")).toBeDefined(); + }); + + it("hides file storage bar when no workspace data", () => { + mockStorageData.mockReturnValue({ data: undefined }); + + render(); + expect(screen.queryByText("File storage")).toBeNull(); + }); }); diff --git a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/SubscriptionTierSection.tsx b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/SubscriptionTierSection.tsx index 084ee7b310..9e3de6088f 100644 --- a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/SubscriptionTierSection.tsx +++ b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/SubscriptionTierSection.tsx @@ -17,19 +17,22 @@ const TIERS: TierInfo[] = [ key: "FREE", label: "Free", multiplier: "1x", - description: "Base AutoPilot capacity with standard rate limits · 250 MB file storage", + description: + "Base AutoPilot capacity with standard rate limits · 250 MB file storage", }, { key: "PRO", label: "Pro", multiplier: "5x", - description: "5x AutoPilot capacity — run 5× more tasks per day/week · 1 GB file storage", + description: + "5x AutoPilot capacity — run 5× more tasks per day/week · 1 GB file storage", }, { key: "BUSINESS", label: "Business", multiplier: "20x", - description: "20x AutoPilot capacity — ideal for teams and heavy workloads · 5 GB file storage", + description: + "20x AutoPilot capacity — ideal for teams and heavy workloads · 5 GB file storage", }, ];