feat: show account AI usage
CI and Deploy / test (push) Successful in 2m40s
CI and Deploy / deploy (push) Successful in 50s

This commit is contained in:
cesnimda
2026-07-31 00:08:41 +02:00
parent 2126a2db5c
commit 9f16a5675a
4 changed files with 93 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
import React from "react";
import "@testing-library/jest-dom";
import { render, screen } from "@testing-library/react";
import AiUsageCard from "./components/AiUsageCard";
import { api } from "./api";
jest.mock("./api", () => ({ api: { get: jest.fn() } }));
test("shows monthly AI call and token limits", async () => {
(api.get as jest.Mock).mockResolvedValue({
data: {
currentMonth: { calls: 4, estimatedTokens: 12000 },
plan: "free",
monthlyCallLimit: 25,
monthlyTokenLimit: 100000,
},
});
render(<AiUsageCard />);
expect(await screen.findByText("4 of 25 generations this month")).toBeInTheDocument();
expect(screen.getByText("12,000 of 100,000 estimated tokens")).toBeInTheDocument();
expect(screen.getByLabelText("Monthly AI generations used")).toHaveAttribute("aria-valuenow", "16");
});