|
@@ -1,12 +1,10 @@
|
|
|
(ns logseq.e2e.bidirectional-properties-test
|
|
(ns logseq.e2e.bidirectional-properties-test
|
|
|
- (:require [clojure.string :as string]
|
|
|
|
|
- [clojure.test :refer [deftest is testing use-fixtures]]
|
|
|
|
|
- [jsonista.core :as json]
|
|
|
|
|
|
|
+ (:require [clojure.test :refer [deftest is testing use-fixtures]]
|
|
|
|
|
+ [logseq.e2e.api :refer [ls-api-call!]]
|
|
|
[logseq.e2e.assert :as assert]
|
|
[logseq.e2e.assert :as assert]
|
|
|
[logseq.e2e.fixtures :as fixtures]
|
|
[logseq.e2e.fixtures :as fixtures]
|
|
|
[logseq.e2e.page :as page]
|
|
[logseq.e2e.page :as page]
|
|
|
- [wally.main :as w]
|
|
|
|
|
- [wally.repl :as repl]))
|
|
|
|
|
|
|
+ [wally.main :as w]))
|
|
|
|
|
|
|
|
(use-fixtures :once fixtures/open-page)
|
|
(use-fixtures :once fixtures/open-page)
|
|
|
|
|
|
|
@@ -14,32 +12,6 @@
|
|
|
fixtures/new-logseq-page
|
|
fixtures/new-logseq-page
|
|
|
fixtures/validate-graph)
|
|
fixtures/validate-graph)
|
|
|
|
|
|
|
|
-(defn- to-snake-case
|
|
|
|
|
- "Converts a string to snake_case. Handles camelCase, PascalCase, spaces, hyphens, and existing underscores."
|
|
|
|
|
- [s]
|
|
|
|
|
- (when (string? s)
|
|
|
|
|
- (-> s
|
|
|
|
|
- (string/replace #"[-\s]+" "_")
|
|
|
|
|
- (string/replace #"(?<!^)([A-Z])" "_$1")
|
|
|
|
|
- (string/replace #"_+" "_")
|
|
|
|
|
- (string/trim)
|
|
|
|
|
- (string/lower-case))))
|
|
|
|
|
-
|
|
|
|
|
-(defn- ls-api-call!
|
|
|
|
|
- [tag & args]
|
|
|
|
|
- (let [tag (name tag)
|
|
|
|
|
- ns' (string/split tag #"\.")
|
|
|
|
|
- ns? (and (seq ns') (= (count ns') 2))
|
|
|
|
|
- inbuilt? (contains? #{"app" "editor"} (first ns'))
|
|
|
|
|
- ns1 (string/lower-case (if (and ns? (not inbuilt?))
|
|
|
|
|
- (str "sdk." (first ns')) "api"))
|
|
|
|
|
- name1 (if ns? (to-snake-case (last ns')) tag)
|
|
|
|
|
- estr (format "s => { const args = JSON.parse(s);const o=logseq.%1$s; return o['%2$s']?.apply(null, args || []); }"
|
|
|
|
|
- ns1
|
|
|
|
|
- name1)
|
|
|
|
|
- args (json/write-value-as-string (vec args))]
|
|
|
|
|
- (w/eval-js estr args)))
|
|
|
|
|
-
|
|
|
|
|
(deftest bidirectional-properties-test
|
|
(deftest bidirectional-properties-test
|
|
|
(testing "shows reverse property references when a class enables bidirectional properties"
|
|
(testing "shows reverse property references when a class enables bidirectional properties"
|
|
|
(let [friend-prop "friend"
|
|
(let [friend-prop "friend"
|