浏览代码

fix(test): close notification before start

Andelf 2 年之前
父节点
当前提交
6e9fec448b

+ 1 - 7
e2e-tests/fixtures.ts

@@ -121,12 +121,6 @@ base.beforeEach(async () => {
     await page.keyboard.press('Escape')
     await page.keyboard.press('Escape')
     await page.keyboard.press('Escape')
     await page.keyboard.press('Escape')
 
 
-    /*
-    const locator = page.locator('.notification-close-button').first()
-    while (await locator.isVisible()) {
-      locator.click() // ignore error
-    }
-    */
     await expect(page.locator('.notification-close-button')).not.toBeVisible()
     await expect(page.locator('.notification-close-button')).not.toBeVisible()
 
 
     const rightSidebar = page.locator('.cp__right-sidebar-inner')
     const rightSidebar = page.locator('.cp__right-sidebar-inner')
@@ -297,7 +291,7 @@ export let traceAll = function(){
   test.beforeAll(async () => {
   test.beforeAll(async () => {
     await context.tracing.startChunk();
     await context.tracing.startChunk();
   })
   })
-  
+
   test.afterAll(async () => {
   test.afterAll(async () => {
     await context.tracing.stopChunk({ path: getTracingFilePath() });
     await context.tracing.stopChunk({ path: getTracingFilePath() });
   })
   })

+ 6 - 8
e2e-tests/utils.ts

@@ -143,15 +143,13 @@ export async function loadLocalGraph(page: Page, path: string): Promise<void> {
 
 
   // If there is an error notification from a previous test graph being deleted,
   // If there is an error notification from a previous test graph being deleted,
   // close it first so it doesn't cover up the UI
   // close it first so it doesn't cover up the UI
-  let locator = page.locator('.notification-close-button').first()
-  while (await locator?.isVisible()) {
-    try { // don't fail if unable to click (likely disappeared already)
-      await locator.click()
-    } catch (error) {}
-    await page.waitForTimeout(250)
-
-    expect(locator.isVisible()).resolves.toBe(false)
+  let n = await page.locator('.notification-close-button').count()
+  if (n > 1) {
+    await page.locator('button >> text="Clear all"').click()
+  } else if (n == 1) {
+    await page.locator('.notification-close-button').click()
   }
   }
+  await expect(page.locator('.notification-close-button').first()).not.toBeVisible({ timeout: 2000 })
 
 
   console.log('Graph loaded for ' + path)
   console.log('Graph loaded for ' + path)
 }
 }

+ 0 - 2
src/main/frontend/fs.cljs

@@ -181,7 +181,6 @@
       (if (seq result) ;; electron, mobile, nfs
       (if (seq result) ;; electron, mobile, nfs
         (let [files result
         (let [files result
               files (mapv (fn [entry]
               files (mapv (fn [entry]
-                            ;; (prn ::xx entry)
                             (assoc entry :path (path/relative-path dir (:path entry))))
                             (assoc entry :path (path/relative-path dir (:path entry))))
                           files)]
                           files)]
           {:path dir :files files})
           {:path dir :files files})
@@ -237,7 +236,6 @@
   (p/let [repo-dir (config/get-repo-dir (state/get-current-repo))
   (p/let [repo-dir (config/get-repo-dir (state/get-current-repo))
           rpath (path/relative-path repo-dir href)
           rpath (path/relative-path repo-dir href)
           exist? (file-exists? repo-dir rpath)]
           exist? (file-exists? repo-dir rpath)]
-    (prn ::href-exists href exist?)
     exist?))
     exist?))
 
 
 (defn asset-path-normalize
 (defn asset-path-normalize

+ 1 - 4
src/main/frontend/fs/capacitor_fs.cljs

@@ -338,8 +338,7 @@
     (let [dir (path/path-normalize dir)]
     (let [dir (path/path-normalize dir)]
       (get-file-paths dir)))
       (get-file-paths dir)))
   (unlink! [this repo fpath _opts]
   (unlink! [this repo fpath _opts]
-    (p/let [_ (prn ::unlink fpath)
-            repo-dir (config/get-local-dir repo)
+    (p/let [repo-dir (config/get-local-dir repo)
             recycle-dir (path/path-join repo-dir config/app-name ".recycle") ;; logseq/.recycle
             recycle-dir (path/path-join repo-dir config/app-name ".recycle") ;; logseq/.recycle
             ;; convert url to pure path
             ;; convert url to pure path
             file-name (-> (path/trim-dir-prefix repo-dir fpath)
             file-name (-> (path/trim-dir-prefix repo-dir fpath)
@@ -351,14 +350,12 @@
     ;; Too dangerous!!! We'll never implement this.
     ;; Too dangerous!!! We'll never implement this.
     nil)
     nil)
   (read-file [_this dir path _options]
   (read-file [_this dir path _options]
-    (prn ::read-file dir path)
     (let [fpath (path/path-join dir path)]
     (let [fpath (path/path-join dir path)]
       (->
       (->
        (<read-file-with-utf8 fpath)
        (<read-file-with-utf8 fpath)
        (p/catch (fn [error]
        (p/catch (fn [error]
                   (log/error :read-file-failed error))))))
                   (log/error :read-file-failed error))))))
   (write-file! [_this repo dir path content opts]
   (write-file! [_this repo dir path content opts]
-    (prn ::write-file dir path)
     (let [fpath (path/path-join dir path)]
     (let [fpath (path/path-join dir path)]
       (p/let [stat (p/catch
       (p/let [stat (p/catch
                     (.stat Filesystem (clj->js {:path fpath}))
                     (.stat Filesystem (clj->js {:path fpath}))

+ 0 - 1
src/main/frontend/fs/memory_fs.cljs

@@ -58,7 +58,6 @@
       (let [fpath (path/url-to-path dir)]
       (let [fpath (path/url-to-path dir)]
         (-> (<readdir fpath)
         (-> (<readdir fpath)
             (p/then (fn [rpaths]
             (p/then (fn [rpaths]
-                      (prn ::debug rpaths)
                       (mapv #(path/path-join "memory://" %) rpaths)))
                       (mapv #(path/path-join "memory://" %) rpaths)))
             (p/catch (fn [error]
             (p/catch (fn [error]
                        (println "(memory-fs)Readdir error: " error)
                        (println "(memory-fs)Readdir error: " error)

+ 0 - 5
src/main/frontend/fs/nfs.cljs

@@ -131,7 +131,6 @@
 (defn- get-files-and-reload-all-handles
 (defn- get-files-and-reload-all-handles
   "Return list of file objects"
   "Return list of file objects"
   [root-dir root-handle]
   [root-dir root-handle]
-  (prn ::get-files-and-reload-all-file-handles root-handle)
   (p/let [files (utils/getFiles root-handle
   (p/let [files (utils/getFiles root-handle
                                 true
                                 true
                                 (fn [path entry]
                                 (fn [path entry]
@@ -214,7 +213,6 @@
                bak-filename (-> (path/relative-path repo-dir fpath)
                bak-filename (-> (path/relative-path repo-dir fpath)
                                 (string/replace "/" "_")
                                 (string/replace "/" "_")
                                 (string/replace "\\" "_"))
                                 (string/replace "\\" "_"))
-               _ (prn ::backup-file bak-filename)
                file-handle (.getFileHandle ^js bak-handle bak-filename #js {:create true})
                file-handle (.getFileHandle ^js bak-handle bak-filename #js {:create true})
                _ (utils/writeFile file-handle content)
                _ (utils/writeFile file-handle content)
 
 
@@ -232,7 +230,6 @@
     nil)
     nil)
 
 
   (read-file [_this dir path _options]
   (read-file [_this dir path _options]
-    (prn ::read-file dir path)
     (p/let [_ (when-not (string/includes? dir "/")
     (p/let [_ (when-not (string/includes? dir "/")
                 (await-get-nfs-file-handle (str "logseq_local_" dir) (str "handle/" dir)))
                 (await-get-nfs-file-handle (str "logseq_local_" dir) (str "handle/" dir)))
             fpath (path/path-join dir path)
             fpath (path/path-join dir path)
@@ -244,7 +241,6 @@
 
 
   (write-file! [_this repo dir path content opts]
   (write-file! [_this repo dir path content opts]
     ;; TODO: file backup handling
     ;; TODO: file backup handling
-    (prn ::write-file dir path)
     (let [fpath (path/path-join dir path)
     (let [fpath (path/path-join dir path)
           ext (util/get-file-ext path)
           ext (util/get-file-ext path)
           file-handle-path (str "handle/" fpath)]
           file-handle-path (str "handle/" fpath)]
@@ -305,7 +301,6 @@
             _ (protocol/unlink! this repo old-path nil)]))
             _ (protocol/unlink! this repo old-path nil)]))
 
 
   (stat [_this fpath]
   (stat [_this fpath]
-    (prn ::stat fpath)
     (if-let [handle (get-nfs-file-handle (str "handle/" fpath))]
     (if-let [handle (get-nfs-file-handle (str "handle/" fpath))]
       (p/let [_ (verify-handle-permission handle true)
       (p/let [_ (verify-handle-permission handle true)
               file (.getFile handle)]
               file (.getFile handle)]

+ 0 - 1
src/main/frontend/fs/node.cljs

@@ -25,7 +25,6 @@
       (p/catch
       (p/catch
        (p/let [result (ipc/ipc "writeFile" repo file-fpath content)]
        (p/let [result (ipc/ipc "writeFile" repo file-fpath content)]
          (when ok-handler
          (when ok-handler
-           (prn ::fuck :why-are-you-using-ok-handler)
            (ok-handler repo rpath result)))
            (ok-handler repo rpath result)))
        (fn [error]
        (fn [error]
          (if error-handler
          (if error-handler

+ 0 - 1
src/main/frontend/fs/watcher_handler.cljs

@@ -158,7 +158,6 @@
                                     (remove nil?))]
                                     (remove nil?))]
             (db/transact! graph delete-tx-data {:delete-files? true})))
             (db/transact! graph delete-tx-data {:delete-files? true})))
         (doseq [file-rpath files]
         (doseq [file-rpath files]
-          (prn ::init-watcher file-rpath)
           (when-let [_ext (util/get-file-ext file-rpath)]
           (when-let [_ext (util/get-file-ext file-rpath)]
             (->
             (->
              (p/let [content (fs/read-file repo-dir file-rpath)
              (p/let [content (fs/read-file repo-dir file-rpath)

+ 1 - 2
src/main/frontend/handler/editor.cljs

@@ -1388,7 +1388,6 @@
   (p/let [repo-dir (config/get-repo-dir repo)
   (p/let [repo-dir (config/get-repo-dir repo)
           assets-dir "assets"
           assets-dir "assets"
           _ (fs/mkdir-if-not-exists (path/path-join repo-dir assets-dir))]
           _ (fs/mkdir-if-not-exists (path/path-join repo-dir assets-dir))]
-    (prn ::ensure-assets-dir repo-dir assets-dir)
     [repo-dir assets-dir]))
     [repo-dir assets-dir]))
 
 
 (defn get-asset-path
 (defn get-asset-path
@@ -1505,7 +1504,7 @@
                             (config/get-repo-fpath
                             (config/get-repo-fpath
                              repo
                              repo
                              (path/resolve-relative-path block-file-rpath href)))]
                              (path/resolve-relative-path block-file-rpath href)))]
-          (prn ::deleting href asset-fpath)
+          (prn ::deleting-asset href asset-fpath)
           (fs/unlink! repo asset-fpath nil))))))
           (fs/unlink! repo asset-fpath nil))))))
 
 
 ;; assets/journals_2021_02_03_1612350230540_0.png
 ;; assets/journals_2021_02_03_1612350230540_0.png

+ 1 - 4
src/main/frontend/handler/repo.cljs

@@ -133,7 +133,6 @@
   "Accept: .md, .org, .edn, .css"
   "Accept: .md, .org, .edn, .css"
   [repo-url file {:keys [new-graph? verbose skip-db-transact? extracted-block-ids]
   [repo-url file {:keys [new-graph? verbose skip-db-transact? extracted-block-ids]
                   :or {skip-db-transact? true}}]
                   :or {skip-db-transact? true}}]
-  ;; (prn ::parse-and-load-file file)
   (try
   (try
     (reset! *file-tx
     (reset! *file-tx
             (file-handler/alter-file repo-url
             (file-handler/alter-file repo-url
@@ -265,9 +264,7 @@
   (route-handler/redirect-to-home!)
   (route-handler/redirect-to-home!)
   (prn ::load-new-repo repo-url :empty-graph? empty-graph? :new-graph? new-graph?)
   (prn ::load-new-repo repo-url :empty-graph? empty-graph? :new-graph? new-graph?)
   (state/set-parsing-state! {:graph-loading? true})
   (state/set-parsing-state! {:graph-loading? true})
-  (let [repo-dir (config/get-local-dir repo-url)
-        _ (prn ::repo-dir repo-dir)
-        config (or (when-let [content (some-> (first (filter #(= "logseq/config.edn" (:file/path %)) file-objs))
+  (let [config (or (when-let [content (some-> (first (filter #(= "logseq/config.edn" (:file/path %)) file-objs))
                                               :file/content)]
                                               :file/content)]
                      (repo-config-handler/read-repo-config content))
                      (repo-config-handler/read-repo-config content))
                    (state/get-config repo-url))
                    (state/get-config repo-url))

+ 2 - 6
src/main/frontend/handler/web/nfs.cljs

@@ -98,12 +98,10 @@
          *repo (atom nil)]
          *repo (atom nil)]
      ;; TODO: add ext filter to avoid loading .git or other ignored file handlers
      ;; TODO: add ext filter to avoid loading .git or other ignored file handlers
      (->
      (->
-      (p/let [_ (prn :xxx-dir-result-fn dir-result-fn)
-              result (if (fn? dir-result-fn)
+      (p/let [result (if (fn? dir-result-fn)
                        (dir-result-fn {:nfs? nfs?})
                        (dir-result-fn {:nfs? nfs?})
                        (fs/open-dir dir))
                        (fs/open-dir dir))
               _ (when (fn? on-open-dir)
               _ (when (fn? on-open-dir)
-                  (prn ::calling-on-open-dir-fn)
                   (on-open-dir result))
                   (on-open-dir result))
               root-dir (:path result)
               root-dir (:path result)
               ;; calling when root picked
               ;; calling when root picked
@@ -116,9 +114,8 @@
         (when-not (string/blank? root-dir)
         (when-not (string/blank? root-dir)
           (p/let [files (:files result)
           (p/let [files (:files result)
                   files (-> (->db-files files nfs?)
                   files (-> (->db-files files nfs?)
-                            ;; NOTE: filter, in case backend does not handle this
+                            ;; filter again, in case fs backend does not handle this
                             (remove-ignore-files root-dir nfs?))
                             (remove-ignore-files root-dir nfs?))
-                  _ (prn ::remain-files files)
                   markup-files (filter-markup-and-built-in-files files)]
                   markup-files (filter-markup-and-built-in-files files)]
             (-> files
             (-> files
                 (p/then (fn [result]
                 (p/then (fn [result]
@@ -155,7 +152,6 @@
                    (throw error))))
                    (throw error))))
       (p/finally
       (p/finally
         (fn []
         (fn []
-          (prn ::set-loading-files false)
           (state/set-loading-files! @*repo false)))))))
           (state/set-loading-files! @*repo false)))))))
 
 
 (defn ls-dir-files-with-path!
 (defn ls-dir-files-with-path!

+ 0 - 3
src/main/frontend/util/fs.cljs

@@ -173,8 +173,6 @@
             (string/replace #"/" url-encode)
             (string/replace #"/" url-encode)
             (string/replace "*" "%2A"))))
             (string/replace "*" "%2A"))))
 
 
-
-
 ;; Register sanitization / parsing fns in:
 ;; Register sanitization / parsing fns in:
 ;; logseq.graph-parser.util (parsing only)
 ;; logseq.graph-parser.util (parsing only)
 ;; frontend.util.fs         (sanitization only)
 ;; frontend.util.fs         (sanitization only)
@@ -188,7 +186,6 @@
        :triple-lowbar (tri-lb-file-name-sanity title)
        :triple-lowbar (tri-lb-file-name-sanity title)
        ;; The earliest file name rule (before May 2022). For file name check in the conversion logic only. Don't allow users to use this or show up in config, as it's not handled.
        ;; The earliest file name rule (before May 2022). For file name check in the conversion logic only. Don't allow users to use this or show up in config, as it's not handled.
        :legacy-dot    (legacy-dot-file-name-sanity title)
        :legacy-dot    (legacy-dot-file-name-sanity title)
-      ;;  :v3            ()
        (legacy-url-file-name-sanity title)))))
        (legacy-url-file-name-sanity title)))))
 
 
 (defn create-title-property?
 (defn create-title-property?

+ 0 - 1
src/main/logseq/api.cljs

@@ -326,7 +326,6 @@
   (fn []
   (fn []
     (p/let [repo ""
     (p/let [repo ""
             path (plugin-handler/get-ls-dotdir-root)
             path (plugin-handler/get-ls-dotdir-root)
-            _ (prn ::dotdir path)
             path (util/node-path.join path "preferences.json")
             path (util/node-path.join path "preferences.json")
             _    (fs/create-if-not-exists repo nil path)
             _    (fs/create-if-not-exists repo nil path)
             json (fs/read-file nil path)
             json (fs/read-file nil path)