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:
@@ -14,7 +14,7 @@ function parseResult(result: {
|
||||
|
||||
describe("MCP Item Tools", () => {
|
||||
test("list_items returns array", async () => {
|
||||
const db = createTestDb();
|
||||
const db = await createTestDb();
|
||||
const tools = registerItemTools(db);
|
||||
const result = await tools.list_items({});
|
||||
const data = parseResult(result);
|
||||
@@ -22,7 +22,7 @@ describe("MCP Item Tools", () => {
|
||||
});
|
||||
|
||||
test("create_item creates and returns item", async () => {
|
||||
const db = createTestDb();
|
||||
const db = await createTestDb();
|
||||
const tools = registerItemTools(db);
|
||||
const result = await tools.create_item({
|
||||
name: "Test Tent",
|
||||
@@ -38,7 +38,7 @@ describe("MCP Item Tools", () => {
|
||||
});
|
||||
|
||||
test("get_item retrieves by ID", async () => {
|
||||
const db = createTestDb();
|
||||
const db = await createTestDb();
|
||||
const tools = registerItemTools(db);
|
||||
const created = parseResult(
|
||||
await tools.create_item({ name: "Sleeping Bag", categoryId: 1 }),
|
||||
@@ -50,7 +50,7 @@ describe("MCP Item Tools", () => {
|
||||
});
|
||||
|
||||
test("get_item returns error for missing item", async () => {
|
||||
const db = createTestDb();
|
||||
const db = await createTestDb();
|
||||
const tools = registerItemTools(db);
|
||||
const result = await tools.get_item({ id: 999 });
|
||||
const data = parseResult(result);
|
||||
@@ -58,7 +58,7 @@ describe("MCP Item Tools", () => {
|
||||
});
|
||||
|
||||
test("delete_item removes item", async () => {
|
||||
const db = createTestDb();
|
||||
const db = await createTestDb();
|
||||
const tools = registerItemTools(db);
|
||||
const created = parseResult(
|
||||
await tools.create_item({ name: "To Delete", categoryId: 1 }),
|
||||
@@ -76,7 +76,7 @@ describe("MCP Item Tools", () => {
|
||||
|
||||
describe("MCP Category Tools", () => {
|
||||
test("list_categories returns array with Uncategorized", async () => {
|
||||
const db = createTestDb();
|
||||
const db = await createTestDb();
|
||||
const tools = registerCategoryTools(db);
|
||||
const result = await tools.list_categories();
|
||||
const data = parseResult(result);
|
||||
@@ -86,7 +86,7 @@ describe("MCP Category Tools", () => {
|
||||
});
|
||||
|
||||
test("create_category creates a new category", async () => {
|
||||
const db = createTestDb();
|
||||
const db = await createTestDb();
|
||||
const tools = registerCategoryTools(db);
|
||||
const result = await tools.create_category({
|
||||
name: "Shelter",
|
||||
@@ -100,7 +100,7 @@ describe("MCP Category Tools", () => {
|
||||
|
||||
describe("MCP Thread Tools", () => {
|
||||
test("create_thread starts a thread with status active", async () => {
|
||||
const db = createTestDb();
|
||||
const db = await createTestDb();
|
||||
const tools = registerThreadTools(db);
|
||||
const result = await tools.create_thread({
|
||||
name: "Handlebar Bag",
|
||||
@@ -112,7 +112,7 @@ describe("MCP Thread Tools", () => {
|
||||
});
|
||||
|
||||
test("add_candidate adds to thread", async () => {
|
||||
const db = createTestDb();
|
||||
const db = await createTestDb();
|
||||
const tools = registerThreadTools(db);
|
||||
const thread = parseResult(
|
||||
await tools.create_thread({ name: "Saddle Bag", categoryId: 1 }),
|
||||
@@ -132,7 +132,7 @@ describe("MCP Thread Tools", () => {
|
||||
});
|
||||
|
||||
test("resolve_thread picks winner and creates item", async () => {
|
||||
const db = createTestDb();
|
||||
const db = await createTestDb();
|
||||
const threadTools = registerThreadTools(db);
|
||||
const itemTools = registerItemTools(db);
|
||||
|
||||
@@ -179,7 +179,7 @@ describe("MCP Thread Tools", () => {
|
||||
|
||||
describe("MCP Setup Tools", () => {
|
||||
test("create_setup and list_setups", async () => {
|
||||
const db = createTestDb();
|
||||
const db = await createTestDb();
|
||||
const tools = registerSetupTools(db);
|
||||
await tools.create_setup({ name: "Weekend Trip" });
|
||||
const result = await tools.list_setups();
|
||||
@@ -189,7 +189,7 @@ describe("MCP Setup Tools", () => {
|
||||
});
|
||||
|
||||
test("get_setup returns setup with items", async () => {
|
||||
const db = createTestDb();
|
||||
const db = await createTestDb();
|
||||
const setupTools = registerSetupTools(db);
|
||||
const itemTools = registerItemTools(db);
|
||||
|
||||
@@ -210,10 +210,10 @@ describe("MCP Setup Tools", () => {
|
||||
});
|
||||
|
||||
describe("MCP Collection Summary Resource", () => {
|
||||
test("returns overview with correct counts", () => {
|
||||
const db = createTestDb();
|
||||
test("returns overview with correct counts", async () => {
|
||||
const db = await createTestDb();
|
||||
|
||||
const summary = getCollectionSummary(db);
|
||||
const summary = await getCollectionSummary(db);
|
||||
expect(summary.overview).toBeDefined();
|
||||
expect(summary.overview.totalItems).toBe(0);
|
||||
expect(summary.overview.categoryCount).toBe(1); // Uncategorized
|
||||
@@ -223,7 +223,7 @@ describe("MCP Collection Summary Resource", () => {
|
||||
});
|
||||
|
||||
test("reflects items and threads after creation", async () => {
|
||||
const db = createTestDb();
|
||||
const db = await createTestDb();
|
||||
const itemTools = registerItemTools(db);
|
||||
const threadTools = registerThreadTools(db);
|
||||
|
||||
@@ -242,7 +242,7 @@ describe("MCP Collection Summary Resource", () => {
|
||||
categoryId: 1,
|
||||
});
|
||||
|
||||
const summary = getCollectionSummary(db);
|
||||
const summary = await getCollectionSummary(db);
|
||||
expect(summary.overview.totalItems).toBe(2);
|
||||
expect(summary.overview.totalWeightGrams).toBe(2000);
|
||||
expect(summary.overview.activeThreadCount).toBe(1);
|
||||
|
||||
Reference in New Issue
Block a user