Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions apps/web/src/components/usage/UsageLimitsPooled.browser.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import {
EnvironmentId,
ProviderDriverKind,
ProviderInstanceId,
type ServerProvider,
} from "@t3tools/contracts";
import { CHATGPT_USAGE_URL } from "@t3tools/shared/usageLimits";
import { describe, expect, it } from "vite-plus/test";

import { render } from "../../../test/render";
import { UsageLimitsPooled } from "./UsageLimitsPooled";

const checkedAt = "2026-10-25T16:00:00.000Z";

function managedChatGpt(instanceId: string, displayName: string): ServerProvider {
return {
instanceId: ProviderInstanceId.make(instanceId),
driver: ProviderDriverKind.make("codex"),
displayName,
enabled: true,
installed: true,
version: "0.164.0",
status: "ready",
auth: { status: "authenticated" },
checkedAt,
models: [],
slashCommands: [],
skills: [],
usageLimits: {
checkedAt,
windows: [],
unavailable: { reason: "unsupported", message: "Track usage in ChatGPT." },
externalUsage: { label: "ChatGPT usage", url: CHATGPT_USAGE_URL },
},
};
}

describe("UsageLimitsPooled ChatGPT usage card", () => {
it("names the managed connections it covers", async () => {
const presentations = new Map([
[
EnvironmentId.make("desk"),
{
entry: { target: { label: "Desk" } },
serverConfig: {
providers: [
managedChatGpt("chatgpt_work", "ChatGPT Work"),
managedChatGpt("chatgpt_personal", "ChatGPT Personal"),
],
},
},
],
]);
await using screen = await render(
<UsageLimitsPooled presentations={presentations} now={Date.parse(checkedAt)} />,
);

await expect
.element(screen.getByText("ChatGPT Work on Desk, ChatGPT Personal on Desk"))
.toBeVisible();
await expect
.element(screen.getByText("View usage in ChatGPT with your connected account."))
.toBeVisible();
});
});
3 changes: 3 additions & 0 deletions apps/web/src/components/usage/UsageLimitsPooled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,9 @@ export function UsageLimitsPooled({
) : null}
<div className="min-w-0 space-y-1">
<h2 className="text-sm font-medium">{link.label}</h2>
<p className="text-xs break-words text-muted-foreground">
{link.accounts.join(", ")}
</p>
{link.url === CHATGPT_USAGE_URL ? (
<p className="text-xs text-muted-foreground">
View usage in ChatGPT with your connected account.
Expand Down
Loading