Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2
3import {
4 getProviderIdentityDraft,
5 resolveAcpRegistryWizardNavigation,
6 resolveWizardNavigation,
7 updateProviderIdentityDraft,
8} from "./AddProviderInstanceDialog.logic";
9
10describe("resolveWizardNavigation", () => {
11 const invalidId = { instanceIdError: "Instance ID is required." };
12
13 // regression: #2813 the wizard advanced past an invalid instance id
14 it("blocks Next from Identity to Config while the instance id is invalid", () => {
15 expect(resolveWizardNavigation(1, 2, 3, invalidId)).toEqual({
16 kind: "blocked",
17 step: 1,
18 error: "Instance ID is required.",
19 });
20 });
21
22 it("stops a direct Driver-to-Config skip at Identity and surfaces its error", () => {
23 expect(resolveWizardNavigation(0, 2, 3, invalidId)).toEqual({
24 kind: "blocked",
25 step: 1,
26 error: "Instance ID is required.",
27 });
28 });
29});
30
31describe("ACP Registry wizard", () => {
32 it("requires a prepared result or valid manual configuration before Identity", () => {
33 expect(
34 resolveAcpRegistryWizardNavigation(0, 1, {
35 instanceIdError: null,
36 selectionError: "Select an ACP or configure one manually.",
37 }),
38 ).toEqual({
39 kind: "blocked",
40 step: 0,
41 error: "Select an ACP or configure one manually.",
42 });
43
44 expect(
45 resolveAcpRegistryWizardNavigation(0, 1, {
46 instanceIdError: null,
47 selectionError: null,
48 }),
49 ).toEqual({ kind: "navigate", step: 1 });
50 });
51
52 it("keeps registry-prefilled identity separate from other drivers", () => {
53 const registryDrafts = updateProviderIdentityDraft({}, "acpRegistry", {
54 label: "Gemini CLI",
55 instanceIdOverride: "acpRegistry_gemini_cli",
56 });
57
58 expect(getProviderIdentityDraft(registryDrafts, "codex")).toEqual({
59 label: "",
60 accentColor: "",
61 instanceIdOverride: null,
62 });
63
64 const drafts = updateProviderIdentityDraft(registryDrafts, "codex", {
65 label: "Work",
66 instanceIdOverride: "codex_work",
67 });
68 expect(getProviderIdentityDraft(drafts, "acpRegistry")).toMatchObject({
69 label: "Gemini CLI",
70 instanceIdOverride: "acpRegistry_gemini_cli",
71 });
72 });
73});