Explorar el Código

Add date time commands tests

Tienson Qin hace 5 meses
padre
commit
9d793aecfb
Se han modificado 3 ficheros con 34 adiciones y 2 borrados
  1. 2 1
      clj-e2e/deps.edn
  2. 1 1
      clj-e2e/dev/user.clj
  3. 31 0
      clj-e2e/test/logseq/e2e/commands_test.clj

+ 2 - 1
clj-e2e/deps.edn

@@ -4,7 +4,8 @@
         io.github.pfeodrippe/wally {:git/url "https://github.com/logseq/wally"
                                     :sha "80ea665c75704a8ca80cb22caeaec3ae6f39ffdb"}
         ;; io.github.zmedelis/bosquet {:mvn/version "2025.03.28"}
-        org.clj-commons/claypoole          {:mvn/version "1.2.2"}}
+        org.clj-commons/claypoole          {:mvn/version "1.2.2"}
+        clj-time/clj-time                  {:mvn/version "0.15.2"}}
  :aliases
  {:build {:deps {io.github.clojure/tools.build {:mvn/version "0.10.5"}}
           :ns-default build}

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

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

+ 31 - 0
clj-e2e/test/logseq/e2e/commands_test.clj

@@ -1,5 +1,8 @@
 (ns logseq.e2e.commands-test
   (:require
+   [clj-time.core :as t]
+   [clj-time.format :as tf]
+   [clj-time.local :as tl]
    [clojure.string :as string]
    [clojure.test :refer [deftest testing is use-fixtures]]
    [logseq.e2e.block :as b]
@@ -158,3 +161,31 @@
         (util/exit-edit)
         (is (= command (util/get-text ".property-k")))
         (is (= "Today" (util/get-text ".ls-datetime a.page-ref")))))))
+
+;; TODO: java "MMMM d, yyyy" vs js "MMM do, yyyy"
+(deftest date-time-test
+  (testing "date time commands"
+    (input-command "today")
+    (let [text (util/get-edit-content)]
+      (and (string/starts-with? text "[[")
+           (string/ends-with? text "]]")))
+    (b/new-block "")
+    (input-command "yesterday")
+    (let [text (util/get-edit-content)]
+      (and (string/starts-with? text "[[")
+           (string/ends-with? text "]]")))
+    (b/new-block "")
+    (input-command "tomorrow")
+    (let [text (util/get-edit-content)]
+      (and (string/starts-with? text "[[")
+           (string/ends-with? text "]]")))
+    (b/new-block "")
+    (input-command "time")
+    (let [text (util/get-edit-content)
+          t (tl/local-now)]
+      (is (= text (str (t/hour t) ":" (t/minute t)))))
+    (b/new-block "")
+    (input-command "date picker")
+    (let [text (util/get-edit-content)]
+      (and (string/starts-with? text "[[")
+           (string/ends-with? text "]]")))))