Files
cc-3-8-x-mcp/server/test/local-status.test.js
T
furao ea364d3470 [cc-3-8-x-mcp] 重构: 改为 Gateway 私有 Editor Bridge
改了什么:移除项目级 MCP Server 与 universal-mcp-sdk,新增带随机 token 的本机 Editor Bridge、Gateway v2 注册和分级超时转发。

为什么:MCP 协议与多项目路由统一交给全局 Gateway,项目扩展只保留 Cocos Editor.Message 和离线 CLI 职责。

影响范围:扩展启动与面板、编辑器注册、router 转发、安全边界、使用文档及自动化测试。
2026-08-14 12:10:09 +08:00

33 lines
1.2 KiB
JavaScript

'use strict';
const test = require('node:test');
const assert = require('node:assert/strict');
const localStatus = require('../local-status');
function makeInfo(overrides) {
return Object.assign({
projectPath: '/project/forest',
projectName: 'forest',
editorPid: 123,
editorVersion: '3.8.8',
previewUrl: 'http://127.0.0.1:7456',
previewPort: 7456,
}, overrides || {});
}
test('dev-reload info 仅 updatedAt 变化时不重复写入', () => {
const previous = Object.assign(makeInfo(), { updatedAt: '2026-08-14T00:00:00.000Z' });
assert.equal(localStatus.isSameDevReloadInfo(previous, makeInfo()), true);
});
test('预览端口或编辑器进程变化时需要更新 dev-reload info', () => {
assert.equal(localStatus.isSameDevReloadInfo(makeInfo(), makeInfo({ previewPort: 7457 })), false);
assert.equal(localStatus.isSameDevReloadInfo(makeInfo(), makeInfo({ editorPid: 456 })), false);
});
test('进程存活检测接受当前进程并拒绝非法 PID', () => {
assert.equal(localStatus.isProcessAlive(process.pid), true);
assert.equal(localStatus.isProcessAlive(0), false);
assert.equal(localStatus.isProcessAlive('invalid'), false);
});