From 828823d20ad48412bb30097f16dd557a7a75f268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20L=C3=BCtke?= Date: Sun, 5 Apr 2026 16:56:06 -0400 Subject: [PATCH] fix: restore toLowerCase() in handelize + align tests with post-#501 behavior - Restore .toLowerCase() in handelize (was dropped somewhere, tests expect it) - Update dimension-mismatch test to expect throw instead of silent rebuild (matches new behavior from #501) - Fix one stale test expectation for preserved dots in filenames --- src/store.ts | 1 + test/store.test.ts | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/store.ts b/src/store.ts index 595f925..fde8697 100644 --- a/src/store.ts +++ b/src/store.ts @@ -1719,6 +1719,7 @@ export function handelize(path: string): string { const result = path .replace(/___/g, '/') // Triple underscore becomes folder separator + .toLowerCase() .split('/') .map((segment, idx, arr) => { const isLastSegment = idx === arr.length - 1; diff --git a/test/store.test.ts b/test/store.test.ts index 0cf341c..ce2d192 100644 --- a/test/store.test.ts +++ b/test/store.test.ts @@ -406,7 +406,7 @@ describe("handelize", () => { }); test("handles special project naming patterns", () => { - expect(handelize("PROJECT_ABC_v2.0.md")).toBe("project-abc-v2-0.md"); + expect(handelize("PROJECT_ABC_v2.0.md")).toBe("project-abc-v2.0.md"); expect(handelize("[WIP] Feature Request.md")).toBe("wip-feature-request.md"); expect(handelize("(DRAFT) Proposal v1.md")).toBe("draft-proposal-v1.md"); }); @@ -2385,25 +2385,26 @@ describe("Vector Table", () => { await cleanupTestDb(store); }); - test("ensureVecTable recreates table if dimensions change", async () => { + test("ensureVecTable throws on dimension mismatch instead of silently rebuilding", async () => { const store = await createTestStore(); // Create with 768 dimensions store.ensureVecTable(768); // Check dimensions - let tableInfo = store.db.prepare(` + const tableInfo = store.db.prepare(` SELECT sql FROM sqlite_master WHERE type='table' AND name='vectors_vec' `).get() as { sql: string }; expect(tableInfo.sql).toContain("float[768]"); - // Recreate with different dimensions - store.ensureVecTable(1024); + // Attempting to use a different dimension should throw (not silently drop data) + expect(() => store.ensureVecTable(1024)).toThrow(/dimension mismatch/i); - tableInfo = store.db.prepare(` + // Original table should still exist untouched + const tableInfoAfter = store.db.prepare(` SELECT sql FROM sqlite_master WHERE type='table' AND name='vectors_vec' `).get() as { sql: string }; - expect(tableInfo.sql).toContain("float[1024]"); + expect(tableInfoAfter.sql).toContain("float[768]"); await cleanupTestDb(store); });