+36
![github-actions[bot]](/assets/img/avatar_default.png)








Julius Marminge
maria-rcks
Bilal Bakr
shivam
Vitalii Yehorov
Jake Leventhal
Claude Opus 5
Alex Southwell
github-actions[bot]
Nicholas Wasmiller
PB
Exotic
Yash Singh
Devin
Theo Browne
Gabriel De Andrade
Dara Adedeji
scratchyone
Dominic Roy
chukfinley
Primož Ajdišek
benthecarman
NaveDanan
aaditagrawal
Aditya Garud
Nick Anisimov
MacKinley Smith
Yordis Prieto
t3-code[bot]
AKolenda
Guillermo Casanova
Otavio Salvador
Shirish Pothi
Ishaan Kothari
Bob Fowler
Anton Bezdenezhnykh
ValeraZSD
Ephraim
Ryan Ilano
Alex
maco
Cursor
Tristan Knight
PR Batch Tester
oliver
kamkm
de34391427
Co-authored-by: maria-rcks <[email protected]> Co-authored-by: Bilal Bakr <[email protected]> Co-authored-by: shivam <[email protected]> Co-authored-by: Vitalii Yehorov <[email protected]> Co-authored-by: Jake Leventhal <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]> Co-authored-by: Alex Southwell <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Nicholas Wasmiller <[email protected]> Co-authored-by: PB <[email protected]> Co-authored-by: Exotic <[email protected]> Co-authored-by: Yash Singh <[email protected]> Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Theo Browne <[email protected]> Co-authored-by: Gabriel De Andrade <[email protected]> Co-authored-by: Dara Adedeji <[email protected]> Co-authored-by: scratchyone <[email protected]> Co-authored-by: Dominic Roy <[email protected]> Co-authored-by: chukfinley <[email protected]> Co-authored-by: Primož Ajdišek <[email protected]> Co-authored-by: benthecarman <[email protected]> Co-authored-by: NaveDanan <[email protected]> Co-authored-by: aaditagrawal <[email protected]> Co-authored-by: Aditya Garud <[email protected]> Co-authored-by: Nick Anisimov <[email protected]> Co-authored-by: MacKinley Smith <[email protected]> Co-authored-by: Yordis Prieto <[email protected]> Co-authored-by: t3-code[bot] <269035359+t3-code[bot]@users.noreply.github.com> Co-authored-by: AKolenda <[email protected]> Co-authored-by: Guillermo Casanova <[email protected]> Co-authored-by: Otavio Salvador <[email protected]> Co-authored-by: Shirish Pothi <[email protected]> Co-authored-by: Ishaan Kothari <[email protected]> Co-authored-by: Bob Fowler <[email protected]> Co-authored-by: Anton Bezdenezhnykh <[email protected]> Co-authored-by: ValeraZSD <[email protected]> Co-authored-by: Ephraim <[email protected]> Co-authored-by: Ryan Ilano <[email protected]> Co-authored-by: Alex <[email protected]> Co-authored-by: maco <[email protected]> Co-authored-by: Cursor <[email protected]> Co-authored-by: Tristan Knight <[email protected]> Co-authored-by: PR Batch Tester <[email protected]> Co-authored-by: oliver <[email protected]> Co-authored-by: kamkm <[email protected]> Signed-off-by: Yordis Prieto <[email protected]>
118 lines
4.2 KiB
TypeScript
118 lines
4.2 KiB
TypeScript
import { describe, expect, it } from "vite-plus/test";
|
|
|
|
import {
|
|
deriveAvailableInstanceId,
|
|
getProviderIdentityDraft,
|
|
isConfiguredAcpRegistryAgent,
|
|
resolveAcpRegistryWizardNavigation,
|
|
resolveWizardNavigation,
|
|
updateProviderIdentityDraft,
|
|
} from "./AddProviderInstanceDialog.logic";
|
|
|
|
describe("resolveWizardNavigation", () => {
|
|
const invalidId = { instanceIdError: "Instance ID is required." };
|
|
const validId = { instanceIdError: null };
|
|
|
|
it("allows moving from Driver to Identity before the instance id is valid", () => {
|
|
expect(resolveWizardNavigation(0, 1, 3, invalidId)).toEqual({ kind: "navigate", step: 1 });
|
|
});
|
|
|
|
it("blocks Next from Identity to Config while the instance id is invalid", () => {
|
|
expect(resolveWizardNavigation(1, 2, 3, invalidId)).toEqual({
|
|
kind: "blocked",
|
|
step: 1,
|
|
error: "Instance ID is required.",
|
|
});
|
|
});
|
|
|
|
it("stops a direct Driver-to-Config skip at Identity and surfaces its error", () => {
|
|
expect(resolveWizardNavigation(0, 2, 3, invalidId)).toEqual({
|
|
kind: "blocked",
|
|
step: 1,
|
|
error: "Instance ID is required.",
|
|
});
|
|
});
|
|
|
|
it("allows advancing and skipping forward once the instance id is valid", () => {
|
|
expect(resolveWizardNavigation(1, 2, 3, validId)).toEqual({ kind: "navigate", step: 2 });
|
|
expect(resolveWizardNavigation(0, 2, 3, validId)).toEqual({ kind: "navigate", step: 2 });
|
|
});
|
|
|
|
it("always preserves backward Driver and Identity navigation", () => {
|
|
expect(resolveWizardNavigation(2, 1, 3, invalidId)).toEqual({ kind: "navigate", step: 1 });
|
|
expect(resolveWizardNavigation(2, 0, 3, invalidId)).toEqual({ kind: "navigate", step: 0 });
|
|
expect(resolveWizardNavigation(1, 0, 3, invalidId)).toEqual({ kind: "navigate", step: 0 });
|
|
});
|
|
|
|
it("clamps requested steps to the wizard bounds", () => {
|
|
expect(resolveWizardNavigation(2, 8, 3, validId)).toEqual({ kind: "navigate", step: 2 });
|
|
expect(resolveWizardNavigation(0, -1, 3, invalidId)).toEqual({ kind: "navigate", step: 0 });
|
|
});
|
|
});
|
|
|
|
describe("ACP Registry wizard", () => {
|
|
it("requires a prepared result or valid manual configuration before Identity", () => {
|
|
expect(
|
|
resolveAcpRegistryWizardNavigation(0, 1, {
|
|
instanceIdError: null,
|
|
selectionError: "Select an ACP or configure one manually.",
|
|
}),
|
|
).toEqual({
|
|
kind: "blocked",
|
|
step: 0,
|
|
error: "Select an ACP or configure one manually.",
|
|
});
|
|
|
|
expect(
|
|
resolveAcpRegistryWizardNavigation(0, 1, {
|
|
instanceIdError: null,
|
|
selectionError: null,
|
|
}),
|
|
).toEqual({ kind: "navigate", step: 1 });
|
|
});
|
|
|
|
it("derives a collision-free instance id without exceeding the slug limit", () => {
|
|
const derive = (label: string) => `acpRegistry_${label}`;
|
|
const existing = new Set(["acpRegistry_gemini", "acpRegistry_gemini_2"]);
|
|
|
|
expect(deriveAvailableInstanceId(derive, "gemini", existing)).toBe("acpRegistry_gemini_3");
|
|
|
|
const longBase = `acpRegistry_${"a".repeat(48)}`;
|
|
expect(deriveAvailableInstanceId(() => longBase, "ignored", new Set([longBase]))).toHaveLength(
|
|
62,
|
|
);
|
|
});
|
|
|
|
it("only marks matching ACP Registry instances as already added", () => {
|
|
const instances = {
|
|
codex: { driver: "codex", config: { agentId: "gemini" } },
|
|
registry: { driver: "acpRegistry", config: { agentId: "gemini" } },
|
|
};
|
|
|
|
expect(isConfiguredAcpRegistryAgent(instances, "gemini")).toBe(true);
|
|
expect(isConfiguredAcpRegistryAgent(instances, "codex")).toBe(false);
|
|
});
|
|
|
|
it("keeps registry-prefilled identity separate from other drivers", () => {
|
|
const registryDrafts = updateProviderIdentityDraft({}, "acpRegistry", {
|
|
label: "Gemini CLI",
|
|
instanceIdOverride: "acpRegistry_gemini_cli",
|
|
});
|
|
|
|
expect(getProviderIdentityDraft(registryDrafts, "codex")).toEqual({
|
|
label: "",
|
|
accentColor: "",
|
|
instanceIdOverride: null,
|
|
});
|
|
|
|
const drafts = updateProviderIdentityDraft(registryDrafts, "codex", {
|
|
label: "Work",
|
|
instanceIdOverride: "codex_work",
|
|
});
|
|
expect(getProviderIdentityDraft(drafts, "acpRegistry")).toMatchObject({
|
|
label: "Gemini CLI",
|
|
instanceIdOverride: "acpRegistry_gemini_cli",
|
|
});
|
|
});
|
|
});
|