fix(core): apply Figma OAuth config before startup
This commit is contained in:
parent
49be2b3a89
commit
d3bb1859e0
7 changed files with 68 additions and 127 deletions
47
packages/core/test/plugin/figma.test.ts
Normal file
47
packages/core/test/plugin/figma.test.ts
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import { describe, expect, test } from "bun:test"
|
||||
import { ConfigMCP } from "@opencode-ai/core/config/mcp"
|
||||
import { FigmaPlugin } from "@opencode-ai/core/plugin/figma"
|
||||
|
||||
describe("plugin.figma", () => {
|
||||
test("adds the OpenCode client ID to configured Figma servers", () => {
|
||||
const server = new ConfigMCP.Remote({
|
||||
type: "remote",
|
||||
url: "https://mcp.figma.com/mcp",
|
||||
oauth: new ConfigMCP.OAuth({ scope: "mcp:connect" }),
|
||||
})
|
||||
|
||||
FigmaPlugin.apply(server)
|
||||
|
||||
expect(server.oauth).toEqual({ client_id: "3zVHNs9kINDDrk8loekLZV", scope: "mcp:connect" })
|
||||
})
|
||||
|
||||
test("preserves an existing client ID", () => {
|
||||
const server = new ConfigMCP.Remote({
|
||||
type: "remote",
|
||||
url: "https://mcp.figma.com/mcp",
|
||||
oauth: new ConfigMCP.OAuth({ client_id: "configured-client-id" }),
|
||||
})
|
||||
|
||||
FigmaPlugin.apply(server)
|
||||
|
||||
expect(server.oauth).toEqual({ client_id: "configured-client-id" })
|
||||
})
|
||||
|
||||
test("does not enable OAuth or modify non-Figma servers", () => {
|
||||
const disabled = new ConfigMCP.Remote({
|
||||
type: "remote",
|
||||
url: "https://mcp.figma.com/mcp",
|
||||
oauth: false,
|
||||
})
|
||||
const other = new ConfigMCP.Remote({
|
||||
type: "remote",
|
||||
url: "https://mcp.example.com/mcp",
|
||||
})
|
||||
|
||||
FigmaPlugin.apply(disabled)
|
||||
FigmaPlugin.apply(other)
|
||||
|
||||
expect(disabled.oauth).toBe(false)
|
||||
expect(other.oauth).toBeUndefined()
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue