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

AddProviderInstanceDialog.test.ts

72 lines2.6 KB

1import { describe, expect, it } from "vite-plus/test";
2​
3import {
4 acpPickerValue,
5 configDraftForFeaturedAgent,
6 parseAddProviderPickerValue,
7 resolveWizardNavigation,
8} from "./AddProviderInstanceDialog.logic";
9​
10describe("resolveWizardNavigation", () => {
11 const invalidId = { instanceIdError: "Instance ID is required." };
12 const validId = { instanceIdError: null };
13​
14 it("allows moving from Driver to Identity before the instance id is valid", () => {
15 expect(resolveWizardNavigation(0, 1, 3, invalidId)).toEqual({ kind: "navigate", step: 1 });
16 });
17​
18 it("blocks Next from Identity to Config while the instance id is invalid", () => {
19 expect(resolveWizardNavigation(1, 2, 3, invalidId)).toEqual({
20 kind: "blocked",
21 step: 1,
22 error: "Instance ID is required.",
23 });
24 });
25​
26 it("stops a direct Driver-to-Config skip at Identity and surfaces its error", () => {
27 expect(resolveWizardNavigation(0, 2, 3, invalidId)).toEqual({
28 kind: "blocked",
29 step: 1,
30 error: "Instance ID is required.",
31 });
32 });
33​
34 it("allows advancing and skipping forward once the instance id is valid", () => {
35 expect(resolveWizardNavigation(1, 2, 3, validId)).toEqual({ kind: "navigate", step: 2 });
36 expect(resolveWizardNavigation(0, 2, 3, validId)).toEqual({ kind: "navigate", step: 2 });
37 });
38​
39 it("always preserves backward Driver and Identity navigation", () => {
40 expect(resolveWizardNavigation(2, 1, 3, invalidId)).toEqual({ kind: "navigate", step: 1 });
41 expect(resolveWizardNavigation(2, 0, 3, invalidId)).toEqual({ kind: "navigate", step: 0 });
42 expect(resolveWizardNavigation(1, 0, 3, invalidId)).toEqual({ kind: "navigate", step: 0 });
43 });
44​
45 it("clamps requested steps to the wizard bounds", () => {
46 expect(resolveWizardNavigation(2, 8, 3, validId)).toEqual({ kind: "navigate", step: 2 });
47 expect(resolveWizardNavigation(0, -1, 3, invalidId)).toEqual({ kind: "navigate", step: 0 });
48 });
49});
50​
51describe("ACP catalog picker", () => {
52 it("parses featured ACP picker values onto the registry driver", () => {
53 expect(acpPickerValue("gemini")).toBe("acp:gemini");
54 expect(parseAddProviderPickerValue("acp:gemini")).toEqual({
55 driver: "acpRegistry",
56 catalogId: "gemini",
57 });
58 expect(parseAddProviderPickerValue("codex")).toEqual({
59 driver: "codex",
60 catalogId: undefined,
61 });
62 });
63​
64 it("prefills Gemini launch config without downloading a binary", () => {
65 expect(configDraftForFeaturedAgent("gemini")).toEqual({
66 catalogId: "gemini",
67 command: "gemini",
68 launchArgs: "--acp",
69 });
70 expect(configDraftForFeaturedAgent("custom")).toEqual({});
71 });
72});