fix(cli): upsert task --priority not working

This commit is contained in:
rcmerci
2026-04-11 22:52:08 +08:00
parent cdfe541552
commit 8281d344d9
3 changed files with 58 additions and 1 deletions

View File

@@ -5,3 +5,4 @@
- Ensure all command outputs are user/agent-friendly, especially error outputs.
- Do not implement new `thread-api` in db-worker unless it is absolutely necessary.
- Use logseq-cli skill; test the changed parts with the new-built logseq-cli & db-worker-node server.
- Ensure at least all cli-e2e non-sync cases passed.

View File

@@ -947,7 +947,8 @@
[action cfg block-ids]
(if (seq block-ids)
(p/let [task-tag-id (ensure-task-tag-id! cfg (:repo action))
update-properties (task-property-overrides action)
update-properties (merge (or (:update-properties action) {})
(task-property-overrides action))
clear-properties (vec (distinct (or (:clear-properties action) [])))
;; Currently only built-in properties is supported. If user properties are
;; supported, resolution needs to happen before this fn to avoid partial update failures

View File

@@ -403,6 +403,61 @@
(is false (str "unexpected error: " e))))
(p/finally done)))))
(deftest test-execute-upsert-task-page-applies-update-properties-map
(async done
(let [ops* (atom nil)
scheduled-ms (.getTime (js/Date. "2026-02-10T08:00:00.000Z"))
deadline-ms (.getTime (js/Date. "2026-02-12T18:00:00.000Z"))
action {:type :upsert-task
:mode :page
:repo "demo-repo"
:graph "demo-graph"
:page "TaskHome"
:update-properties {:logseq.property/status :logseq.property/status.todo
:logseq.property/priority :logseq.property/priority.high
:logseq.property/scheduled scheduled-ms
:logseq.property/deadline deadline-ms}}]
(-> (p/with-redefs [cli-server/ensure-server! (fn [config _repo]
(p/resolved (assoc config :base-url "http://example")))
transport/invoke (fn [_ method _ args]
(case method
:thread-api/pull
(let [[_ selector lookup] args]
(cond
(= lookup [:block/name "taskhome"])
(p/resolved {:db/id 42 :block/uuid (uuid "00000000-0000-0000-0000-000000000042")})
(= lookup [:db/ident :logseq.class/Task])
(p/resolved {:db/id 900})
(and (vector? selector) (= selector [:db/id])
(vector? lookup) (= :db/ident (first lookup)))
(p/resolved {:db/id 1})
:else
(p/resolved {})))
:thread-api/apply-outliner-ops
(let [[_ ops _] args]
(reset! ops* ops)
(p/resolved nil))
(throw (ex-info "unexpected invoke"
{:method method
:args args}))))]
(p/let [result (upsert-command/execute-upsert-task action {})]
(is (= :ok (:status result)))
(is (= [42] (get-in result [:data :result])))
(is (= [[:batch-set-property [[42] :block/tags 900 {}]]
[:batch-set-property [[42] :logseq.property/status :logseq.property/status.todo {}]]
[:batch-set-property [[42] :logseq.property/priority :logseq.property/priority.high {}]]
[:batch-set-property [[42] :logseq.property/scheduled scheduled-ms {}]]
[:batch-set-property [[42] :logseq.property/deadline deadline-ms {}]]]
@ops*))))
(p/catch (fn [e]
(is false (str "unexpected error: " e))))
(p/finally done)))))
(deftest test-execute-upsert-task-page-clears-task-properties
(async done
(let [ops* (atom nil)