Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
70 lines
2.1 KiB
TypeScript
70 lines
2.1 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import type { AgentHostUserProjectsApi } from "../../host/agentHostApi";
|
|
import { createAgentGUIUserProjectSelectionApi } from "./agentGuiUserProjectSelectionApi";
|
|
|
|
function createUserProjectsApi(): AgentHostUserProjectsApi {
|
|
return {
|
|
async list() {
|
|
return { projects: [] };
|
|
},
|
|
async pin() {},
|
|
async use({ path }) {
|
|
return { id: path, label: path, path, pinnedAtUnixMs: 0 };
|
|
}
|
|
};
|
|
}
|
|
|
|
describe("createAgentGUIUserProjectSelectionApi", () => {
|
|
it("uses only the explicitly injected project directory selector", async () => {
|
|
const selectProjectDirectory = vi.fn(async () => ({
|
|
path: "/workspace/existing"
|
|
}));
|
|
const api = createAgentGUIUserProjectSelectionApi({
|
|
selectProjectDirectory,
|
|
userProjects: createUserProjectsApi()
|
|
});
|
|
|
|
await expect(api?.selectDirectory?.()).resolves.toEqual({
|
|
path: "/workspace/existing"
|
|
});
|
|
expect(selectProjectDirectory).toHaveBeenCalledOnce();
|
|
});
|
|
|
|
it("disables existing-project selection when the selector is unavailable", () => {
|
|
const api = createAgentGUIUserProjectSelectionApi({
|
|
selectProjectDirectory: undefined,
|
|
userProjects: createUserProjectsApi()
|
|
});
|
|
|
|
expect(api?.selectDirectory).toBeUndefined();
|
|
});
|
|
|
|
it("adds the optional import flow without changing the default project API", async () => {
|
|
const importDirectory = vi.fn(async () => ({
|
|
path: "/workspace/imported"
|
|
}));
|
|
const api = createAgentGUIUserProjectSelectionApi({
|
|
importDirectory,
|
|
userProjects: createUserProjectsApi()
|
|
});
|
|
|
|
await expect(api?.importDirectory?.()).resolves.toEqual({
|
|
path: "/workspace/imported"
|
|
});
|
|
expect(api?.selectDirectory).toBeUndefined();
|
|
});
|
|
|
|
it("does not fabricate a project catalog for a directory-only host", () => {
|
|
const selectProjectDirectory = vi.fn(async () => ({
|
|
path: "/workspace/existing"
|
|
}));
|
|
const api = createAgentGUIUserProjectSelectionApi({
|
|
selectProjectDirectory,
|
|
userProjects: null
|
|
});
|
|
|
|
expect(api).toBeNull();
|
|
expect(selectProjectDirectory).not.toHaveBeenCalled();
|
|
});
|
|
});
|