Open History to see the last commit
1import { ProviderDriverKind, ProviderInstanceId, type ServerProvider } from "@t3tools/contracts";
2import { describe, expect, it } from "vite-plus/test";
3
4import { deriveProviderInstanceEntries } from "../../providerInstances";
5import { shouldIncludeModelPickerOption } from "./ModelPickerContent";
6
7function entry(status: ServerProvider["status"]) {
8 return deriveProviderInstanceEntries([
9 {
10 instanceId: ProviderInstanceId.make("opencode_work"),
11 driver: ProviderDriverKind.make("opencode"),
12 enabled: true,
13 installed: true,
14 version: null,
15 status,
16 auth: { status: "authenticated" },
17 checkedAt: "2026-08-28T00:00:00.000Z",
18 models: [],
19 slashCommands: [],
20 skills: [],
21 },
22 ])[0]!;
23}
24
25describe("shouldIncludeModelPickerOption", () => {
26 it.each(["error", "warning"] as const)(
27 "keeps only the active synthetic OpenCode row when the provider status is %s",
28 (status) => {
29 const providerEntry = entry(status);
30 const activeInstanceId = ProviderInstanceId.make("opencode_work");
31 const activeModel = "openrouter/kimi-k3";
32
33 expect(
34 shouldIncludeModelPickerOption({
35 entry: providerEntry,
36 option: {
37 slug: activeModel,
38 name: activeModel,
39 isUnavailable: true,
40 },
41 activeInstanceId,
42 activeModel,
43 }),
44 ).toBe(true);
45 expect(
46 shouldIncludeModelPickerOption({
47 entry: providerEntry,
48 option: { slug: "stale/model", name: "Stale model" },
49 activeInstanceId,
50 activeModel,
51 }),
52 ).toBe(false);
53 expect(
54 shouldIncludeModelPickerOption({
55 entry: providerEntry,
56 option: {
57 slug: "other/missing",
58 name: "Other missing",
59 isUnavailable: true,
60 },
61 activeInstanceId,
62 activeModel,
63 }),
64 ).toBe(false);
65 },
66 );
67});