mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-12 06:10:44 +01:00
test(server): initialize live-run route modules in per-case setup
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
4f717f6b09
commit
b2317b259a
1 file changed
+15
-10
@@ -157,6 +157,9 @@ function registerModuleMocks() {
|
||||
}));
|
||||
}
|
||||
|
||||
let agentRoutes: typeof import("../routes/agents.js")["agentRoutes"];
|
||||
let errorHandler: typeof import("../middleware/index.js")["errorHandler"];
|
||||
|
||||
async function createApp(
|
||||
db: Record<string, unknown> = {},
|
||||
actor: Record<string, unknown> = {
|
||||
@@ -168,15 +171,6 @@ async function createApp(
|
||||
},
|
||||
options: { chatRunRetries?: typeof mockChatRunRetries } = {},
|
||||
) {
|
||||
// Vitest tracks factory-mock resolution in one shared call stack. Importing
|
||||
// these graphs concurrently can drop the services/index factory mock and
|
||||
// accidentally run real DB-backed activity logging against this test stub.
|
||||
const { agentRoutes } = await vi.importActual<
|
||||
typeof import("../routes/agents.js")
|
||||
>("../routes/agents.js");
|
||||
const { errorHandler } = await vi.importActual<
|
||||
typeof import("../middleware/index.js")
|
||||
>("../middleware/index.js");
|
||||
const app = express();
|
||||
app.use(express.json());
|
||||
app.use((req, _res, next) => {
|
||||
@@ -291,7 +285,7 @@ describe("agent live run routes", () => {
|
||||
limit, { summary: query.includes("summary=true") });
|
||||
expect(mockRunSecretRedactionRegistry.redactForRuns).toHaveBeenCalled();
|
||||
});
|
||||
beforeEach(() => {
|
||||
beforeEach(async () => {
|
||||
vi.resetModules();
|
||||
vi.doUnmock("../services/agents.js");
|
||||
vi.doUnmock("../services/heartbeat.js");
|
||||
@@ -424,6 +418,17 @@ describe("agent live run routes", () => {
|
||||
skipped: 0,
|
||||
skipReasons: [],
|
||||
});
|
||||
|
||||
// Module loading is fixture setup; each behavioral case keeps its own timeout.
|
||||
// Vitest tracks factory-mock resolution in one shared call stack. Importing
|
||||
// these graphs concurrently can drop the services/index factory mock and
|
||||
// accidentally run real DB-backed activity logging against this test stub.
|
||||
({ agentRoutes } = await vi.importActual<
|
||||
typeof import("../routes/agents.js")
|
||||
>("../routes/agents.js"));
|
||||
({ errorHandler } = await vi.importActual<
|
||||
typeof import("../middleware/index.js")
|
||||
>("../middleware/index.js"));
|
||||
});
|
||||
|
||||
describe("heartbeat run ID validation", () => {
|
||||
|
||||
Reference in new issue
Block a user