chore: establish YCode replication baseline and TODO
This commit is contained in:
commit
6dc59f89ba
1118 files changed
+196002
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import fs from 'node:fs/promises'
|
||||
import path from 'node:path'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
import assert from 'node:assert/strict'
|
||||
import { build } from 'esbuild'
|
||||
const directory = await fs.mkdtemp(path.resolve('.tmp/mcp-helpers-'))
|
||||
const file = path.join(directory, 'helpers.mjs')
|
||||
await build({ entryPoints: ['src/renderer/src/capabilities/connectors-helpers.ts'], outfile: file, bundle: true, platform: 'node', format: 'esm', logLevel: 'warning' })
|
||||
const { mcpEditorDocument, parseMcpEditor } = await import(pathToFileURL(file).href)
|
||||
const checks = [], test = (label, operation) => { operation(); checks.push({ label, pass: true }) }
|
||||
const existing = { id: 'existing', name: 'Before', transport: 'http', url: 'http://127.0.0.1:3333/mcp', enabled: true, status: 'disconnected', trusted: true, configHash: 'qa', tools: [], envKeys: ['ENV_TOKEN'], headerKeys: ['authorization'] }
|
||||
test('editor uses blank credential metadata, never stored secret values', () => assert.deepEqual(JSON.parse(mcpEditorDocument(existing)).mcpServers.Before, { url: existing.url, env: { ENV_TOKEN: '' }, headers: { authorization: '' } }))
|
||||
test('editing retains target id and enabled state', () => { const result = parseMcpEditor(mcpEditorDocument(existing), existing); assert.equal(result.id, existing.id); assert.equal(result.enabled, true) })
|
||||
test('renaming edits the same server instead of overwriting another', () => { const body = JSON.parse(mcpEditorDocument(existing)); body.mcpServers.After = body.mcpServers.Before; delete body.mcpServers.Before; const result = parseMcpEditor(JSON.stringify(body), existing); assert.equal(result.id, 'existing'); assert.equal(result.name, 'After') })
|
||||
test('blank existing credentials reach preservation contract', () => assert.deepEqual(parseMcpEditor(mcpEditorDocument(existing), existing).headers, { authorization: '' }))
|
||||
test('new stdio config starts disabled and does not invent trust', () => { const result = parseMcpEditor('{"mcpServers":{"New":{"command":"node","args":["server.mjs"]}}}'); assert.equal(result.enabled, false); assert.equal(result.transport, 'stdio'); assert.equal(result.id, undefined) })
|
||||
test('HTTP URL selects actual supported transport', () => assert.equal(parseMcpEditor('{"mcpServers":{"Remote":{"url":"http://localhost:3333/mcp","type":"streamable-http"}}}').transport, 'http'))
|
||||
test('invalid JSON cannot partially save', () => assert.throws(() => parseMcpEditor('{broken'), /JSON/))
|
||||
test('multi-server document cannot silently replace registry', () => assert.throws(() => parseMcpEditor('{"mcpServers":{"A":{"command":"node"},"B":{"command":"node"}}}'), /一个/))
|
||||
test('empty document cannot silently remove registry', () => assert.throws(() => parseMcpEditor('{"mcpServers":{}}'), /一个/))
|
||||
test('unsupported SSE is not mislabeled as StreamableHTTP support', () => assert.throws(() => parseMcpEditor('{"mcpServers":{"A":{"url":"http://localhost/mcp","type":"sse"}}}'), /支持/))
|
||||
test('args rejects non-string values', () => assert.throws(() => parseMcpEditor('{"mcpServers":{"A":{"command":"node","args":[1]}}}'), /args/))
|
||||
test('headers reject nested credential objects', () => assert.throws(() => parseMcpEditor('{"mcpServers":{"A":{"url":"http://localhost/mcp","headers":{"Authorization":{"token":"x"}}}}}'), /headers/))
|
||||
await fs.writeFile(path.join(directory, 'report.json'), JSON.stringify({ result: 'PASS', checks }, null, 2))
|
||||
console.log('MCP_HELPERS_PASS ' + checks.length + ' ' + directory)
|
||||
Reference in new issue
Block a user