feat(14-06): convert route tests + MCP tests to async PGlite
- All 8 route test files: async createTestApp(), async beforeEach - MCP tools test: await createTestDb(), await getCollectionSummary() - Fixed MCP tool files: added await to all service calls in items, categories, threads, setups tools - Fixed MCP collection resource: made getCollectionSummary async - Fixed MCP index.ts: await getCollectionSummary call - Increased test timeout to 30s in bunfig.toml for PGlite WASM overhead - Zero SQLite references remain in tests/ Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -6,8 +6,8 @@ import { oauthRoutes, wellKnownRoute } from "../../src/server/routes/oauth.ts";
|
||||
import { createUser } from "../../src/server/services/auth.service.ts";
|
||||
import { createTestDb } from "../helpers/db.ts";
|
||||
|
||||
function createTestApp() {
|
||||
const db = createTestDb();
|
||||
async function createTestApp() {
|
||||
const db = await createTestDb();
|
||||
const app = new Hono<{ Variables: { db?: any } }>();
|
||||
app.use("*", async (c, next) => {
|
||||
c.set("db", db);
|
||||
@@ -18,8 +18,8 @@ function createTestApp() {
|
||||
return { app, db };
|
||||
}
|
||||
|
||||
function createFullTestApp() {
|
||||
const db = createTestDb();
|
||||
async function createFullTestApp() {
|
||||
const db = await createTestDb();
|
||||
const app = new Hono<{ Variables: { db?: any } }>();
|
||||
app.use("*", async (c, next) => {
|
||||
c.set("db", db);
|
||||
@@ -39,10 +39,10 @@ function generatePkce() {
|
||||
|
||||
describe("OAuth Routes", () => {
|
||||
let app: Hono;
|
||||
let db: ReturnType<typeof createTestDb>;
|
||||
let db: any;
|
||||
|
||||
beforeEach(async () => {
|
||||
const testApp = createTestApp();
|
||||
const testApp = await createTestApp();
|
||||
app = testApp.app;
|
||||
db = testApp.db;
|
||||
await createUser(db, "admin", "secret123");
|
||||
@@ -182,7 +182,7 @@ describe("OAuth Routes", () => {
|
||||
});
|
||||
|
||||
describe("Full OAuth flow", () => {
|
||||
it("register → authorize → token exchange", async () => {
|
||||
it("register -> authorize -> token exchange", async () => {
|
||||
// 1. Register client
|
||||
const regRes = await app.request("/oauth/register", {
|
||||
method: "POST",
|
||||
@@ -245,9 +245,9 @@ describe("OAuth Routes", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("Full OAuth → MCP Flow", () => {
|
||||
it("complete flow: register → authorize → token → MCP call", async () => {
|
||||
const { app, db } = createFullTestApp();
|
||||
describe("Full OAuth -> MCP Flow", () => {
|
||||
it("complete flow: register -> authorize -> token -> MCP call", async () => {
|
||||
const { app, db } = await createFullTestApp();
|
||||
await createUser(db, "admin", "secret123");
|
||||
const { verifier, challenge } = generatePkce();
|
||||
|
||||
@@ -321,7 +321,7 @@ describe("OAuth Routes", () => {
|
||||
});
|
||||
|
||||
it("rejects MCP call without auth when user exists", async () => {
|
||||
const { app, db } = createFullTestApp();
|
||||
const { app, db } = await createFullTestApp();
|
||||
await createUser(db, "admin", "secret123");
|
||||
|
||||
const mcpRes = await app.request("/mcp", {
|
||||
|
||||
Reference in New Issue
Block a user