Przeglądaj źródła

enhance(apis): add set_property_node_tags API and corresponding test

charlie 4 dni temu
rodzic
commit
77537a337b

+ 12 - 0
clj-e2e/test/logseq/e2e/plugins_basic_test.clj

@@ -376,3 +376,15 @@
       ;; Verify the result contains valid tag structure
       (is (string? (get (first result) "uuid")) "returned tag should have uuid")
       (is (string? (get (first result) "title")) "returned tag should have title"))))
+
+(deftest set-property-node-tags
+  (testing "set property node tags"
+    (let [property-name (new-property)
+          _ (ls-api-call! :editor.upsertProperty property-name {:type "node"})
+          tag1 (ls-api-call! :editor.createTag "Tag A")
+          tag2 (ls-api-call! :editor.createTag "Tag B")
+          tags [(get tag1 "id") (get tag2 "id")]
+          _ (ls-api-call! :editor.setPropertyNodeTags property-name tags)
+          property (ls-api-call! :editor.getProperty property-name)
+          node-tags (get property ":logseq.property/classes")]
+      (is (= (set node-tags) (set tags)) "property node tags should match the set tags"))))

+ 1 - 0
src/main/logseq/api.cljs

@@ -215,6 +215,7 @@
 (def ^:export set_block_icon db-based-api/set-block-icon)
 (def ^:export remove_block_icon db-based-api/remove-block-icon)
 (def ^:export add_property_value_choices db-based-api/add-property-value-choices)
+(def ^:export set_property_node_tags db-based-api/set-property-node-tags)
 
 ;; Internal db-based CLI APIs
 ;; CLI APIs should use ensure-db-graph unless they have a nested check in cli-common-mcp-tools ns