浏览代码

fix: blocking hooks when setup repo; recover diacritic e2e test (#5952)

* fix: blocking hooks when setup repo; recover diacritic e2e test

* test(e2e): update e2e test for the new selection UI
Junyi Du 3 年之前
父节点
当前提交
ee3ac7dd21
共有 3 个文件被更改,包括 24 次插入7 次删除
  1. 7 3
      e2e-tests/page-search.spec.ts
  2. 4 2
      src/main/frontend/handler.cljs
  3. 13 2
      src/main/frontend/handler/repo.cljs

+ 7 - 3
e2e-tests/page-search.spec.ts

@@ -68,9 +68,12 @@ async function alias_test(page: Page, page_name: string, search_kws: string[]) {
   await page.waitForTimeout(500)
 
   // build target Page with alias
+  // the target page will contains the content in 
+  //   alias_test_content_1,
+  //   alias_test_content_2, and
+  //   alias_test_content_3 sequentialy, to validate the target page state
   await page.type('textarea >> nth=0', 'alias:: [[' + alias_name)
-  await page.press('textarea >> nth=0', 'ArrowRight')
-  await page.press('textarea >> nth=0', 'ArrowRight')
+  await page.press('textarea >> nth=0', 'Enter') // Enter for finishing selection
   await page.press('textarea >> nth=0', 'Enter') // double Enter for exit property editing
   await page.press('textarea >> nth=0', 'Enter') // double Enter for exit property editing
   await page.waitForTimeout(500)
@@ -81,6 +84,7 @@ async function alias_test(page: Page, page_name: string, search_kws: string[]) {
   // create alias ref in origin Page
   await newBlock(page)
   await page.type('textarea >> nth=0', '[[' + alias_name)
+  await page.press('textarea >> nth=0', 'Enter') // Enter for finishing selection
   await page.waitForTimeout(100)
 
   await page.keyboard.press(hotkeyOpenLink)
@@ -157,6 +161,6 @@ async function alias_test(page: Page, page_name: string, search_kws: string[]) {
   // TODO: search clicking (alias property)
 }
 
-test.skip('page diacritic alias', async ({ page }) => {
+test('page diacritic alias', async ({ page }) => {
   await alias_test(page, "ü", ["ü", "ü", "Ü"])
 })

+ 4 - 2
src/main/frontend/handler.cljs

@@ -101,8 +101,10 @@
            (repo-handler/setup-local-repo-if-not-exists!)
 
            :else
-           (state/set-db-restoring! false))
-
+           (state/set-db-restoring! false))))
+      (p/then
+       (fn []
+         (prn "db restored, setting up repo hooks")
          (store-schema!)
 
          (state/pub-event! [:modal/nfs-ask-permission])

+ 13 - 2
src/main/frontend/handler/repo.cljs

@@ -348,8 +348,9 @@
   (state/set-current-repo! repo)
   (db/start-db-conn! repo))
 
-(defn setup-local-repo-if-not-exists!
+(defn- setup-local-repo-if-not-exists-impl!
   []
+  ;; loop query if js/window.pfs is ready, interval 100ms
   (if js/window.pfs
     (let [repo config/local-repo]
       (p/do! (fs/mkdir-if-not-exists (str "/" repo))
@@ -367,7 +368,17 @@
              (create-custom-theme repo)
              (state/set-db-restoring! false)
              (ui-handler/re-render-root!)))
-    (js/setTimeout setup-local-repo-if-not-exists! 100)))
+    (p/then (p/delay 100) ;; TODO Junyi remove the string
+            setup-local-repo-if-not-exists-impl!)))
+
+(defn setup-local-repo-if-not-exists!
+  []
+  ;; ensure `(state/set-db-restoring! false)` at exit
+  (-> (setup-local-repo-if-not-exists-impl!)
+      (p/timeout 3000)
+      (p/catch (fn []
+                 (state/set-db-restoring! false)
+                 (prn "setup-local-repo failed! timeout 3000ms")))))
 
 (defn restore-and-setup-repo!
   "Restore the db of a graph from the persisted data, and setup. Create a new