-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest-integration.js
More file actions
144 lines (127 loc) · 4.9 KB
/
Copy pathtest-integration.js
File metadata and controls
144 lines (127 loc) · 4.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/usr/bin/env node
// Integration test for frontend-orchestrator connection
// This script tests the API endpoints that the frontend uses
const axios = require("axios");
const ORCHESTRATOR_URL = "http://localhost:8080";
const FRONTEND_URL = "http://localhost:5173";
async function testIntegration() {
console.log("🧪 Testing Frontend-Orchestrator Integration\n");
try {
// Test 1: Check orchestrator health
console.log("1️⃣ Testing orchestrator health...");
const healthResponse = await axios.get(`${ORCHESTRATOR_URL}/health`);
console.log("✅ Orchestrator is healthy");
console.log(` Agents available: ${healthResponse.data.agents.length}`);
healthResponse.data.agents.forEach((agent) => {
console.log(` - ${agent.name}: ${agent.description}`);
});
console.log();
// Test 2: Check frontend accessibility
console.log("2️⃣ Testing frontend accessibility...");
const frontendResponse = await axios.get(FRONTEND_URL);
console.log("✅ Frontend is accessible");
console.log(
` Title: ${
frontendResponse.data.match(/<title>(.*?)<\/title>/)?.[1] || "Not found"
}`
);
console.log();
// Test 3: Test workflow creation
console.log("3️⃣ Testing workflow creation...");
const workflowData = {
description: "Integration test: Create a simple greeting workflow",
context: { source: "integration-test" },
preferences: { executionMode: "sequential" },
};
const createResponse = await axios.post(
`${ORCHESTRATOR_URL}/workflows/create`,
workflowData
);
const workflow = createResponse.data.workflow;
console.log("✅ Workflow created successfully");
console.log(` Workflow ID: ${workflow.workflowId}`);
console.log(` Steps: ${workflow.steps.length}`);
workflow.steps.forEach((step, index) => {
console.log(` ${index + 1}. ${step.agentName}: ${step.description}`);
});
console.log();
// Test 4: Test workflow execution
console.log("4️⃣ Testing workflow execution...");
const executeResponse = await axios.post(
`${ORCHESTRATOR_URL}/workflows/execute`,
{
workflowId: workflow.workflowId,
input: {
userName: "Integration Test User",
userLanguage: "English",
},
}
);
const execution = executeResponse.data.execution;
console.log("✅ Workflow execution started");
console.log(` Execution ID: ${execution.executionId}`);
console.log(` Status: ${execution.status}`);
console.log();
// Test 5: Poll execution status
console.log("5️⃣ Polling execution status...");
let finalExecution = execution;
let attempts = 0;
const maxAttempts = 10;
while (finalExecution.status === "running" && attempts < maxAttempts) {
await new Promise((resolve) => setTimeout(resolve, 2000)); // Wait 2 seconds
attempts++;
try {
const statusResponse = await axios.get(
`${ORCHESTRATOR_URL}/workflows/executions/${execution.executionId}`
);
finalExecution = statusResponse.data.execution;
console.log(
` Attempt ${attempts}: Status = ${finalExecution.status}`
);
} catch (error) {
console.log(` Attempt ${attempts}: Error checking status`);
break;
}
}
console.log("✅ Final execution status:", finalExecution.status);
if (finalExecution.stepResults && finalExecution.stepResults.length > 0) {
console.log(" Step results:");
finalExecution.stepResults.forEach((result, index) => {
console.log(` ${index + 1}. ${result.stepId}: ${result.status}`);
if (result.output) {
console.log(
` Output: ${JSON.stringify(result.output).substring(
0,
100
)}...`
);
}
});
}
console.log();
// Test 6: Test agents endpoint
console.log("6️⃣ Testing agents endpoint...");
const agentsResponse = await axios.get(`${ORCHESTRATOR_URL}/agents`);
console.log("✅ Agents endpoint working");
console.log(` Total agents: ${agentsResponse.data.agents.length}`);
console.log();
console.log("🎉 All integration tests passed!");
console.log("\n📋 Summary:");
console.log(" ✅ Orchestrator health check");
console.log(" ✅ Frontend accessibility");
console.log(" ✅ Workflow creation");
console.log(" ✅ Workflow execution");
console.log(" ✅ Execution status polling");
console.log(" ✅ Agents discovery");
console.log("\n🚀 Frontend-Orchestrator integration is working correctly!");
} catch (error) {
console.error("❌ Integration test failed:", error.message);
if (error.response) {
console.error(" Response status:", error.response.status);
console.error(" Response data:", error.response.data);
}
process.exit(1);
}
}
// Run the test
testIntegration();