conversation-session-plugin-mcp-skill-not-installed.test.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // 状态 A:插件 MCP skill 未安装基线。
  2. // 证明:用户从未导入/安装 e2e-plugin-mcp-ping 插件时,agent 不会把
  3. // `mcp__plugin_e2e-plugin-mcp-ping_ping__ping` 写入模型请求 tools 数组,模型也调不到它。
  4. // wdio 启动前会清空 E2E home;该状态不写 plugin 安装记录。
  5. import { clearAppData } from "#e2e/helpers/desktop-app";
  6. import {
  7. E2E_REPLY_TOKEN,
  8. prepareV4ConversationE2E,
  9. sendV4Prompt,
  10. startNewV4Draft,
  11. waitForV4AssistantMessageContaining,
  12. waitForV4ConversationState,
  13. waitForV4ComposerText,
  14. waitForV4UserMessageContaining,
  15. } from "#e2e/helpers/v4-conversation";
  16. import { getToolCallBlockByToolName } from "#e2e/helpers/conversation-session-tool";
  17. import { waitForUpstreamRequestContaining } from "#e2e/helpers/conversation-session-network";
  18. import {
  19. PLUGIN_MCP_TOOL_NAME,
  20. captureArtifactAdvertisesToolName,
  21. findUpstreamRequestContaining,
  22. } from "#e2e/helpers/plugin-mcp-skill";
  23. const NOT_INSTALLED_TIMEOUT_MS = 180000;
  24. describe("会话区 插件 MCP Skill 生命周期 E2E / 未安装基线", () => {
  25. after(async () => {
  26. await browser.electron.restoreAllMocks();
  27. await clearAppData();
  28. });
  29. it("plugin 未安装时:请求 tools 数组不含 mcp__plugin_e2e-plugin-mcp-ping_ping__ping,chat 也不出现该工具 block", async function () {
  30. this.timeout(NOT_INSTALLED_TIMEOUT_MS);
  31. await prepareV4ConversationE2E();
  32. await startNewV4Draft();
  33. const runId = Date.now();
  34. const marker = `E2E_PLUGIN_MCP_PING_NOT_INSTALLED_${runId}`;
  35. const prompt = `${marker}: Reply with exactly "${E2E_REPLY_TOKEN}" and no other text.`;
  36. await sendV4Prompt(prompt);
  37. await waitForV4ComposerText("", "未安装基线 首发后输入框没有清空");
  38. await waitForV4UserMessageContaining(prompt);
  39. await waitForUpstreamRequestContaining(marker, 60000);
  40. const requestRecord = await findUpstreamRequestContaining(marker, 60000);
  41. expect(requestRecord).not.toBeNull();
  42. if (!requestRecord) return;
  43. // 强证据:模型请求的 tools 数组里不能有 plugin MCP 工具。
  44. expect(captureArtifactAdvertisesToolName(requestRecord.requestJson, PLUGIN_MCP_TOOL_NAME)).toBe(
  45. false,
  46. );
  47. // 软证据:chat 端没有任何该工具的 tool-call block(normal text 轮次)。
  48. const block = await getToolCallBlockByToolName(PLUGIN_MCP_TOOL_NAME);
  49. expect(block).toBeNull();
  50. await waitForV4AssistantMessageContaining(E2E_REPLY_TOKEN);
  51. await waitForV4ConversationState(
  52. (snapshot) => snapshot.state === "idle" && snapshot.queueCount === 0,
  53. "未安装基线 完成后会话没有回到 idle",
  54. 90000,
  55. );
  56. });
  57. });