源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
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
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
This commit is contained in:
+100
@@ -0,0 +1,100 @@
|
||||
import { act, renderHook } from "@testing-library/react";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { ReferenceSourceAggregator } from "@tutti-os/workspace-file-reference/core";
|
||||
|
||||
import { useAgentGUIWorkspaceReferencePicker } from "./useAgentGUIWorkspaceReferencePicker";
|
||||
|
||||
function createInput(
|
||||
projectDirectorySourceAggregator: ReferenceSourceAggregator
|
||||
): Parameters<typeof useAgentGUIWorkspaceReferencePicker>[0] {
|
||||
return {
|
||||
onWorkspaceFileReferencesAdded: undefined,
|
||||
projectDirectorySourceAggregator,
|
||||
referenceSourceAggregator: {} as ReferenceSourceAggregator,
|
||||
resolveMentionReferenceTarget: undefined,
|
||||
resolveWorkspaceReferenceInitialTarget: undefined,
|
||||
viewModel: {
|
||||
composer: {
|
||||
composerSettings: { selectedProjectPath: null }
|
||||
},
|
||||
rail: {
|
||||
activeConversation: null,
|
||||
userProjects: []
|
||||
},
|
||||
shell: { workspaceId: "workspace-1" }
|
||||
} as unknown as Parameters<
|
||||
typeof useAgentGUIWorkspaceReferencePicker
|
||||
>[0]["viewModel"],
|
||||
workspaceFileReferenceAdapter: undefined,
|
||||
workspaceFileReferenceCopy: undefined
|
||||
};
|
||||
}
|
||||
|
||||
describe("useAgentGUIWorkspaceReferencePicker project directory purpose", () => {
|
||||
it("allows Host folders for ordinary workspace references", () => {
|
||||
const { result } = renderHook(() =>
|
||||
useAgentGUIWorkspaceReferencePicker(
|
||||
createInput({} as ReferenceSourceAggregator)
|
||||
)
|
||||
);
|
||||
|
||||
expect(result.current.workspaceReferencePickerPurpose).toBe("reference");
|
||||
expect(
|
||||
result.current.isWorkspaceReferencePickerNodeSelectable({
|
||||
displayName: "host-folder",
|
||||
kind: "folder",
|
||||
ref: { nodeId: "/Users/me/project", sourceId: "host-local-file" }
|
||||
})
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("opens the shared picker with the directory aggregator and resolves one folder", async () => {
|
||||
const projectDirectorySourceAggregator = {} as ReferenceSourceAggregator;
|
||||
const { result } = renderHook(() =>
|
||||
useAgentGUIWorkspaceReferencePicker(
|
||||
createInput(projectDirectorySourceAggregator)
|
||||
)
|
||||
);
|
||||
let selectionPromise!: Promise<{ path: string } | null>;
|
||||
|
||||
act(() => {
|
||||
selectionPromise = result.current.requestProjectDirectory();
|
||||
});
|
||||
|
||||
expect(result.current.workspaceReferencePickerOpen).toBe(true);
|
||||
expect(result.current.workspaceReferencePickerPurpose).toBe("directory");
|
||||
expect(result.current.workspaceReferencePickerAggregator).toBe(
|
||||
projectDirectorySourceAggregator
|
||||
);
|
||||
expect(
|
||||
result.current.isWorkspaceReferencePickerNodeSelectable({
|
||||
displayName: "folder",
|
||||
kind: "folder",
|
||||
ref: { nodeId: "/workspace/folder", sourceId: "workspace-file" }
|
||||
})
|
||||
).toBe(true);
|
||||
expect(
|
||||
result.current.isWorkspaceReferencePickerNodeSelectable({
|
||||
displayName: "file",
|
||||
kind: "file",
|
||||
ref: { nodeId: "/workspace/file", sourceId: "workspace-file" }
|
||||
})
|
||||
).toBe(false);
|
||||
|
||||
act(() => {
|
||||
result.current.confirmWorkspaceReferencePicker([
|
||||
{
|
||||
kind: "folder",
|
||||
path: "/workspace/folder",
|
||||
sourceId: "workspace-file"
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
await expect(selectionPromise).resolves.toEqual({
|
||||
path: "/workspace/folder"
|
||||
});
|
||||
expect(result.current.workspaceReferencePickerOpen).toBe(false);
|
||||
expect(result.current.workspaceReferencePickerPurpose).toBe("reference");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user