Files
agent-radar 2ed3415fb7
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
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:17:27 +08:00

124 lines
3.3 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
parseResolvableAgentMentionIdentity,
resolveAgentMentionNodePresentation
} from "./agentMentionNodeResolution";
describe("agentMentionNodeResolution", () => {
it("parses the complete canonical identity for a resolvable Composer mention", () => {
expect(
parseResolvableAgentMentionIdentity(
{
href: "mention://workspace-issue/issue-1?projectId=project-1&workspaceId=workspace-1",
name: "Task Center"
},
"workspace-issue"
)
).toEqual({
entityId: "issue-1",
label: "Task Center",
providerId: "workspace-issue",
scope: {
projectId: "project-1",
workspaceId: "workspace-1"
},
trigger: "@"
});
});
it("does not resolve mention kinds outside the Composer presentation seam", () => {
expect(
parseResolvableAgentMentionIdentity(
{
href: "mention://agent-session/session-1?workspaceId=workspace-1",
name: "Session"
},
"session"
)
).toBeNull();
});
it.each(["missing", "error"] as const)(
"clears stale presentation attrs when resolution becomes %s",
(state) => {
expect(
resolveAgentMentionNodePresentation({
attrs: {
agentProviderId: "stale-provider",
iconUrl: "https://icons.example/stale.png",
name: "Weather"
},
hasMentionService: true,
state
})
).toEqual({ label: "Weather" });
}
);
it("clears stale presentation attrs when the mention service is removed", () => {
expect(
resolveAgentMentionNodePresentation({
attrs: {
agentProviderId: "stale-provider",
iconUrl: "https://icons.example/stale.png",
name: "Weather"
},
hasMentionService: false,
state: "ready"
})
).toEqual({ label: "Weather" });
});
it("does not retain omitted provider or icon fields from a ready resolution", () => {
expect(
resolveAgentMentionNodePresentation({
attrs: {
agentProviderId: "stale-provider",
iconUrl: "https://icons.example/stale.png",
name: "Weather"
},
hasMentionService: true,
resolved: { label: "@Resolved Weather" },
state: "ready"
})
).toEqual({
agentProviderId: undefined,
iconUrl: undefined,
label: "Resolved Weather"
});
});
it.each([
[
"iconUrl",
{ iconUrl: "https://icons.example/app.png" },
"https://icons.example/app.png"
],
[
"thumbnailUrl",
{ thumbnailUrl: "https://icons.example/issue.png" },
"https://icons.example/issue.png"
],
[
"agentIconUrl",
{ agentIconUrl: "https://icons.example/agent.png" },
"https://icons.example/agent.png"
]
] as const)(
"uses resolved %s presentation without attrs fallback",
(_, presentation, expectedIconUrl) => {
expect(
resolveAgentMentionNodePresentation({
attrs: {
iconUrl: "https://icons.example/stale.png",
name: "Mention"
},
hasMentionService: true,
resolved: { presentation },
state: "ready"
}).iconUrl
).toBe(expectedIconUrl);
}
);
});