conversation-session-plugin-mcp-skill-workspace-inherited.test.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { TID_SETTINGS_BACK_BUTTON } from "@zcode/shared/test-ids";
  2. import { clearAppData, clickTestIdByDom } from "#e2e/helpers/desktop-app";
  3. import {
  4. getPluginList,
  5. openPluginManagementSettings,
  6. selectPluginSettingsScope,
  7. waitForPluginControl,
  8. } from "#e2e/helpers/plugin-management-lifecycle";
  9. import { PLUGIN_MCP_PLUGIN_ID } from "#e2e/helpers/plugin-mcp-skill";
  10. import {
  11. assertWorkspacePluginRuntime,
  12. pluginConfigEnabled,
  13. readWorkspacePluginConfig,
  14. } from "#e2e/helpers/workspace-plugin-runtime";
  15. describe("WPL-002 Workspace Plugin User inheritance and cold-start reload E2E", () => {
  16. after(async () => {
  17. await browser.electron.restoreAllMocks();
  18. await clearAppData();
  19. });
  20. it("inherits User enablement when Workspace omits the key", async function () {
  21. this.timeout(240000);
  22. expect(pluginConfigEnabled(await readWorkspacePluginConfig())).toBeUndefined();
  23. const plugin = (await getPluginList()).plugins.find((item) => item.id === PLUGIN_MCP_PLUGIN_ID);
  24. expect(plugin).toMatchObject({ enabled: true, enabledSource: "user" });
  25. // User/Workspace 是同一 Host inventory 的两个配置视图。切到 Workspace 后仍应看到
  26. // 继承的插件;列表不再显示来源标签,继承来源由上面的 Agent 投影断言验证。
  27. await openPluginManagementSettings();
  28. await waitForPluginControl("plugin-settings-plugin-row", {
  29. pluginId: PLUGIN_MCP_PLUGIN_ID,
  30. });
  31. await selectPluginSettingsScope("workspace");
  32. await waitForPluginControl("plugin-settings-plugin-row", {
  33. pluginId: PLUGIN_MCP_PLUGIN_ID,
  34. });
  35. expect(
  36. await browser.execute((pluginId) => {
  37. const row = document.querySelector<HTMLElement>(
  38. `[data-testid="plugin-settings-plugin-row"][data-plugin-id="${pluginId}"]`,
  39. );
  40. return {
  41. checked:
  42. row?.querySelector<HTMLElement>('[data-testid="plugin-settings-enabled-switch"]')
  43. ?.dataset.state === "checked",
  44. source:
  45. row?.querySelector<HTMLElement>("[data-settings-scope]")?.dataset.settingsScope ?? null,
  46. };
  47. }, PLUGIN_MCP_PLUGIN_ID),
  48. ).toEqual({ checked: true, source: null });
  49. await clickTestIdByDom(TID_SETTINGS_BACK_BUTTON);
  50. await assertWorkspacePluginRuntime("E2E_PLUGIN_MCP_PING_INSTALLED_ENABLED");
  51. });
  52. });