Files
defiQUG f52313e7c6 Enhance ComboHandler and orchestrator functionality with access control and error handling improvements
- Added AccessControl to ComboHandler for role-based access management.
- Implemented gas estimation for plan execution and improved gas limit checks.
- Updated execution and preparation methods to enforce step count limits and role restrictions.
- Enhanced error handling in orchestrator API endpoints with AppError for better validation feedback.
- Integrated request timeout middleware for improved request management.
- Updated Swagger documentation to reflect new API structure and parameters.
2025-11-05 17:55:48 -08:00

52 lines
1.3 KiB
TypeScript

import { describe, it, expect, beforeAll, afterAll } from "@jest/globals";
import request from "supertest";
import express from "express";
import { createPlan, getPlan } from "../../src/api/plans";
// Mock Express app
const app = express();
app.use(express.json());
app.post("/api/plans", createPlan);
app.get("/api/plans/:planId", getPlan);
describe("Plan Management Integration Tests", () => {
it("should create a plan", async () => {
const plan = {
creator: "test-user",
steps: [
{ type: "borrow", asset: "CBDC_USD", amount: 100000 },
],
};
const response = await request(app)
.post("/api/plans")
.send(plan)
.expect(201);
expect(response.body).toHaveProperty("plan_id");
expect(response.body).toHaveProperty("plan_hash");
});
it("should get a plan by ID", async () => {
// First create a plan
const plan = {
creator: "test-user",
steps: [{ type: "borrow", asset: "CBDC_USD", amount: 100000 }],
};
const createResponse = await request(app)
.post("/api/plans")
.send(plan);
const planId = createResponse.body.plan_id;
// Then get it
const getResponse = await request(app)
.get(`/api/plans/${planId}`)
.expect(200);
expect(getResponse.body.plan_id).toBe(planId);
});
});