Selaa lähdekoodia

fix: switch promise returning order to avoid race condition

Junyi Du 2 vuotta sitten
vanhempi
sitoutus
3311a8a8f9
2 muutettua tiedostoa jossa 10 lisäystä ja 6 poistoa
  1. 1 0
      e2e-tests/page-search.spec.ts
  2. 9 6
      src/main/frontend/search/agency.cljs

+ 1 - 0
e2e-tests/page-search.spec.ts

@@ -40,6 +40,7 @@ test('Search page and blocks (diacritics)', async ({ page, block }) => {
 
   // check if diacritics are indexed
   const results = await searchPage(page, 'Einführung in die Allgemeine Sprachwissenschaft' + rand)
+  await page.pause();
   await expect(results.length).toEqual(5) // 1 page + 2 block + 2 page content
   await closeSearchBox(page)
 })

+ 9 - 6
src/main/frontend/search/agency.cljs

@@ -32,27 +32,30 @@
     (let [[e1 e2 e3] (get-registered-engines repo)]
       (doseq [e e2]
         (protocol/query e q opts))
-      (protocol/query e1 q opts)
       (when e3
-        (protocol/query e3 q opts))))
+        (protocol/query e3 q opts))
+      ;; Return the promise of the integrated search
+      (protocol/query e1 q opts)))
 
   (query-page [_this q opts]
     (println "D:Search > Query-page contents:" repo q opts)
     (let [[e1 e2 e3] (get-registered-engines repo)]
       (doseq [e e2]
         (protocol/query-page e q opts))
-      (protocol/query-page e1 q opts)
       (when e3
-        (protocol/query-page e3 q opts))))
+        (protocol/query-page e3 q opts))
+      ;; Return the promise of the integrated search
+      (protocol/query-page e1 q opts)))
 
   (rebuild-blocks-indice! [_this]
     (println "D:Search > Initial blocks indice!:" repo)
     (let [[e1 e2 e3] (get-registered-engines repo)]
       (doseq [e e2]
         (protocol/rebuild-blocks-indice! e))
-      (protocol/rebuild-blocks-indice! e1)
       (when e3
-        (protocol/rebuild-blocks-indice! e3))))
+        (protocol/rebuild-blocks-indice! e3))
+      ;; Return the promise of the integrated search
+      (protocol/rebuild-blocks-indice! e1)))
 
   (transact-blocks! [_this data]
     (doseq [e (get-flatten-registered-engines repo)]