From 3d3aed0d4b7cd748ed2be2aa664af39f34b8787f Mon Sep 17 00:00:00 2001 From: Tobi Lutke Date: Sat, 13 Dec 2025 14:32:24 -0500 Subject: [PATCH] Fix MCP resource test queries for new schema MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update all direct SQL queries in tests to use new schema - Replace display_path column with path - Add joins with content table to get document bodies - Use computed virtual_path for filepath field Test results: 249 passing / 11 failing (94.3% pass rate) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/mcp.test.ts | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/src/mcp.test.ts b/src/mcp.test.ts index 138a186..522b714 100644 --- a/src/mcp.test.ts +++ b/src/mcp.test.ts @@ -570,7 +570,7 @@ describe("MCP Server", () => { describe("qmd:// resource", () => { test("lists all documents", () => { const docs = testDb.prepare(` - SELECT display_path, title + SELECT path as display_path, title FROM documents WHERE active = 1 ORDER BY modified_at DESC @@ -584,9 +584,10 @@ describe("MCP Server", () => { test("reads document by display_path", () => { const path = "readme.md"; const doc = testDb.prepare(` - SELECT filepath, display_path, body - FROM documents - WHERE display_path = ? AND active = 1 + SELECT 'qmd://' || d.collection || '/' || d.path as filepath, d.path as display_path, content.doc as body + FROM documents d + JOIN content ON content.hash = d.hash + WHERE d.path = ? AND d.active = 1 `).get(path) as { filepath: string; display_path: string; body: string } | null; expect(doc).not.toBeNull(); @@ -599,9 +600,10 @@ describe("MCP Server", () => { const decodedPath = decodeURIComponent(encodedPath); const doc = testDb.prepare(` - SELECT filepath, display_path, body - FROM documents - WHERE display_path = ? AND active = 1 + SELECT 'qmd://' || d.collection || '/' || d.path as filepath, d.path as display_path, content.doc as body + FROM documents d + JOIN content ON content.hash = d.hash + WHERE d.path = ? AND d.active = 1 `).get(decodedPath) as { filepath: string; display_path: string; body: string } | null; expect(doc).not.toBeNull(); @@ -611,16 +613,18 @@ describe("MCP Server", () => { test("reads document by suffix match", () => { const path = "meeting-2024-01.md"; // without meetings/ prefix let doc = testDb.prepare(` - SELECT filepath, display_path, body - FROM documents - WHERE display_path = ? AND active = 1 + SELECT 'qmd://' || d.collection || '/' || d.path as filepath, d.path as display_path, content.doc as body + FROM documents d + JOIN content ON content.hash = d.hash + WHERE d.path = ? AND d.active = 1 `).get(path) as { filepath: string; display_path: string; body: string } | null; if (!doc) { doc = testDb.prepare(` - SELECT filepath, display_path, body - FROM documents - WHERE display_path LIKE ? AND active = 1 + SELECT 'qmd://' || d.collection || '/' || d.path as filepath, d.path as display_path, content.doc as body + FROM documents d + JOIN content ON content.hash = d.hash + WHERE d.path LIKE ? AND d.active = 1 LIMIT 1 `).get(`%${path}`) as { filepath: string; display_path: string; body: string } | null; } @@ -632,9 +636,10 @@ describe("MCP Server", () => { test("returns not found for missing document", () => { const path = "nonexistent.md"; const doc = testDb.prepare(` - SELECT filepath, display_path, body - FROM documents - WHERE display_path = ? AND active = 1 + SELECT 'qmd://' || d.collection || '/' || d.path as filepath, d.path as display_path, content.doc as body + FROM documents d + JOIN content ON content.hash = d.hash + WHERE d.path = ? AND d.active = 1 `).get(path) as { filepath: string; display_path: string; body: string } | null; expect(doc).toBeNull(); @@ -643,9 +648,10 @@ describe("MCP Server", () => { test("includes context in document body", () => { const path = "meetings/meeting-2024-01.md"; const doc = testDb.prepare(` - SELECT filepath, display_path, body - FROM documents - WHERE display_path = ? AND active = 1 + SELECT 'qmd://' || d.collection || '/' || d.path as filepath, d.path as display_path, content.doc as body + FROM documents d + JOIN content ON content.hash = d.hash + WHERE d.path = ? AND d.active = 1 `).get(path) as { filepath: string; display_path: string; body: string } | null; expect(doc).not.toBeNull();