figma.test.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { describe, expect, test } from "bun:test"
  2. import { ConfigMCP } from "@opencode-ai/core/config/mcp"
  3. import { FigmaPlugin } from "@opencode-ai/core/plugin/figma"
  4. describe("plugin.figma", () => {
  5. test("adds the OpenCode client ID to configured Figma servers", () => {
  6. const server = new ConfigMCP.Remote({
  7. type: "remote",
  8. url: "https://mcp.figma.com/mcp",
  9. oauth: new ConfigMCP.OAuth({ scope: "mcp:connect" }),
  10. })
  11. FigmaPlugin.apply(server)
  12. expect(server.oauth).toEqual({ client_id: "3zVHNs9kINDDrk8loekLZV", scope: "mcp:connect" })
  13. })
  14. test("preserves an existing client ID", () => {
  15. const server = new ConfigMCP.Remote({
  16. type: "remote",
  17. url: "https://mcp.figma.com/mcp",
  18. oauth: new ConfigMCP.OAuth({ client_id: "configured-client-id" }),
  19. })
  20. FigmaPlugin.apply(server)
  21. expect(server.oauth).toEqual({ client_id: "configured-client-id" })
  22. })
  23. test("does not enable OAuth or modify non-Figma servers", () => {
  24. const disabled = new ConfigMCP.Remote({
  25. type: "remote",
  26. url: "https://mcp.figma.com/mcp",
  27. oauth: false,
  28. })
  29. const other = new ConfigMCP.Remote({
  30. type: "remote",
  31. url: "https://mcp.example.com/mcp",
  32. })
  33. FigmaPlugin.apply(disabled)
  34. FigmaPlugin.apply(other)
  35. expect(disabled.oauth).toBe(false)
  36. expect(other.oauth).toBeUndefined()
  37. })
  38. })