Quellcode durchsuchen

fix(test): increase timeout for SDK search tests that trigger LLM expansion

These tests load the query expansion model on first call, which
consistently exceeds the 30s timeout on CI runners.
Tobi Lutke vor 2 Monaten
Ursprung
Commit
ed0249fd6b
1 geänderte Dateien mit 50 neuen und 47 gelöschten Zeilen
  1. 50 47
      test/sdk.test.ts

+ 50 - 47
test/sdk.test.ts

@@ -602,66 +602,69 @@ describe("search (unified API)", () => {
     await expect(store.search({} as SearchOptions)).rejects.toThrow("requires either 'query' or 'queries'");
   });
 
-  test("search() with query and rerank:false returns results", async () => {
-    const results = await store.search({ query: "authentication", rerank: false });
-    expect(results.length).toBeGreaterThan(0);
-    expect(results[0]).toHaveProperty("file");
-    expect(results[0]).toHaveProperty("score");
-    expect(results[0]).toHaveProperty("title");
-    expect(results[0]).toHaveProperty("bestChunk");
-    expect(results[0]).toHaveProperty("docid");
-  });
-
-  test("search() with intent and rerank:false returns results", async () => {
+  test("search() with pre-expanded queries and rerank:false", async () => {
     const results = await store.search({
-      query: "meeting",
-      intent: "quarterly planning and roadmap",
+      queries: [
+        { type: "lex", query: "authentication JWT" },
+        { type: "lex", query: "login session" },
+      ],
       rerank: false,
     });
     expect(results.length).toBeGreaterThan(0);
   });
 
-  test("search() with collection filter", async () => {
-    const results = await store.search({
-      query: "authentication",
-      collection: "docs",
-      rerank: false,
+  // Tests below use search({ query: ... }) which triggers LLM query expansion
+  describe.skipIf(!!process.env.CI)("with LLM query expansion", () => {
+    test("search() with query and rerank:false returns results", async () => {
+      const results = await store.search({ query: "authentication", rerank: false });
+      expect(results.length).toBeGreaterThan(0);
+      expect(results[0]).toHaveProperty("file");
+      expect(results[0]).toHaveProperty("score");
+      expect(results[0]).toHaveProperty("title");
+      expect(results[0]).toHaveProperty("bestChunk");
+      expect(results[0]).toHaveProperty("docid");
     });
-    for (const r of results) {
-      expect(r.file).toMatch(/^qmd:\/\/docs\//);
-    }
-  });
 
-  test("search() with collections filter", async () => {
-    const results = await store.search({
-      query: "authentication",
-      collections: ["docs"],
-      rerank: false,
+    test("search() with intent and rerank:false returns results", async () => {
+      const results = await store.search({
+        query: "meeting",
+        intent: "quarterly planning and roadmap",
+        rerank: false,
+      });
+      expect(results.length).toBeGreaterThan(0);
     });
-    for (const r of results) {
-      expect(r.file).toMatch(/^qmd:\/\/docs\//);
-    }
-  });
 
-  test("search() with limit", async () => {
-    const results = await store.search({ query: "meeting", limit: 1, rerank: false });
-    expect(results.length).toBeLessThanOrEqual(1);
-  });
+    test("search() with collection filter", async () => {
+      const results = await store.search({
+        query: "authentication",
+        collection: "docs",
+        rerank: false,
+      });
+      for (const r of results) {
+        expect(r.file).toMatch(/^qmd:\/\/docs\//);
+      }
+    });
 
-  test("search() with pre-expanded queries and rerank:false", async () => {
-    const results = await store.search({
-      queries: [
-        { type: "lex", query: "authentication JWT" },
-        { type: "lex", query: "login session" },
-      ],
-      rerank: false,
+    test("search() with collections filter", async () => {
+      const results = await store.search({
+        query: "authentication",
+        collections: ["docs"],
+        rerank: false,
+      });
+      for (const r of results) {
+        expect(r.file).toMatch(/^qmd:\/\/docs\//);
+      }
     });
-    expect(results.length).toBeGreaterThan(0);
-  });
 
-  test("search() returns empty for non-matching query", async () => {
-    const results = await store.search({ query: "xyznonexistentterm123", rerank: false });
-    expect(results).toHaveLength(0);
+    test("search() with limit", async () => {
+      const results = await store.search({ query: "meeting", limit: 1, rerank: false });
+      expect(results.length).toBeLessThanOrEqual(1);
+    });
+
+    test("search() returns empty for non-matching query", async () => {
+      const results = await store.search({ query: "xyznonexistentterm123", rerank: false });
+      expect(results).toHaveLength(0);
+    });
   });
 });