add template and calculator tests

This commit is contained in:
Tienson Qin
2025-05-05 21:18:38 +08:00
parent 2193e3bae1
commit 62b654319f
4 changed files with 38 additions and 8 deletions

1
.gitignore vendored
View File

@@ -70,4 +70,5 @@ deps/shui/.clj-kondo
tx-log*
clj-e2e/.wally
clj-e2e/resources
clj-e2e/e2e-dump
.dir-locals.el

View File

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

View File

@@ -229,3 +229,30 @@
[?r :block/title \"bar\"]]}")
(k/esc)
(is (some? (w/find-one-by-text "div" "Live query (2)")))))
(deftest calculator-test
(testing "calculator"
(b/new-block "")
(util/input-command "calculator")
(util/input "1 + 2")
(is (some? (w/find-one-by-text "div.extensions__code-calc-output-line" "3")))))
(deftest template-test
(testing "template"
(b/new-block "template 1")
(util/type " #")
(util/type "Template")
(w/wait-for (w/find-one-by-text "a.menu-link mark" "Template"))
(k/enter)
(b/new-blocks ["block 1" "block 2" "block 3" "test"])
(k/arrow-up)
(util/repeat-keyboard 3 "Shift+ArrowUp")
(k/tab)
(b/jump-to-block "test")
(util/input-command "template")
(util/input "template 1")
(k/enter)
(util/exit-edit)
(let [content (w/all-text-contents ".ls-block .block-content")]
(doseq [text ["block 1" "block 2" "block 3"]]
(is (= 2 (count (filter #(= % text) content))))))))

View File

@@ -148,12 +148,13 @@
(hooks/use-effect! search-f [(hooks/use-debounced-value q 150)])
(let [matched-pages' (if (string/blank? q)
(if db-tag?
(db-model/get-all-classes (state/get-current-repo) {:except-root-class? true})
(->> (map (fn [title] {:block/title title
:nlp-date? true})
date/nlp-pages)
(take 10)))
(when db-based?
(if db-tag?
(db-model/get-all-classes (state/get-current-repo) {:except-root-class? true})
(->> (map (fn [title] {:block/title title
:nlp-date? true})
date/nlp-pages)
(take 10))))
;; reorder, shortest and starts-with first.
(let [matched-pages-with-new-page
(fn [partial-matched-pages]
@@ -185,7 +186,8 @@
(or (db/entity [:block/uuid id]) block)
block)]
[:div.flex.flex-col
(when (and (not (or (:page? block) (ldb/page? block))) (:block/uuid block'))
(when (and (not (or db-tag? (:page? block) (ldb/page? block)))
(:block/uuid block'))
(when-let [breadcrumb (state/get-component :block/breadcrumb)]
[:div.text-xs.opacity-70.mb-1 {:style {:margin-left 3}}
(breadcrumb {:search? true} (state/get-current-repo) (:block/uuid block') {})]))