openpencil/tests/engine/app/integrations/pi-mcp.test.ts
Danila Poyarkov 076f7ce0d9
fix: restore engine test coverage and isolation (#653)
* ci: require complete engine test shard coverage

* test: provide path data in the font editing gate fixture

* test: remove stale Tauri runtime markers during cleanup

* fix(collab): deduplicate pending page switches

* test: simplify pending page switch regression setup
2026-09-06 23:29:45 +03:00

47 lines
1.5 KiB
TypeScript

import { afterEach, beforeEach, describe, expect, test } from 'bun:test'
import { replaceMCPConnectionSettings, setMCPConnectionCredential } from '@/app/integrations/mcp'
import { buildPiMCPServers } from '@/app/integrations/mcp/pi'
import { clearTauriMocks, installTauriMockWindow } from '#tests/helpers/tauri/mocks'
beforeEach(installTauriMockWindow)
afterEach(clearTauriMocks)
describe('Pi MCP configuration', () => {
test('adapts the built-in and external MCP servers to Pi native configuration', async () => {
replaceMCPConnectionSettings({
version: 1,
connections: [
{
id: 'mcp-example',
name: 'example',
enabled: true,
transport: { type: 'streamable-http', url: 'https://example.com/mcp' },
authentication: {
type: 'bearer',
credentialRef: {
integrationId: 'mcp',
profileId: 'mcp-example',
field: 'bearer-token'
}
}
}
]
})
await setMCPConnectionCredential('mcp-example', 'external-token')
const servers = await buildPiMCPServers({ authorizationToken: 'built-in-token' })
expect(servers.example).toEqual({
url: 'https://example.com/mcp',
headers: { Authorization: 'Bearer external-token' },
auth: false
})
expect(servers['open-pencil']).toEqual({
url: expect.stringContaining('/mcp'),
headers: { Authorization: 'Bearer built-in-token' },
auth: false
})
})
})