mirror of
https://github.com/logseq/logseq.git
synced 2026-05-29 15:09:41 +00:00
fix: upsert page property options can't handle user properties
Fails with 'unknown built-in' error instead of just handling it. Also fix an incorrect test teardown from previous commit
This commit is contained in:
@@ -195,9 +195,13 @@
|
||||
(let [id (:id options)
|
||||
page (some-> (:page options) string/trim)
|
||||
update-tags-result (add-command/parse-tags-option (:update-tags options))
|
||||
update-properties-result (add-command/parse-properties-option (:update-properties options))
|
||||
update-properties-result (add-command/parse-properties-option
|
||||
(:update-properties options)
|
||||
{:allow-non-built-in? true})
|
||||
remove-tags-result (add-command/parse-tags-vector-option (:remove-tags options))
|
||||
remove-properties-result (add-command/parse-properties-vector-option (:remove-properties options))
|
||||
remove-properties-result (add-command/parse-properties-vector-option
|
||||
(:remove-properties options)
|
||||
{:allow-non-built-in? true})
|
||||
invalid-message (invalid-options? :upsert-page options)]
|
||||
(cond
|
||||
(seq invalid-message)
|
||||
@@ -541,9 +545,11 @@
|
||||
block-ids [page-id]
|
||||
update-tags (add-command/resolve-tags cfg (:repo action) (:update-tags action))
|
||||
remove-tags (add-command/resolve-tags cfg (:repo action) (:remove-tags action))
|
||||
update-properties (add-command/resolve-properties cfg (:repo action) (:update-properties action))
|
||||
update-properties (add-command/resolve-properties cfg (:repo action) (:update-properties action)
|
||||
{:allow-non-built-in? false})
|
||||
remove-properties (add-command/resolve-property-identifiers cfg (:repo action)
|
||||
(:remove-properties action))
|
||||
(:remove-properties action)
|
||||
{:allow-non-built-in? false})
|
||||
_ (ensure-property-identifiers-exist! cfg (:repo action) (keys (or update-properties {})))
|
||||
_ (ensure-property-identifiers-exist! cfg (:repo action) remove-properties)
|
||||
update-tag-ids (->> (or update-tags [])
|
||||
|
||||
@@ -2399,6 +2399,23 @@
|
||||
(p/catch (fn [e] (is false (str "unexpected error: " e))))
|
||||
(p/finally done)))))
|
||||
|
||||
(deftest test-build-action-upsert-page-accepts-user-property
|
||||
(testing "upsert page accepts user property key in update-properties"
|
||||
(let [parsed (commands/parse-args ["upsert" "page"
|
||||
"--page" "Home"
|
||||
"--update-properties" "{\"p1\" \"default\"}"])
|
||||
result (commands/build-action parsed {:graph "demo"})]
|
||||
(is (true? (:ok? result)))
|
||||
(is (some? (get-in result [:action :update-properties])))))
|
||||
|
||||
(testing "upsert page accepts user property key in remove-properties"
|
||||
(let [parsed (commands/parse-args ["upsert" "page"
|
||||
"--page" "Home"
|
||||
"--remove-properties" "[\"p1\"]"])
|
||||
result (commands/build-action parsed {:graph "demo"})]
|
||||
(is (true? (:ok? result)))
|
||||
(is (some? (get-in result [:action :remove-properties]))))))
|
||||
|
||||
(deftest test-execute-upsert-page-errors-when-property-does-not-exist
|
||||
(async done
|
||||
(let [action {:type :upsert-page :repo "demo" :page "Home"
|
||||
|
||||
@@ -127,4 +127,4 @@
|
||||
(is (not (string/includes? (:output result) "at "))
|
||||
"output should not contain a stack trace")))
|
||||
(p/catch (fn [e] (is false (str "unexpected error: " e))))
|
||||
(p/finally (done)))))
|
||||
(p/finally (fn [] (done))))))
|
||||
|
||||
Reference in New Issue
Block a user