Open History to see the last commit
1import { createElement } from "react";
2import { renderToStaticMarkup } from "react-dom/server";
3import { describe, expect, it } from "vite-plus/test";
4import {
5 ProviderDriverKind,
6 ProviderInstanceId,
7 type ServerProvider,
8 type ServerProviderModel,
9} from "@t3tools/contracts";
10
11import { deriveProviderModelsForDisplay, ProviderInstanceCard } from "./ProviderInstanceCard";
12
13describe("deriveProviderModelsForDisplay", () => {
14 it("uses current config custom models instead of stale live custom rows", () => {
15 const liveModels: ReadonlyArray<ServerProviderModel> = [
16 {
17 slug: "server-model",
18 name: "Server Model",
19 isCustom: false,
20 capabilities: null,
21 },
22 {
23 slug: "removed-custom",
24 name: "Removed Custom",
25 isCustom: true,
26 capabilities: null,
27 },
28 {
29 slug: "kept-custom",
30 name: "Kept Custom",
31 isCustom: true,
32 capabilities: null,
33 },
34 ];
35
36 expect(
37 deriveProviderModelsForDisplay({
38 liveModels,
39 customModels: ["kept-custom"],
40 }).map((model) => model.slug),
41 ).toEqual(["server-model", "kept-custom"]);
42 });
43
44 it("shows a redacted provider email in the editor header status line", () => {
45 const instanceId = ProviderInstanceId.make("codex");
46 const driver = ProviderDriverKind.make("codex");
47 const liveProvider: ServerProvider = {
48 instanceId,
49 driver,
50 enabled: true,
51 installed: true,
52 version: "1.0.0",
53 status: "ready",
54 auth: { status: "authenticated", email: "developer@example.com" },
55 checkedAt: "2026-08-27T12:00:00.000Z",
56 models: [],
57 slashCommands: [],
58 skills: [],
59 };
60
61 const markup = renderToStaticMarkup(
62 createElement(ProviderInstanceCard, {
63 instanceId,
64 instance: { driver },
65 driverOption: undefined,
66 liveProvider,
67 mode: "editor",
68 onUpdate: () => undefined,
69 hiddenModels: [],
70 favoriteModels: [],
71 modelOrder: [],
72 onHiddenModelsChange: () => undefined,
73 onFavoriteModelsChange: () => undefined,
74 onModelOrderChange: () => undefined,
75 }),
76 );
77
78 expect(markup).toContain("Authenticated as");
79 expect(markup).toContain('aria-label="Toggle account email visibility"');
80 expect(markup).toContain("blur-[2px]");
81 expect(markup).not.toContain("developer@example.com");
82 });
83 it("surfaces a failed probe message in both the list row and the editor", () => {
84 const instanceId = ProviderInstanceId.make("codex_work");
85 const driver = ProviderDriverKind.make("codex");
86 const message =
87 "Codex app-server provider probe failed: Cannot create Codex shadow home entry 'auth.json' because '/home/me/.codex-t3/work/auth.json' already exists and is not a symlink.";
88 const liveProvider: ServerProvider = {
89 instanceId,
90 driver,
91 enabled: true,
92 installed: true,
93 version: null,
94 status: "error",
95 auth: { status: "unknown" },
96 checkedAt: "2026-08-28T12:00:00.000Z",
97 models: [],
98 slashCommands: [],
99 skills: [],
100 message,
101 };
102 const props = {
103 instanceId,
104 instance: { driver },
105 driverOption: undefined,
106 liveProvider,
107 onUpdate: () => undefined,
108 hiddenModels: [],
109 favoriteModels: [],
110 modelOrder: [],
111 onHiddenModelsChange: () => undefined,
112 onFavoriteModelsChange: () => undefined,
113 onModelOrderChange: () => undefined,
114 } as const;
115
116 for (const mode of ["list", "editor"] as const) {
117 const markup = renderToStaticMarkup(createElement(ProviderInstanceCard, { ...props, mode }));
118 expect(markup).toContain("Unavailable");
119 expect(markup).toContain("is not a symlink");
120 }
121 });
122});