Files
czlonkowski--n8n-mcp/tests/test-node-documentation-service.js
wehub-resource-sync 409e92d6ae
Build and Push Docker Images / Build Docker Image (push) Has been cancelled
Build and Push Docker Images / Build Railway Docker Image (push) Has been cancelled
Build and Publish n8n Docker Image / test-image (push) Has been cancelled
Dependency Compatibility Check / Fresh Install Dependency Check (push) Has been cancelled
Build and Publish n8n Docker Image / build-and-push (push) Has been cancelled
Build and Publish n8n Docker Image / create-release (push) Has been cancelled
Automated Release / Detect Version Change (push) Has been cancelled
Automated Release / Generate Release Notes (push) Has been cancelled
Automated Release / Create GitHub Release (push) Has been cancelled
Automated Release / Package MCPB Bundle (push) Has been cancelled
Automated Release / Build and Verify (push) Has been cancelled
Automated Release / Publish to NPM (push) Has been cancelled
Automated Release / Build and Push Docker Images (push) Has been cancelled
Automated Release / Update Documentation (push) Has been cancelled
Automated Release / Notify Release Completion (push) Has been cancelled
Secret Scan / secretlint (push) Has been cancelled
Test Suite / test (push) Has been cancelled
Test Suite / cjs-runtime (push) Has been cancelled
Test Suite / publish-results (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:41:06 +08:00

88 lines
3.4 KiB
JavaScript

#!/usr/bin/env node
const { NodeDocumentationService } = require('../dist/services/node-documentation-service');
async function testService() {
console.log('=== Testing Node Documentation Service ===\n');
// Use the main database
const service = new NodeDocumentationService('./data/nodes.db');
try {
// Test 1: List nodes
console.log('1️⃣ Testing list nodes...');
const nodes = await service.listNodes();
console.log(` Found ${nodes.length} nodes in database`);
if (nodes.length === 0) {
console.log('\n⚠️ No nodes found. Running rebuild...');
const stats = await service.rebuildDatabase();
console.log(` Rebuild complete: ${stats.successful} nodes stored`);
}
// Test 2: Get specific node info (IF node)
console.log('\n2️⃣ Testing get node info for "If" node...');
const ifNode = await service.getNodeInfo('n8n-nodes-base.if');
if (ifNode) {
console.log(' ✅ Found IF node:');
console.log(` Name: ${ifNode.displayName}`);
console.log(` Description: ${ifNode.description}`);
console.log(` Has source code: ${!!ifNode.sourceCode}`);
console.log(` Source code length: ${ifNode.sourceCode?.length || 0} bytes`);
console.log(` Has documentation: ${!!ifNode.documentation}`);
console.log(` Has example: ${!!ifNode.exampleWorkflow}`);
if (ifNode.exampleWorkflow) {
console.log('\n 📋 Example workflow:');
console.log(JSON.stringify(ifNode.exampleWorkflow, null, 2).substring(0, 500) + '...');
}
} else {
console.log(' ❌ IF node not found');
}
// Test 3: Search nodes
console.log('\n3️⃣ Testing search functionality...');
// Search for webhook nodes
const webhookNodes = await service.searchNodes({ query: 'webhook' });
console.log(`\n 🔍 Search for "webhook": ${webhookNodes.length} results`);
webhookNodes.slice(0, 3).forEach(node => {
console.log(` - ${node.displayName} (${node.nodeType})`);
});
// Search for HTTP nodes
const httpNodes = await service.searchNodes({ query: 'http' });
console.log(`\n 🔍 Search for "http": ${httpNodes.length} results`);
httpNodes.slice(0, 3).forEach(node => {
console.log(` - ${node.displayName} (${node.nodeType})`);
});
// Test 4: Get statistics
console.log('\n4️⃣ Testing database statistics...');
const stats = service.getStatistics();
console.log(' 📊 Database stats:');
console.log(` Total nodes: ${stats.totalNodes}`);
console.log(` Nodes with docs: ${stats.nodesWithDocs}`);
console.log(` Nodes with examples: ${stats.nodesWithExamples}`);
console.log(` Trigger nodes: ${stats.triggerNodes}`);
console.log(` Webhook nodes: ${stats.webhookNodes}`);
console.log(` Total packages: ${stats.totalPackages}`);
// Test 5: Category filtering
console.log('\n5️⃣ Testing category filtering...');
const coreNodes = await service.searchNodes({ category: 'Core Nodes' });
console.log(` Found ${coreNodes.length} core nodes`);
console.log('\n✅ All tests completed!');
} catch (error) {
console.error('\n❌ Test failed:', error);
process.exit(1);
} finally {
service.close();
}
}
// Run tests
testService().catch(console.error);