Keep route fixture imports outside HTTP assertion timeouts

This commit is contained in:
Dotta 2026-09-11 15:25:12 -05:00
parent 74f1914d55
commit 601eacf0f8
1 changed files with 10 additions and 4 deletions

View File

@ -177,11 +177,15 @@ function createDb(requireBoardApprovalForNewAgents = false) {
};
}
async function createApp(db: Record<string, unknown> = createDb()) {
const [{ agentRoutes }, { errorHandler }] = await Promise.all([
function loadAppModules() {
return Promise.all([
vi.importActual<typeof import("../routes/agents.js")>("../routes/agents.js"),
vi.importActual<typeof import("../middleware/index.js")>("../middleware/index.js"),
]);
}
async function createApp(db: Record<string, unknown> = createDb()) {
const [{ agentRoutes }, { errorHandler }] = await loadAppModules();
const app = express();
app.use(express.json());
app.use((req, _res, next) => {
@ -246,7 +250,7 @@ function makeAgent(adapterType: string) {
}
describe.sequential("agent skill routes", () => {
beforeEach(() => {
beforeEach(async () => {
vi.resetModules();
vi.doUnmock("../routes/agents.js");
vi.doUnmock("../routes/authz.js");
@ -369,7 +373,9 @@ describe.sequential("agent skill routes", () => {
mockAccessService.listPrincipalGrants.mockResolvedValue([]);
mockAccessService.ensureMembership.mockResolvedValue(undefined);
mockAccessService.setPrincipalPermission.mockResolvedValue(undefined);
});
// Keep cold route imports in setup rather than the HTTP assertion timeout.
await loadAppModules();
}, 60_000);
it("skips runtime materialization when listing Claude skills", async () => {
mockAgentService.getById.mockResolvedValue(makeAgent("claude_local"));