Some checks failed
CI / go (push) Waiting to run
CI / docker (push) Waiting to run
CI / lint-go (push) Waiting to run
CI / lint-docs (push) Waiting to run
CI / check-paperclip (push) Waiting to run
Deploy static site / Deploy to GitHub Pages (push) Has been cancelled
Deploy static site / Deploy via Docker to hatch.surf (push) Has been cancelled
Resolved conflicts by taking GitHub versions for: - .dockerignore, .gitignore, Dockerfile, README.md, docker-compose.yml Kept deploy.sh updated to: - Pull from GitHub (primary source) - Push to Gitea (push-mirror) - Build from site/ directory (GitHub structure) Co-Authored-By: Paperclip <noreply@paperclip.ing>
107 lines
3.5 KiB
JavaScript
107 lines
3.5 KiB
JavaScript
/**
|
|
* @jest-environment node
|
|
*/ "use strict";
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
const _build = require("./build");
|
|
describe('MCP Telemetry Events', ()=>{
|
|
it('should generate correct telemetry events for single tool', ()=>{
|
|
const usages = [
|
|
{
|
|
featureName: 'mcp/get_errors',
|
|
invocationCount: 5
|
|
}
|
|
];
|
|
const events = (0, _build.eventMcpToolUsage)(usages);
|
|
expect(events).toHaveLength(1);
|
|
expect(events[0]).toEqual({
|
|
eventName: _build.EVENT_MCP_TOOL_USAGE,
|
|
payload: {
|
|
toolName: 'mcp/get_errors',
|
|
invocationCount: 5
|
|
}
|
|
});
|
|
});
|
|
it('should generate correct telemetry events for multiple tools', ()=>{
|
|
const usages = [
|
|
{
|
|
featureName: 'mcp/get_errors',
|
|
invocationCount: 3
|
|
},
|
|
{
|
|
featureName: 'mcp/get_logs',
|
|
invocationCount: 1
|
|
},
|
|
{
|
|
featureName: 'mcp/get_page_metadata',
|
|
invocationCount: 7
|
|
}
|
|
];
|
|
const events = (0, _build.eventMcpToolUsage)(usages);
|
|
expect(events).toHaveLength(3);
|
|
expect(events[0]).toEqual({
|
|
eventName: _build.EVENT_MCP_TOOL_USAGE,
|
|
payload: {
|
|
toolName: 'mcp/get_errors',
|
|
invocationCount: 3
|
|
}
|
|
});
|
|
expect(events[1]).toEqual({
|
|
eventName: _build.EVENT_MCP_TOOL_USAGE,
|
|
payload: {
|
|
toolName: 'mcp/get_logs',
|
|
invocationCount: 1
|
|
}
|
|
});
|
|
expect(events[2]).toEqual({
|
|
eventName: _build.EVENT_MCP_TOOL_USAGE,
|
|
payload: {
|
|
toolName: 'mcp/get_page_metadata',
|
|
invocationCount: 7
|
|
}
|
|
});
|
|
});
|
|
it('should handle all MCP tool types', ()=>{
|
|
const allTools = [
|
|
'mcp/get_errors',
|
|
'mcp/get_logs',
|
|
'mcp/get_page_metadata',
|
|
'mcp/get_project_metadata',
|
|
'mcp/get_server_action_by_id'
|
|
];
|
|
const usages = allTools.map((tool, index)=>({
|
|
featureName: tool,
|
|
invocationCount: index + 1
|
|
}));
|
|
const events = (0, _build.eventMcpToolUsage)(usages);
|
|
expect(events).toHaveLength(5);
|
|
events.forEach((event, index)=>{
|
|
expect(event.eventName).toBe(_build.EVENT_MCP_TOOL_USAGE);
|
|
expect(event.payload.toolName).toBe(allTools[index]);
|
|
expect(event.payload.invocationCount).toBe(index + 1);
|
|
});
|
|
});
|
|
it('should handle empty usage array', ()=>{
|
|
const events = (0, _build.eventMcpToolUsage)([]);
|
|
expect(events).toEqual([]);
|
|
});
|
|
it('should use correct event name constant', ()=>{
|
|
expect(_build.EVENT_MCP_TOOL_USAGE).toBe('NEXT_MCP_TOOL_USAGE');
|
|
});
|
|
it('should transform featureName to toolName in payload', ()=>{
|
|
const usages = [
|
|
{
|
|
featureName: 'mcp/get_project_metadata',
|
|
invocationCount: 2
|
|
}
|
|
];
|
|
const events = (0, _build.eventMcpToolUsage)(usages);
|
|
// Verify the input has 'featureName' but output has 'toolName'
|
|
expect(usages[0]).toHaveProperty('featureName');
|
|
expect(events[0].payload).toHaveProperty('toolName');
|
|
expect(events[0].payload).not.toHaveProperty('featureName');
|
|
});
|
|
});
|
|
|
|
//# sourceMappingURL=mcp-telemetry.test.js.map
|