mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-30 03:00:41 -04:00
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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(<UsagePanelContent usage={makeUsage()} />);
|
||||
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(<UsagePanelContent usage={makeUsage()} />);
|
||||
expect(screen.queryByText("File storage")).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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",
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user