feat: complete release readiness work
- consolidate API ownership and remove dead vendor code - add Stripe billing, learning paths, and public CV hardening - add migration, recovery, security, audit, and browser gates
This commit is contained in:
@@ -4,7 +4,7 @@ import { render, screen } from "@testing-library/react";
|
||||
import AiUsageCard from "./components/AiUsageCard";
|
||||
import { api } from "./api";
|
||||
|
||||
jest.mock("./api", () => ({ api: { get: jest.fn() } }));
|
||||
jest.mock("./api", () => ({ api: { get: jest.fn(), post: jest.fn() } }));
|
||||
jest.mock("./i18n/I18nProvider", () => ({ useI18n: () => ({ t: (key: string, params?: Record<string, unknown>) => {
|
||||
const messages: Record<string, string> = {
|
||||
settingsUsageTitle: "Account usage",
|
||||
@@ -14,13 +14,14 @@ jest.mock("./i18n/I18nProvider", () => ({ useI18n: () => ({ t: (key: string, par
|
||||
settingsUsageTokens: "{used} of {limit} estimated tokens",
|
||||
settingsUsageStorage: "{used} of {limit} attachment storage",
|
||||
settingsUsageReset: "AI limits reset at the start of each calendar month.",
|
||||
settingsBillingUpgrade: "Upgrade to Premium",
|
||||
};
|
||||
return Object.entries(params ?? {}).reduce((text, [name, value]) => text.replace(`{${name}}`, String(value)), messages[key] ?? key);
|
||||
} }) }));
|
||||
|
||||
test("shows monthly AI call and token limits", async () => {
|
||||
(api.get as jest.Mock).mockResolvedValue({
|
||||
data: {
|
||||
(api.get as jest.Mock).mockImplementation((url: string) => Promise.resolve({
|
||||
data: url === "/billing/status" ? { enabled: true, canCheckout: true, canManage: false } : {
|
||||
currentMonth: { calls: 4, estimatedTokens: 12000 },
|
||||
plan: "free",
|
||||
monthlyCallLimit: 25,
|
||||
@@ -28,7 +29,7 @@ test("shows monthly AI call and token limits", async () => {
|
||||
storageUsedBytes: 50000000,
|
||||
storageLimitBytes: 250000000,
|
||||
},
|
||||
});
|
||||
}));
|
||||
|
||||
render(<AiUsageCard />);
|
||||
|
||||
@@ -36,4 +37,5 @@ test("shows monthly AI call and token limits", async () => {
|
||||
expect(screen.getByText("12,000 of 100,000 estimated tokens")).toBeInTheDocument();
|
||||
expect(screen.getByText("50.0 MB of 250.0 MB attachment storage")).toBeInTheDocument();
|
||||
expect(screen.getByLabelText("Monthly AI generations used")).toHaveAttribute("aria-valuenow", "16");
|
||||
expect(screen.getByRole("button", { name: "Upgrade to Premium" })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user