Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

providerStatus.test.ts

71 lines2.1 KB

1import { ProviderDriverKind, ProviderInstanceId, type ServerProvider } from "@t3tools/contracts";
2import { describe, expect, it } from "vite-plus/test";
3​
4import { getProviderSummary } from "./providerStatus";
5​
6const provider: ServerProvider = {
7 instanceId: ProviderInstanceId.make("codex"),
8 driver: ProviderDriverKind.make("codex"),
9 enabled: true,
10 installed: true,
11 version: "1.0.0",
12 status: "ready",
13 auth: { status: "authenticated", label: "ChatGPT" },
14 checkedAt: "2026-08-23T00:00:00.000Z",
15 models: [],
16 slashCommands: [],
17 skills: [],
18};
19​
20describe("getProviderSummary", () => {
21 it("reports ready providers with unknown authentication as available", () => {
22 expect(getProviderSummary({ ...provider, auth: { status: "unknown" } })).toEqual({
23 headline: "Available",
24 detail: null,
25 });
26 });
27​
28 it("does not hide a provider error behind a previous authenticated state", () => {
29 expect(
30 getProviderSummary({
31 ...provider,
32 status: "error",
33 message: "The provider process failed to start.",
34 }),
35 ).toEqual({
36 headline: "Unavailable",
37 detail: "The provider process failed to start.",
38 });
39 });
40​
41 it("does not hide a provider warning behind an authenticated state", () => {
42 expect(
43 getProviderSummary({
44 ...provider,
45 status: "warning",
46 message: "The provider version is unsupported.",
47 }),
48 ).toEqual({
49 headline: "Needs attention",
50 detail: "The provider version is unsupported.",
51 });
52 });
53​
54 it("keeps authentication failures actionable when their provider status is error", () => {
55 expect(
56 getProviderSummary({
57 ...provider,
58 status: "error",
59 auth: { status: "unauthenticated" },
60 message: "Run codex login.",
61 }),
62 ).toEqual({
63 headline: "Not authenticated",
64 detail: "Run codex login.",
65 });
66 });
67​
68 it("treats a disabled provider status as disabled even before its enabled flag updates", () => {
69 expect(getProviderSummary({ ...provider, status: "disabled" }).headline).toBe("Disabled");
70 });
71});