시나리오 탭 처리
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
class APIScenarioExecutor {
|
||||
constructor(graph) {
|
||||
constructor(graph, apiTester) {
|
||||
this.graph = graph; // The graph data
|
||||
this.currentNodeId = this.findStartNodeId(); // Initialize at the 'start' node
|
||||
this.apiClient = new APIClient();
|
||||
this.apiTester = apiTester;
|
||||
this.visitedNodes = new Set(); // Keep track of visited nodes
|
||||
}
|
||||
|
||||
@@ -19,7 +20,7 @@ class APIScenarioExecutor {
|
||||
// Method to execute the current node's API request if it's an 'api' node
|
||||
executeCurrentNode() {
|
||||
console.log(this.currentNodeId)
|
||||
if(!this.currentNodeId) {
|
||||
if (!this.currentNodeId) {
|
||||
console.log('No current node to execute.');
|
||||
return;
|
||||
}
|
||||
@@ -27,7 +28,19 @@ class APIScenarioExecutor {
|
||||
const currentNode = this.graph[this.currentNodeId];
|
||||
if (currentNode && currentNode.class === 'api') {
|
||||
// get API model with currentNode.id
|
||||
//this.apiClient.sendAPIRequest(currentNode);
|
||||
let model = this.apiTester.getApiRequestModel(currentNode.id);
|
||||
this.apiClient.sendAPIRequest(model)
|
||||
.then(response => {
|
||||
console.log(response);
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error.name)
|
||||
if (error.name === 'AbortError') {
|
||||
console.log('Fetch aborted');
|
||||
} else {
|
||||
console.log('error3')
|
||||
}
|
||||
});
|
||||
console.log(`Executing API request for node: ${currentNode.id} - ${currentNode.name}`);
|
||||
} else {
|
||||
console.log('Current node is not an API node or does not exist.');
|
||||
|
||||
Reference in New Issue
Block a user