Tienson Qin před 5 měsíci
rodič
revize
cead4f1c88

+ 1 - 1
clj-e2e/dev/user.clj

@@ -69,7 +69,7 @@
   (repl/resume)
 
   ;; Run specific test
-  (future (run-test logseq.e2e.commands-test/number-children-test))
+  (future (run-test logseq.e2e.commands-test/query-test))
 
   ;; after the test has been paused, you can do anything with the current page like this
   (repl/with-page

+ 28 - 1
clj-e2e/test/logseq/e2e/commands_test.clj

@@ -8,7 +8,8 @@
    [logseq.e2e.fixtures :as fixtures]
    [logseq.e2e.keyboard :as k]
    [logseq.e2e.util :as util]
-   [wally.main :as w]))
+   [wally.main :as w]
+   [wally.repl :as repl]))
 
 (use-fixtures :once fixtures/open-page)
 
@@ -202,3 +203,29 @@
     (b/jump-to-block "a")
     (util/input-command "number children")
     (is (= ["1." "2." "3."] (w/all-text-contents "span.typed-list")))))
+
+(deftest query-test
+  (testing "query"
+    (b/new-blocks ["[[foo]] block" "[[foo]] another" ""])
+    (util/input-command "query")
+    (let [btn (w/find-one-by-text "button" "Filter")]
+      (w/click btn)
+      (util/input "page reference")
+      (is (some? (w/find-one-by-text "div" "page reference")))
+      (k/enter)
+      (util/input "foo")
+      (is (some? (w/find-one-by-text "div" "foo")))
+      (k/enter)
+      (is (some? (w/find-one-by-text "div" "Live query (2)"))))))
+
+(deftest advanced-query-test
+  (testing "query"
+    (b/new-blocks ["[[bar]] block" "[[bar]] another" ""])
+    (util/input-command "advanced query")
+    (w/click ".ls-query-setting")
+    (w/click "pre.CodeMirror-line")
+    (util/input "{:query [:find (pull ?b [*])
+:where [?b :block/refs ?r]
+[?r :block/title \"bar\"]]}")
+    (k/esc)
+    (is (some? (w/find-one-by-text "div" "Live query (2)")))))

+ 1 - 1
src/main/frontend/components/block.cljs

@@ -2377,7 +2377,7 @@
                          (shui/button
                           {:size :sm
                            :variant :ghost
-                           :class (str "ls-small-icon text-muted-foreground ml-2 w-6 h-6 transition-opacity ease-in duration-300 " opacity)
+                           :class (str "ls-query-setting ls-small-icon text-muted-foreground ml-2 w-6 h-6 transition-opacity ease-in duration-300 " opacity)
                            :on-pointer-down (fn [e]
                                               (util/stop e)
                                               (when *show-query? (swap! *show-query? not)))}