- 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.
52 lines
1.3 KiB
TypeScript
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);
|
|
});
|
|
});
|
|
|