mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 22:25:01 +00:00
add template and calculator tests
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -70,4 +70,5 @@ deps/shui/.clj-kondo
|
||||
tx-log*
|
||||
clj-e2e/.wally
|
||||
clj-e2e/resources
|
||||
clj-e2e/e2e-dump
|
||||
.dir-locals.el
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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))))))))
|
||||
|
||||
@@ -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') {})]))
|
||||
|
||||
Reference in New Issue
Block a user