diff --git a/src/main/logseq/cli/command/upsert.cljs b/src/main/logseq/cli/command/upsert.cljs index 399e34ce33..8dd5cddc3e 100644 --- a/src/main/logseq/cli/command/upsert.cljs +++ b/src/main/logseq/cli/command/upsert.cljs @@ -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 []) diff --git a/src/test/logseq/cli/commands_test.cljs b/src/test/logseq/cli/commands_test.cljs index b42826031f..2cd34ee3d3 100644 --- a/src/test/logseq/cli/commands_test.cljs +++ b/src/test/logseq/cli/commands_test.cljs @@ -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" diff --git a/src/test/logseq/cli/main_test.cljs b/src/test/logseq/cli/main_test.cljs index 19e9915448..685c4b4a34 100644 --- a/src/test/logseq/cli/main_test.cljs +++ b/src/test/logseq/cli/main_test.cljs @@ -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))))))