mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-02-09 06:43:08 +00:00
Add workflow-list, execution-history, and health-dashboard apps. Redesign operation-result with operation-aware headers, detail panels, and copy-to-clipboard. Fix React hooks violations in validation-summary and execution-history (useMemo after early returns). Add local preview harness for development. Update tests for 5-app config. Conceived by Romuald Członkowski - www.aiadvisors.pl/en Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
132 lines
4.8 KiB
TypeScript
132 lines
4.8 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { UI_APP_CONFIGS } from '@/mcp/ui/app-configs';
|
|
|
|
describe('UI_APP_CONFIGS', () => {
|
|
it('should have all required fields for every config', () => {
|
|
for (const config of UI_APP_CONFIGS) {
|
|
expect(config.id).toBeDefined();
|
|
expect(typeof config.id).toBe('string');
|
|
expect(config.id.length).toBeGreaterThan(0);
|
|
|
|
expect(config.displayName).toBeDefined();
|
|
expect(typeof config.displayName).toBe('string');
|
|
expect(config.displayName.length).toBeGreaterThan(0);
|
|
|
|
expect(config.description).toBeDefined();
|
|
expect(typeof config.description).toBe('string');
|
|
expect(config.description.length).toBeGreaterThan(0);
|
|
|
|
expect(config.uri).toBeDefined();
|
|
expect(typeof config.uri).toBe('string');
|
|
|
|
expect(config.mimeType).toBeDefined();
|
|
expect(typeof config.mimeType).toBe('string');
|
|
|
|
expect(config.toolPatterns).toBeDefined();
|
|
expect(Array.isArray(config.toolPatterns)).toBe(true);
|
|
}
|
|
});
|
|
|
|
it('should have URIs following ui://n8n-mcp/{id} pattern', () => {
|
|
for (const config of UI_APP_CONFIGS) {
|
|
expect(config.uri).toBe(`ui://n8n-mcp/${config.id}`);
|
|
}
|
|
});
|
|
|
|
it('should have unique IDs', () => {
|
|
const ids = UI_APP_CONFIGS.map(c => c.id);
|
|
const uniqueIds = new Set(ids);
|
|
expect(uniqueIds.size).toBe(ids.length);
|
|
});
|
|
|
|
it('should have non-empty toolPatterns arrays', () => {
|
|
for (const config of UI_APP_CONFIGS) {
|
|
expect(config.toolPatterns.length).toBeGreaterThan(0);
|
|
for (const pattern of config.toolPatterns) {
|
|
expect(typeof pattern).toBe('string');
|
|
expect(pattern.length).toBeGreaterThan(0);
|
|
}
|
|
}
|
|
});
|
|
|
|
it('should not have duplicate tool patterns across configs', () => {
|
|
const allPatterns: string[] = [];
|
|
for (const config of UI_APP_CONFIGS) {
|
|
allPatterns.push(...config.toolPatterns);
|
|
}
|
|
const uniquePatterns = new Set(allPatterns);
|
|
expect(uniquePatterns.size).toBe(allPatterns.length);
|
|
});
|
|
|
|
it('should not have duplicate tool patterns within a single config', () => {
|
|
for (const config of UI_APP_CONFIGS) {
|
|
const unique = new Set(config.toolPatterns);
|
|
expect(unique.size).toBe(config.toolPatterns.length);
|
|
}
|
|
});
|
|
|
|
it('should have consistent mimeType of text/html;profile=mcp-app', () => {
|
|
for (const config of UI_APP_CONFIGS) {
|
|
expect(config.mimeType).toBe('text/html;profile=mcp-app');
|
|
}
|
|
});
|
|
|
|
it('should have URIs that start with the ui://n8n-mcp/ scheme', () => {
|
|
for (const config of UI_APP_CONFIGS) {
|
|
expect(config.uri).toMatch(/^ui:\/\/n8n-mcp\//);
|
|
}
|
|
});
|
|
|
|
// Regression: verify expected configs are present
|
|
it('should contain the operation-result config', () => {
|
|
const config = UI_APP_CONFIGS.find(c => c.id === 'operation-result');
|
|
expect(config).toBeDefined();
|
|
expect(config!.displayName).toBe('Operation Result');
|
|
expect(config!.toolPatterns).toContain('n8n_create_workflow');
|
|
expect(config!.toolPatterns).toContain('n8n_update_full_workflow');
|
|
expect(config!.toolPatterns).toContain('n8n_delete_workflow');
|
|
expect(config!.toolPatterns).toContain('n8n_test_workflow');
|
|
expect(config!.toolPatterns).toContain('n8n_deploy_template');
|
|
});
|
|
|
|
it('should contain the validation-summary config', () => {
|
|
const config = UI_APP_CONFIGS.find(c => c.id === 'validation-summary');
|
|
expect(config).toBeDefined();
|
|
expect(config!.displayName).toBe('Validation Summary');
|
|
expect(config!.toolPatterns).toContain('validate_node');
|
|
expect(config!.toolPatterns).toContain('validate_workflow');
|
|
expect(config!.toolPatterns).toContain('n8n_validate_workflow');
|
|
});
|
|
|
|
it('should have exactly 5 configs', () => {
|
|
expect(UI_APP_CONFIGS.length).toBe(5);
|
|
});
|
|
|
|
it('should contain the workflow-list config', () => {
|
|
const config = UI_APP_CONFIGS.find(c => c.id === 'workflow-list');
|
|
expect(config).toBeDefined();
|
|
expect(config!.displayName).toBe('Workflow List');
|
|
expect(config!.toolPatterns).toContain('n8n_list_workflows');
|
|
});
|
|
|
|
it('should contain the execution-history config', () => {
|
|
const config = UI_APP_CONFIGS.find(c => c.id === 'execution-history');
|
|
expect(config).toBeDefined();
|
|
expect(config!.displayName).toBe('Execution History');
|
|
expect(config!.toolPatterns).toContain('n8n_executions');
|
|
});
|
|
|
|
it('should contain the health-dashboard config', () => {
|
|
const config = UI_APP_CONFIGS.find(c => c.id === 'health-dashboard');
|
|
expect(config).toBeDefined();
|
|
expect(config!.displayName).toBe('Health Dashboard');
|
|
expect(config!.toolPatterns).toContain('n8n_health_check');
|
|
});
|
|
|
|
it('should have IDs that are valid URI path segments (no spaces or special chars)', () => {
|
|
for (const config of UI_APP_CONFIGS) {
|
|
expect(config.id).toMatch(/^[a-z0-9-]+$/);
|
|
}
|
|
});
|
|
});
|