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 Configuration", () => {
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("Account email");
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});