diff --git a/test/wanijo/infra/system_test.clj b/test/wanijo/infra/system_test.clj index 28c6eb8..82ccb75 100644 --- a/test/wanijo/infra/system_test.clj +++ b/test/wanijo/infra/system_test.clj @@ -8,7 +8,8 @@ [wanijo.attribute.routes :as attr-routes] [wanijo.instance.routes :as inst-routes] [wanijo.instance.forms :as inst-forms] - [wanijo.instance.db :as inst-db])) + [wanijo.instance.db :as inst-db] + [clojure.pprint :as pp])) (defn single-result ([cypher] @@ -123,11 +124,11 @@ (is (= (:uuid instance) (single-result "MATCH (i:instance)-[:link]->(:instance) - RETURN i.uuid"))) + RETURN i.uuid"))) (is (= (:uuid instance2) (single-result "MATCH (i:instance)<-[:link]-(:instance) - RETURN i.uuid")))) + RETURN i.uuid")))) (testing "show instances" (let [resp (inst-routes/route-show! @@ -143,6 +144,25 @@ (is (true? (string/includes? resp (:name instance)))) (is (true? (string/includes? resp (:name schema)))))) + (testing "modifying first instance" + (let [prop-uuid (single-result + (str + "MATCH (i:instance)<-[:of]-(p:property) + WHERE i.uuid = '" (:uuid instance) "' + RETURN p.uuid"))] + (inst-routes/route-edit! + (:uuid instance) + {:params {:name "new-instance-1" + (inst-forms/attr->field-id attr) "new-value" + (inst-forms/attr->uuid-field-id attr) prop-uuid} + :session {:uuid (:uuid user)}}) + (is (= "new-value" + (single-result + (str + "MATCH (p:property) + WHERE p.uuid = '" prop-uuid "' + RETURN p.value")))))) + (testing "delete first instance" (inst-routes/route-delete! (:uuid instance)) (is (= 1 (single-result "MATCH (i:instance) RETURN COUNT(i)"))) @@ -155,3 +175,6 @@ (is (= 0 (single-result "MATCH (i:instance) RETURN COUNT(i)"))) (is (= 0 (single-result "MATCH (p:property) RETURN COUNT(p)"))) (is (= 1 (single-result "MATCH (s:schema) RETURN COUNT(s)"))))) + +(comment + (allround-system-test)) \ No newline at end of file